0

I recentyl upgraded my web application to JSF 2.0 (MyFaces 2.0.9) and using tomcat 6 (Servlet 2.5 container).

Previously (Before upgrading to JSF 2) in the JSP files i had statments such as:

    <h:selectOneMenu id="country"
           value="#{myBean.countrySelectionControl ? (empty myBean.restrictedCountry ? '' : myBean.restrictedCountry)  : myBean.countryCode}"
           onchange="submit()"
           disabled="#{myBean.countrySelectionControl}">
            <f:selectItem itemValue="" itemLabel="------------------Select-----------------" />
            <f:selectItem itemValue="here" itemLabel="Here" />
            <f:selectItem itemValue="there" itemLabel="There" />
    </h:selectOneMenu>

but ever since the upgrade such statements are causing errors as below:

ERROR: org.ajax4jsf.webapp.BaseXMLFilter - Exception in the filter chain javax.servlet.ServletException: /jsp/CrudUser.jsp(79,9) '#{myBean.countrySelectionControl ? (empty myBean.restrictedCountry ? '' : myBean.restrictedCountry) : myBean.countryCode}' Illegal Syntax for Set Operation

Now i know i can just move the logic back to Backbean but just before doing that i wanted to check and see if there are other alternative and to know what's the "best practice" in such cases.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
ke3pup
  • 1,835
  • 4
  • 36
  • 66
  • 1
    Please don't confuse [JSTL](http://stackoverflow.com/tags/jstl/info) with [EL](http://stackoverflow.com/tags/el/info). – BalusC Feb 29 '12 at 11:42
  • 1
    Try upgrading to a more up to date version , like 2.0.12 cause the expression should work – Daniel Feb 29 '12 at 12:05

1 Answers1

2

There is a general rule of thumb to keep as much logic in your java code(model + controller) as possible opposed to having logic in templates(view). You had quite complex logic in xhtml there so migrating it to bean would be in line with this rule.

mrembisz
  • 12,722
  • 7
  • 36
  • 32