CDI Injection into a FacesConverter

Replace @FacesConverter(value = “categoryConverter”) by @Named and use <h:inputSomething converter=”#{categoryConverter}” /> or <f:converter binding=”#{categoryConverter}” /> instead of <h:inputSomething converter=”categoryConverter” /> or <f:converter converterId=”categoryConverter” /> By the way, similar problem exist for @EJB inside a @FacesConverter. It however offers a way to be grabbed by JNDI manually. See also Communication in JSF 2.0 – Getting an … Read more

How to find indication of a Validation error (required=”true”) while doing ajax command

Not specifically for required=”true”, but you can check by #{facesContext.validationFailed} if validation has failed in general. If you combine this with checking if the button in question is pressed by #{not empty param[buttonClientId]}, then you can put it together in the rendered attribute of the <h:outputScript> as follows: <h:commandButton id=”add_something_id” binding=”#{add}” value=”Add” action=”#{myBean.addSomething(false)}”> <f:ajax execute=”@form” … Read more

How to use if, else condition in jsf to display image

For those like I who just followed the code by skuntsel and received a cryptic stack trace, allow me to save you some time. It seems c:if cannot by itself be followed by c:otherwise. The correct solution is as follows: <c:choose> <c:when test=”#{some.test}”> <p>some.test is true</p> </c:when> <c:otherwise> <p>some.test is not true</p> </c:otherwise> </c:choose> You … Read more

JQuery Conflicts with Primefaces? [duplicate]

I had the same problem as described in the question. That’s why I came up with the following solution: Include the primefaces built-in jQuery library (currently 1.4.1) as including an own jQuery library leads to CSS formatting problems. Adding the target=”head” attribute allows for specifying the tag everywhere – e.g. when using templating you not … Read more

What does the PF function do in Primefaces?

PF is a Javascript function. In Primefaces 4.0 the Javascript scope of widgets changed. Prior to version 4.0 you could open a dialog widget with widgetVar.show();. In Primefaces 4.0 and above the widgets are stored in a Javascript widget array. When you call PF(‘widgetVar’) it is looking for the widget in the array and returning … Read more

Difference between h:link and h:outputLink

<h:link> uses its value attribute as the link text and its outcome attribute to generate the linked-to URL via JSF navigation rules. This makes it useful for application-internal links. Also, this component was introduced only on JSF 2.0 <h:outputLink> uses the value attribute directly as linked-to URL and the content of the tag as link … 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

When to use f:view and f:subview

<f:view> The <f:view> is only useful if you want to explicitly specify/override any of the available attributes such as locale, encoding, contentType, etc or want to attach some phase listeners. E.g. <f:view locale=”#{user.locale}” encoding=”UTF-8″ contentType=”text/html”> If you don’t specify it, then the sane JSF defaults will just be used instead, which is respectively UIViewRoot#getLocale(), UTF-8 … Read more

What are the differences between ${} and #{}?

#{} are for deferred expressions (they are resolved depending on the life cycle of the page) and can be used to read or write from or to a bean or to make a method call. ${} are expressions for immediate resolution, as soon as they are encountered they are resolved. They are read-only. You can … Read more

tech