In a Screen to be rendered by a JSF Implementation, I had to show a static drop down or list box (which means the values are not changing ), So I decided to use a list of select Items and in the getter of the List , I am populating all the select Items as this
List.add(new SelectItem(VALUE,TEXT)) and so on..
If I used this way – What are the pitfalls? I made this List static since this will be common for all the Request Scoped Beans the JSF Implementation creates. Is this okay to do?
Sometimes , the items are added twice if multiple requests are fired.Is there an Application Scope ? or Whats the standard way of doing these stuff?
I’m also looking into API.Sometimes SO is quicker.
I’m using JSF Apace My Faces 1.2 without Tomahawk or any extra libs
Thanks,
This indicates that you’re adding the items in the getter method like follows
This is not good. A javabean getter should have the sole purpose to return a bean property or at highest do lazy loading, not to do some business stuff. You should create and fill the list during bean construction
or initialization
or
@PostConstructThere is. Just use
<managed-bean-scope>application</managed-bean-scope>.An application scoped bean is the way to go.
See also: