webtier@glassfish.java.net

JSF - AJAX does not update JSTL forEach loop (getter before setter)

From: <forums_at_java.net>
Date: Tue, 1 Nov 2011 20:45:25 -0500 (CDT)

I have a tree structure which is navigated via a single selectOneListBox.
Each time the user selects and item, its children a displayed in the dropdown
field. A breadcrumb trail is also being constructed to allow for navigation
back to any of the parent nodes in the tree structure. On each selection I am
updating the entire h:panelGroup which seem to work for most of however the
bread crumb trail is not updated correctly. I added additional debugging to
my treeController and found that the getBreadCrumbs method was consistently
called before the setSelectedItemId method. This results in the breadcrumb
trail being constructed before the current selected is given the option to
update the object model. So the previous selection is always shown in the
breadcrumb trail. It seems to be that it is incorrect to call any getter
before all setters have completed however this seems to be what is happening.
I tried searching online but could not find any solution to this problem.

<ui:define name="content">     <f:view>       <h:form id="dropdown">  
      <h:panelGroup id="everything">                    
<h:commandButton value="Root" styleClass="button"
action="#{treeController.displayRootItem}"/>           Bread crumbs:  
        <c:forEach var="breadCrumb"
items="${treeController.breadCrumbs}">             <h:commandButton
value="#{breadCrumb.name}" styleClass="button"
action="#{treeController.displayBreadCrumb}">              
<f:setPropertyActionListener value="#{breadCrumb}"
target="#{treeController.currentItem}"/>             </h:commandButton>
          </c:forEach>           <hr/>          
<h:selectOneListbox id="itemList" value="#{treeController.selectedItemId}"
size="10" styleClass="contactList" tabindex="2">            
<f:selectItems value="#{treeController.items}"/>             <f:ajax
execute="itemList" render="everything" onevent="eventLog"
onerror="errorLog"/>           </h:selectOneListbox>            
      <hr/>           Item : <h:outputLabel
value="#{treeController.selectedItemId}"
rendered="#{treeController.selectedItemId != 0}"/>           Parent :
<h:outputLabel value="#{treeController.selectedParentId}"
rendered="#{treeController.selectedParentId != 0}"/>           <br/>  
        <h:inputText value="#{treeController.currentItem.name}"
rendered="#{treeController.currentItem != null}"/>          
</h:panelGroup>                 </h:form>     </f:view>  
</ui:define>
 


--
[Message sent by forum member 'lostinspace2011']
View Post: http://forums.java.net/node/859532