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

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

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

Skip required validation and invoke the application

Just put that condition straight in the required attribute. <h:inputText … required=”#{someCondition}” /> It namely just accepts any EL expression like as many other attributes. Many starters think that you can only hardcode a “true” or “false” string in it. This is untrue. For example, when you want to let it evaluate true only when … Read more

JSF resource versioning

If I do like this resources/js/1_0_0/mainscript.js It does not work. It says RESOURCE_NOT_FOUND This will work if you specify js as library name. <h:outputScript library=”js” name=”mainscript.js” /> However, this is not the proper usage of a resource library. Rather introduce one. resources/default/1_0_0/js/mainscript.js Then you can specify it as follows: <h:outputScript library=”default” name=”js/mainscript.js” /> They did … Read more