Pass method argument/parameter to composite-component action attribute

This is indeed not going to work. You cannot pass “extra” parameters afterwards like that. The method-signature as you have declared has to be fulfilled in the side where the composite component is been used. E.g. <my:button action=”#{bean.remove(‘Somestring’)}” /> The composite component implementation should just look like this <h:commandButton value=”Remove” action=”#{cc.attrs.removeFieldAction}” /> If this is … Read more

How to re-execute javascript function after form reRender?

Simplest way is to just put the JS function call in the to-be-updated component itself. <h:form> … <h:commandButton value=”submit”><f:ajax render=”@form” /></h:commandButton> <h:outputScript>someFunction();</h:outputScript> </h:form> This way it’s executed as the page loads and also if the form get updated by ajax. As to the <f:ajax> itself, you could also use its onevent attribute. <f:ajax … onevent=”handleAjax” … Read more

jsf validate two fields in one time [duplicate]

Best what you can do is to grab the other UIInput component by UIViewRoot#findComponent() inside the validate() method and then determine the submitted value by either UIInput#getSubmittedValue() (when it occurs after the currently validated component in the component tree) or UIInput#getValue() (when it occurs before the current component and thus is already validated). E.g. public … Read more

Why use a JSF ExceptionHandlerFactory instead of redirection?

The particular example does only one useful thing: it saves the view ID as a request attribute so that you can use for example <h:link value=”Go back to previous page” outcome=”#{currentViewId}” /> But this is not tremendously useful as the raw request URI is already available by the <error-page>‘s default request attribute javax.servlet.error.request_uri. <h:outputLink value=”#{requestScope[‘javax.servlet.error.request_uri’]}”>Go … Read more

java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String

java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String; This will happen when there are Xerces JAR files in your WAR’s /WEB-INF/lib (or even JRE’s /lib) which is of an older version than the one internally used by the servletcontainer. The older version, which apparently implements JAXP of Java 1.4.2 or older, is missing the mentioned method which was introduced in JAXP … Read more

How can I get a message bundle string from inside a managed bean?

You can get the full qualified bundle name of <message-bundle> by Application#getMessageBundle(). You can get the current locale by UIViewRoot#getLocale(). You can get a ResourceBundle out of a full qualified bundle name and the locale by ResourceBundle#getBundle(). So, summarized: FacesContext facesContext = FacesContext.getCurrentInstance(); String messageBundleName = facesContext.getApplication().getMessageBundle(); Locale locale = facesContext.getViewRoot().getLocale(); ResourceBundle bundle = ResourceBundle.getBundle(messageBundleName, … Read more

Why Facelets is preferred over JSP as the view definition language from JSF 2.0 onwards?

True, JSP has some templating capabilities, but the biggest disadvantage of using JSP in JSF is that JSP writes to the response as soon as it encounters template text content, while JSF would like to do some pre/post processing with it. In JSF 1.0/1.1 the following JSF code <h:outputText value=”first”/> second <h:outputText value=”third”/> fourth would … Read more

Validate order of items inside ui:repeat

There’s physically only one UIInput component whose state changes depending on the current iteration round of UIRepeat. It’s available by just its client ID without the UIRepeat index: findComponent(“formId:inputId”) (the UIRepeat index is only of significance in the client side). However, when the component is programmatically been accessed outside the context of UIRepeat this way, … Read more