Should I use JSTL in JSF 2 xhtml pages?

I would like to bind a fallback bean field to the selected selectOneListbox value. This value may be zero, so I want to convert it to 0. This will set the selected value to the "default" selectItem value. I am using JSF2

I plan to do this using http://java.sun.com/jstl/core taglib (using <c:if test="#{empty...}>)

My question is : is there a "cleaner" way to do this. Maybe JSF (2) related taglib?

Thankyou!

+3
source share
2 answers

The "JSFish" way to do this is to create a converter:

public Object getAsObject(FacesContext context, UIComponent comp, String param) {
    return (param.equals("0")) ? null : param;
}

public String getAsString(FacesContext context, UIComponent comp, Object obj) {
    return (obj == null) ? "0" : obj.toString();
}
+3

Long Integer String . EL ( boolean) / .

+3

Source: https://habr.com/ru/post/1726977/


All Articles