2 Replies Latest reply on Dec 22, 2011 3:16 AM by omid pourhadi

    value becomes invalid (null) after posting form

    omid pourhadi Apprentice

      Hi,


      I have 2 comboboxes (City, Region) that one of them (region) fills based on another as below




      <h:selectOneMenu value="#{instituteHome.instance.city}">
          <s:selectItems value="#{cityQuery.resultList}" var="_city" label="#{_city.name}"/>
          <s:convertEntity />
          <a:support event="onchange" ajaxSingle="true" reRender="cityField" />
      </h:selectOneMenu>





      <h:selectOneMenu id="cityField" value="#{instituteHome.instance.region}">
          <s:selectItems value="#{regionQuery.resultList}" var="_region" label="#{_region.name}"/>
          <s:convertEntity />
      </h:selectOneMenu>



      RegionQuery.java




      @In(create = true)
      InstituteHome instituteHome;
      
      @Override
      public List<Region> getResultList(){
         if(instituteHome.instance.getCity() != null){ // after posting form turns into null
                return region where city = instituteHome.instance.getCity()
         }else{
           return null; //this is cause of invalid value 
         }
         
      }



      if i return super.getResultList() instead of null the problem will be solved but in this case
      user can see all regions without selecting a city


      I'm wondering why when i select city from combobox the instituteHome.instance.getCity() is not null but after posting form it turns into null


      Does anyone know how i can solve this problem ?


      Thanks in advanced