2 Replies Latest reply on Jan 24, 2008 7:48 AM by neiti01

    Problems using a4j:support, s:selectItems and s:convertEntit

    neiti01

      Hi,

      I am using two selectOneMenus with s:convertEntity. When a value is selected in the first selectOneMenu the selectItems of the second one are reloaded.

      Everything works fine until i press a a4j:commandButton to reRender a dataTable based on the selected values. After pressing the button every value set from the
      selectOneMenu is set to null and choosing another value in the selectOneMenu don't work.

      I tried playing around with ajaxSingle, immediate and a4j:region but nothing seems to work.

      Similar combinations of those items in the same application work without problems. But this particular page isn't working no matter what i'm doing.

      Here is the relevant code:

      View:

      <a4j:commandButton actionListener="#{tool1.filterData}" value="#{labels['xrail.tool1.filter']}" reRender="detailList" status="progress"/>
      
       <a4j:region id="statusRegion">
       <a4j:status startText="#{labels['xrail.tool1.processing']}" stopText="" id="progress"/>
       </a4j:region>
       <rich:toolBar contentStyle="width: 100%">
       <h:panelGrid columns="1" style="width: 100%">
       <rich:spacer width="1" height="15" />
       <rich:dataTable id="detailList" value="#{tool1.details}" var="detail" style="width:100%" headerClass="top_align">
       <rich:column>
       <f:facet name="header">
       <h:panelGrid columns="1">
       #{labels['xrail.tool1.departure_country']}
       <h:selectOneMenu value="#{tool1.departureCountry}" id="departureCountry">
       <s:selectItems value="#{selectItems.railways}" var="railway" label="#{railway.name}" noSelectionLabel=" "/>
       <s:convertEntity />
       <a4j:support event="onchange" reRender="departureStation"/>
       </h:selectOneMenu>
       </h:panelGrid>
       </f:facet>
       <h:outputText value="#{detail.origStation.luRailway.name}"/>
       </rich:column>
       <rich:column>
       <f:facet name="header">
       <h:panelGrid columns="1">
       #{labels['xrail.tool1.departure_station']}
       <h:selectOneMenu value="#{tool1.departureStation}" id="departureStation" disabled="#{tool1.departureCountry==null}" style="font-size:10px">
       <s:selectItems value="#{tool1.departureCountry.luStations}" var="station" noSelectionLabel=" "
       label="#{station.stationCode}-#{station.name}" />
       <s:convertEntity />
       </h:selectOneMenu>
       </h:panelGrid>
       </f:facet>
       <h:outputText value="#{detail.origStation.stationCode}-#{detail.origStation.name}"/>
       </rich:column>


      Helper bean to populate selectItems:
      @Name("selectItems")
      @Scope(ScopeType.EVENT)
      public class SelectItems {
      
       @In
       private EntityManager entityManager;
      
       public List getRailways() {
       return entityManager.createQuery("Select r from LuRailway r where r.isValid = true order by r.name asc").getResultList();
       }
      
      }
      


      Backing bean for page:
      @Name("tool1")
      @Scope(ScopeType.PAGE)
      public class Tool1 {
      
       @In
       private EntityManager entityManager;
      
       private LuRailway departureCountry;
       private LuStation departureStation;
      
       public LuStation getDepartureStation() {
       return departureStation;
       }
      
       public void setDepartureStation(LuStation departureStation) {
       this.departureStation = departureStation;
       }
      
       public LuRailway getDepartureCountry() {
       return departureCountry;
       }
      
       public void setDepartureCountry(LuRailway departureCountry) {
       this.departureCountry = departureCountry;
       }
      
       public void filterData(ActionEvent event) {
       //Makes some sort of search request
       }
      


      In both entity beans equals and hashCode are overridden but it also don't works if i don't override them.

      What causes this problem?

      Thanks in advance.

      Markus