selectOneListBox not calling setTarget
deanhiller2000 Jun 21, 2010 4:17 PMThis should be simple but for the life of me, it is just not calling setSelectedScript though it is calling getSelectedScript. This is mostly supposed to be a read page so no long conversations going on here either(We really really don't want one as this is the main landing page where conversations end).
xhtml
<h:form id="scriptsform"> <div id="scriptstable"> <h2>Scripts</h2> <!-- NOTE: init here instead of pages so freaking ajax does not keep reloading and initing --> #{listScripts2.initialize()} <div id="scriptlist" style="float:left; width:200px"> <h:selectOneListbox id="scripts" value="#{listScripts2.selectedScript}" required="true" size="21" styleClass="singleListOfScripts"> <s:selectItems var="s" value="#{listScripts2.scripts}" label="#{s.name}" > </s:selectItems> <s:convertEntity /> <a:support event="onchange" reRender="desc" immediate="true" ajaxSingle="true" bypassUpdates="false"/> </h:selectOneListbox> </div> <s:div id="desc" style="float:left; width:200px"> <h3>Name:</h3> #{listScripts2.selectedScript.name}<br/><br/> <h3>Language:</h3> #{listScripts2.selectedScript.language}<br/><br/> <h3>Description:</h3> <h:outputText escape="false" value="#{listScripts2.selectedScript.description}" /> </s:div> <br/><br/> </div> </h:form>
Java bean
@Name("listScripts2") @Scope(ScopeType.SESSION) public class ListScriptsAction2 extends ActionBase implements Serializable { private static final long serialVersionUID = -6587296133429904762L; private Script selectedScript; protected List<Script> scripts; // NOTE: Each time we hit the page, this makes sure // we reload the entities.... public void initialize() { if(selectedScript != null) { if(selectedScript.getId() != null) selectedScript = entityManager.find(Script.class, selectedScript.getId()); else selectedScript = null; } scripts = Script.findAllScripts(entityManager); } public List<Script> getScripts() { return scripts; } public Script getSelectedScript() { return selectedScript; } public void setSelectedScript(Script selectedScript) { this.selectedScript = selectedScript; } }
ONE last question. I would prefer the list to be in the PAGE scope, the action bean in EVENT scope(as nearly all action beans I think should be stateless) and then the selectedScript in SESSION scope so if you come back to this page in any browser tab, the last selected value is selected for you. Is this possible though?
I guess first, I need the dang setSelectedScript to be called. Any ideas on why it is not invoked when I make a selection and only getter is called every time I choose something new?
thanks,
Dean