f:viewParam doesn’t pass required parameter when new xmlns.jcp.org namespace is used

The way how the new xmlns.jcp.org XML namespaces are been handled is broken in the first Mojarra releases 2.2.0 and 2.2.1. It has been fixed in Mojarra 2.2.2 (note: ticket in the link describes different problem symptom, but under the covers, it’s essentially the same cause). It’s recommended to upgrade to Mojarra 2.2.2. GlassFish 4.0 … Read more

Primefaces dialog + commandButton

You can try either of the following , I vote number one, it’s a cleaner design IMO Bring the <p:dialog/> outside of the general <h:form/> and put an <h:form/> inside it instead <p:dialog id=”dlg” header=”#{messages.chooseSkillLevel}” widgetVar=”dlg” modal=”true” dynamic=”true”> <h:form> <h:dataTable value=”#{editSkills.skillsAndLevels}” var=”skillslevel”> <h:column> #{skillslevel.skill.umiejetnosc} </h:column> <h:column> <p:selectOneMenu value=”#{skillslevel.level}” > <f:selectItems value=”#{editSkills.levels}” var=”level” itemLabel=”#{level.stopien}” itemValue=”#{level.id}” /> … Read more

Display Current Date on JSF Page

You could register an instance of java.util.Date as a request scoped bean in faces-config.xml. <managed-bean> <managed-bean-name>currentDate</managed-bean-name> <managed-bean-class>java.util.Date</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> This way it’s available as #{currentDate} without the need for a custom backing bean class. Update: the JSF utility library OmniFaces has such a bean already registered as #{now}. So if you happen to use OmniFaces … Read more

What is STATE_SAVING_METHOD parameter in JSF 2.0

java.io.NotSerializableException This kind of exception has usually a message in the root cause which shows the fully qualified class name of the class which doesn’t implement Serializable. You should pay close attention to this message to learn about which class it is talking about and then let it implement Serializable accordingly. Often, making only your … Read more

Passing parameter to JSF action

The <f:param> sets a HTTP request parameter, not an action method parameter. To get it, you would need to use <f:viewParam> or @ManagedProperty. In this particular case, the latter is more suitable. You only have to replace CDI annotations by JSF annotations in order to get @ManagedProperty to work: @ManagedBean(name=”bean”) @RequestScoped public class ActionParam { … Read more

Create table columns dynamically in JSF

You can achieve this with standard JSF components using a <h:panelGrid> wherein <c:forEach> is been used to generate the cells during the view build time. The <ui:repeat> won’t work as that runs during view render time. <h:panelGrid columns=”5″> <c:forEach items=”#{bean.items}” var=”item”> <h:panelGroup> <h:outputText value=”#{item.value}” /> </h:panelGroup> </c:forEach> </h:panelGrid> As to component libraries, I don’t see … Read more