2 Replies Latest reply on May 7, 2009 9:39 AM by Sandeep Shenoy

    Show or Hide s:decorate based on dropdown

    Sandeep Shenoy Newbie

      Hi,


      I need to hide a field contained within a s:decorate tag based on value selected in dropdown. The code i attempted  is as follows - but it does not seem to work as expected, any help is greatly appreciated


      The dropdown field:





      <s:decorate id="paramDecoration" template="layout/edit.xhtml">
                      <ui:define name="label">Name</ui:define>
                <h:selectOneMenu id="ruleset"
                             required="true"
                             style="width:170px;"
                                value="#{ruleElemHome.instance.paramMetadata}">
                            <s:selectItems
                                 value="#{paramMetadataList.resultList}" 
                                 var ="paramMetadata"
                                 label="#{paramMetadata.name}" />
                            <s:convertEntity/>
                            <a4j:support event="onchange" reRender="valueDecoration" ajaxSingle="true"/>
                            </h:selectOneMenu>
                            
      </s:decorate>
      
      The field that needs to hidden
      <s:decorate id="valueDecoration" template="layout/edit.xhtml" rendered="#{ruleElemHome.enumField eq 'false'}">
                      <ui:define name="label">value</ui:define>
                      <h:inputText id="value" 
                                 size="32"
                            maxlength="32"
                                value="#{ruleElemHome.instance.value}">
                          <a:support event="onblur" reRender="valueDecoration" bypassUpdates="true" ajaxSingle="true"/>
                      </h:inputText>
                      <h:outputText value="#{ruleElemHome.enumField}" />
                    </s:decorate>
      
      
      The home class which sets the field called enumField based on which the "value" field is to be hidden
      
      private String enumField=null;
              public void setEnumField(String enumField) {
                      this.enumField = enumField;
              }
              
              
              
              public String getEnumField() {
                      
                      if(this.getInstance().getParamMetadata()!=null && this.getInstance().getParamMetadata().getDataType()!=null) {
                              
                              if(this.getInstance().getParamMetadata().getDataType().equalsIgnoreCase("ENUM")) {
                                      
                                      this.enumField = "true";
                              }
                      }
                      return this.enumField;
              }