Friday, 15 June 2012

el - Access static property in JSF -


One of my backing beans has a constant list of items:

  List & lt; SelectItem & gt; Countries = New Arrestists & lt; SelectItem & gt; ();  

with the following gates and sets:

  public static list & lt; SelectItem & gt; GetCountries () {Return Countries; } Public static zero set country (list & amp; lt; SelectItem & gt; country) {LoadSelectItemsBean.countries = countries; }  

I'm having trouble accessing the static list through my XHTML page. I have tried that:

   & Lt; Ace: ajax / & gt; & Lt; / Ace: simpleSelectOneMenu & gt;  

The problem line is:

  & lt; F: selectItems value = "# {loadSelectItemsBean.countries}" />  

The result of which is the exception:

  javax.el.PropertyNotFoundException: /pages/GeneralCarrierData.xhtml @ 394,64 value = "# {loadSelectItemsBean states. } ": Property can not be found on 'states' type com.oag.reference.util.LoadSelectItemsBean  

how to correctly reference a static property from a backing bean Can you give any advice about this?

Thanks

No definitions per language are static Gates and the setters simply can not be static, although they can refer to a fixed variable. But the outside world does not see it.

You have 3 options:

  1. Remove static modifier from the recipient. The entire setter is unnecessary, you can remove it.

      Public listing & lt; SelectItem & gt; GetCountries () {Return Countries; }  
  2. If you really insist on reaching a static "property" (function), then create EL function. Detailed answer can be found in this answer:

  3. The complete list to enum and use it. Detailed answer can be found in this answer:


No comments:

Post a Comment