facelets

Is it possible to change the element id separator in JSF?

微笑、不失礼 提交于 2019-12-17 20:06:21
问题 For example, the following snippet: <h:form id="levelone"> <h:inputText id="leveltwo" value="Test" /> </h:form> generates the following markup: <form id="levelone" name="levelone" method="post" action="/test/testPage.html" enctype="application/x-www-form-urlencoded"> <input id="levelone:leveltwo" type="text" name="levelone:leveltwo" value="Test" /> </form> Is it possible to change the automatically generated ids to use a different separator than colon? For example, I'd like to change levelone

XML prolog / instruction not removed from XHTML output

若如初见. 提交于 2019-12-17 19:38:31
问题 I'm starting to learn JavaServer Faces (JSF). I'm using GlassFish 3+. I've just created a new JSF project in NetBeans and run the project. It worked fine, but upon examining the XHTML output, I noticed the XML declaration was left in. This messes up the DOCTYPE declaration (which is always supposed to be first in the document). Is JSF supposed to remove the XML declaration, or is there something I've done wrong? 回答1: Facelets will by default only remove it from compositions (include files and

How to change head elements of a page when using ui:composition

隐身守侯 提交于 2019-12-17 18:52:15
问题 I want to ask a question that i have a master template like this <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <title>Login</title> </h:head> <h:body> <div id="top"> <ui:insert name="top"> <ui:include src="header.xhtml" id="header"/> </ui:insert>

Why not JSF pages are precompiled (atleast partially) but instead parsed, evaluated each time view is built?

喜你入骨 提交于 2019-12-17 17:59:41
问题 I don't know whether it is true or not but from what I've read, I believe, JSF EL & xhtml pages are not pre-compiled & just used when needed but instead they are parsed, evaluated, compiled each time the view is built. I fail to understand why this is done so! Why not just parse & compile it just once, ok atleast partially , rendering of some components may depend on a dynamically fetched variable so they may be rendered later but why delay that for all the components on page? Whatever

Concatenating strings within EL expression defined in an attribute of a facelets tag

让人想犯罪 __ 提交于 2019-12-17 17:50:11
问题 I need to write an EL expression for an attribute which goes something like this: #{cc.attrs.appreciatedByCurrentUser ? (cc.attrs.count +'<br/>'+ (cc.attrs.count-1)) : ((cc.attrs.count+1) +'<br/>'+ cc.attrs.count)} Now the problem is that this gives an error as strings cannot be concatenated, the way I am doing it. So how can I rectify this? I'm using JSF 2.0 with facelets. EDIT : I'm resolving the issue using the following inline javascript <script type="text/javascript"> var count=#{cc

How to change css class for the inputfield and label when validation fails?

主宰稳场 提交于 2019-12-17 16:43:22
问题 Suppose I have a username to validate, in this case I need to show username outputText and username inputText field in red color when validation fails along with error message. I tried to bind all these in a panelgroup so that if validation fails all field should be affected. But simply putting panelgroup is not working. My backing bean validator public void emailValidate(FacesContext context, UIComponent componentToValidate, Object value) throws ValidatorException { String email = value

<!--[if IE]> conditional comments are rendered HTML-escaped in Facelets

微笑、不失礼 提交于 2019-12-17 14:55:09
问题 I'm trying to use an IE conditional comment to declare a CSS resource: <h:outputStylesheet name="common.css" library="css" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="#{resource['css:ie.css']}" /> <![endif]--> However, that doesn't seem to work. I'm seeing this in my generated HTML output: <link type="text/css" rel="stylesheet" href="/context/faces/javax.faces.resource/common.css?ln=css" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="/context/faces/javax.faces

JSF 2: how to pass an action including an argument to be invoked to a Facelets sub view (using ui:include and ui:param)?

自作多情 提交于 2019-12-17 10:57:32
问题 This is basically an extension to this answer. I am trying to get an argument into a method/action call (for a delete button in a list/data table). Client: <ui:include src="..."> <ui:param name="acceptButtonBean" value="#{repoHome}" /> <ui:param name="acceptButtonAction" value="removeIndividualDocument(#{doc.id})" /> </ui:include> Sub view: <h:commandButton value="Continue" action="#{acceptButtonBean[acceptButtonAction]}" /> ... </h:commandButton> However, JSF fails with an exception saying:

How to include JavaScript files by h:outputScript? [duplicate]

﹥>﹥吖頭↗ 提交于 2019-12-17 10:46:22
问题 This question already has answers here : How to reference CSS / JS / image resource in Facelets template? (4 answers) Closed 3 years ago . I want to use jQuery Validate plugin with JSF for client side form validation. I am finding basic difficulty in importing the resources. In my JSF page I have <h:outputScript library="js" name="jquery-1.6.2.js"></h:outputScript> <h:outputScript library="js" name="jquery.validate.js"></h:outputScript> <h:outputScript library="js" name="jquery.maskedinput.js

How can I remove HTML comments in my Facelets?

泪湿孤枕 提交于 2019-12-17 09:37:53
问题 I would like to remove all HTML comments from my facelets before delivering to end users. Does any standard approach exist? 回答1: There are actually two ways: To remove ALL comments, add this to web.xml : <context-param> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> or when you're still on JSF 1.2 which doesn't use Facelets as default view technology yet: <context-param> <param-name>facelets.SKIP_COMMENTS</param-name> <param-value