jsf - Getter called multiple times - selected item not retained in JSP -
i working jsf 1.2 , use little advice. have fmb (planfmb.java) contains array list of select items , single selecteditem.
when page loads, getprojects() method correctly called , displays projects expected. strange thing though, getselecteditem() method called 3 times (once of each project). not sure if typical behavior:
systemout o getselecteditem = null systemout o getselecteditem = null systemout o getselecteditem = null
also, have command link in jsp, when clicked same thing, calls getselecteditem() method 3 times:
<h:commandlink action="#{plandocbean.classaction}" id="classactionenlink">
planfmb.java
string selecteditem = null; private list<selectitem> selectitems = null; public string getselecteditem() { system.out.println("getselecteditem = " + selecteditem); return selecteditem; } public void setselecteditem(string selecteditem) { this.selecteditem = selecteditem; system.out.println("setselecteditem = " + selecteditem); } public list<selectitem> getprojects() { if (selectitems == null) { selectitems = new arraylist<selectitem>(); selectitems.add(new selectitem("project1", "project1")); selectitems.add(new selectitem("project2", "project2")); selectitems.add(new selectitem("project3", "project3")); } return selectitems; } <h:selectonemenu id="items" value="#{plandocbean.selecteditem}"> <f:selectitems value="#{plandocbean.projects}" /> </h:selectonemenu>
one last thing, actual selected item not retained in select menu when page reloads.
any feedback appreciated. thanks!
Comments
Post a Comment