0 Replies Latest reply on Oct 21, 2009 5:58 PM by bossy

    How to update search criteria from EntityQuery class

    bossy

      Hello,


      I have a seam application (Seam 2.1.1) that has one of these seam-gen generated xxxList.xhtml pages.


      In my page I need to be able to select a search criteria from a selectOneMenu. Since the list in that control can be too long and the users already know a lot of the codes/id's for the items in that list they asked for a way of simply entering the code/id of the item that is then searched for and the appropriate item is displayed in the selectOneMenu.They should still be able to scroll the selectOneMenu and select an item from there.


      This is what I added to my search form:




      <s:decorate template="layout/edit.xhtml" id="acsField"> 
              <ui:define name="label">ACS</ui:define>         
               <h:inputText id="acsCode" size="3"  valueChangeListener="#{alList.findContact}" > 
                      <a4j:support event="onblur"    reRender="acsField,acsText"  
                              ajaxSingle="true" bypassUpdates="false" eventsQueue="lq"/> 
              </h:inputText>                
              
              <h:selectOneMenu value="#{alList.al.contactByAlAcs.contactId}"  id="acsText" 
                     onchange="alert('#{alList.al.contactByAlAcs.contactId}');"> 
                      <s:selectItems value="#{acsList}" var="_c" itemValue="#{_c.contactId}" 
                                     label="#{_c.contactName}" noSelectionLabel="Select Acs ..." />                                                                
              </h:selectOneMenu>      
      </s:decorate>






      In my xxxList.java class I have this method:




      public void findContact(ValueChangeEvent event)
      {
         /// search for the contact
         this.getAl().setContactByAlInstaller(contact); 
      }




      I was expecting that by setting the above value, the reRendering of the acsField will result in the contact name being displayed in the drop down box. This unfortunatelly does not happen. Not only that, but I added an alert for the onchange event of the drop down, When I select something from the drop down list the alert displays blank.


      I would be very grateful if someone explains why this is not working. I used the same approach in one of my xxxEdit.xhtml pages and it works. The only difference I could see between both situations is that in the case of the xxxEdit.xhtml the backing is an EntityHome class. Could that be the reason and how?


      Thanks in advance.