0 Replies Latest reply on Oct 21, 2008 8:51 AM by gopib

    Using Select One Menu

    gopib

      Hi all,

      I have a <h:selectOneMenu> wich is a drop down list .In the drop down list if i select an item it should be displayed there.i.e if i hav a sms,ussd,gprs etc in <h:selectOneMenu> if i select sms an output field and an input text field should be displayed,like wise if i select ussd an output field and an input text field should be displayed.


      code is below please view.
      -----------------------------


      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a="http://richfaces.org/a4j" template="mainTemplate.xhtml">
      <!--

      function display(obj,id1.id2)
      {
      txt = obj.options[obj.selectedIndex].value;
      document.getElementById(id1).style.display = 'none';
      document.getElementById(id2).style.display = 'none';

      if ( txt.match(id1) )
      {
      document.getElementById(id1).style.display = 'block';
      }
      if ( txt.match(id2) )
      {
      document.getElementById(id2).style.display = 'block';
      }
      }
      -->

      <ui:define name="innerbody">
      <h:form id="addServiceForm" enctype="multipart/form-data">
      <ui:include src="/stylesheet/defaultStyles.css" />

      <rich:panel headerClass="headerFont">
      <f:facet name="header">#{messages.templatedetails}</f:facet>

      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplName"
      styleClass="formFont">#{messages.templatename}</h:outputLabel>
      <s:span rendered="#{required}" styleClass="required">*</s:span>


      <h:inputText id="tplName" required="true"
      value="#{templateHome.instance.tplName}"
      style=" width : 195px;" rendered="#{!templateHome.managed}"
      styleClass="formFont2"
      validator="#{applicationValidators.checkBlankSpaces}"
      requiredMessage="#{messages.validatetemplatename}">
      <f:validateLength minimum="4" maximum="20" />
      <rich:ajaxValidator event="onblur"/>

      </h:inputText>
      <h:inputText id="tplName1" required="true"
      value="#{templateHome.instance.tplName}"
      style=" width : 195px;" rendered="#{templateHome.managed}"
      disabled="true" styleClass="formFont2"
      validator="#{applicationValidators.checkBlankSpaces}">
      </h:inputText>
      <rich:message for="tplName" style="color:red;"></rich:message>



      </s:decorate>


      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplType"
      styleClass="formFont">#{messages.templatetype}</h:outputLabel>
      <s:span rendered="#{required}" styleClass="required">*</s:span>


      <h:inputText id="tplType" required="true"
      value="#{templateHome.instance.tplType}"
      style=" width : 195px;" styleClass="formFont2"
      validator="#{applicationValidators.checkBlankSpaces}"
      requiredMessage="#{messages.validatetemplatetype}">
      <f:validateLength minimum="4" maximum="100" />
      <rich:ajaxValidator event="onblur"/>
      </h:inputText>
      <rich:message for="tplType" style="color:red;"></rich:message>



      </s:decorate>


      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel
      for="language" styleClass="formFont">#{messages.language}:</h:outputLabel>
      <s:span rendered="#{required}" styleClass="required">*</s:span>

      <h:selectOneListbox id="language"
      value="#{templateHome.instance.tplLanguage}"
      style="width : 195px;" required="true" styleClass="formFont2"
      requiredMessage="#{messages.validatelanguage}">
      <rich:ajaxValidator event="onblur"/>

      <f:selectItem itemValue="en" itemLabel="English" />
      <f:selectItem itemValue="ar" itemLabel="Arabic" />

      </h:selectOneListbox>
      <rich:message for="language" style="color:red;"></rich:message>



      </s:decorate>



      <h:outputLabel style="color=blue; font-size: 12px">*While creating the template text below, dynamic tags should be defined as [:text], otherwise tags will not be considered as dynamic. </h:outputLabel>
      <h:outputLabel style="color=blue; font-size: 12px">For example: In Dear [:user], [:user] will be replaced by the user name while processing the template </h:outputLabel>



      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel
      for="template" styleClass="formFont">Select a Template:</h:outputLabel>


      <h:selectOneMenu id="template"
      value="Select a template"
      style="width : 195px;" styleClass="formFont2">
      <a4j:support event="onchange"></a4j:support>
      <f:selectItem itemValue="tplSms" itemLabel="Template SMS" />
      <f:selectItem itemValue="tplUssd" itemLabel="Template USSD" />

      </h:selectOneMenu>




      </s:decorate>


      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplSms" rendered="false"
      styleClass="formFont">#{messages.templatesms}: </h:outputLabel>


      <h:inputTextarea id="tplSms" rendered="false"
      value="#{templateHome.instance.tplSms}"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>



      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplUssd" rendered="false"
      styleClass="formFont">#{messages.templateussd}: </h:outputLabel>


      <h:inputTextarea id="tplUssd" rendered="false"
      value="#{templateHome.instance.tplUssd}"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>


      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplGprs" rendered="false"
      styleClass="formFont">#{messages.templategprs}: </h:outputLabel>


      <h:inputTextarea id="tplSms"
      value="#{templateHome.instance.tplGprs}" rendered="false"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>




      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplWap" rendered="false"
      styleClass="formFont">#{messages.templatewap}: </h:outputLabel>


      <h:inputTextarea id="tplWap"
      value="#{templateHome.instance.tplWap}" rendered="false"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>



      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplIvr" rendered="false"
      styleClass="formFont">#{messages.templateivr}: </h:outputLabel>


      <h:inputTextarea id="tplIvr"
      value="#{templateHome.instance.tplIvr}" rendered="false"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>




      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplMail" rendered="false"
      styleClass="formFont">#{messages.templatemail}: </h:outputLabel>


      <h:inputTextarea id="tplMail" rendered="false"
      value="#{templateHome.instance.tplMail}"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>



      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplWeb" rendered="false"
      styleClass="formFont">#{messages.templateweb}: </h:outputLabel>


      <h:inputTextarea id="tplWeb" rendered="false"
      value="#{templateHome.instance.tplWeb}"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>



      <s:decorate for="name" template="/layout/edit.xhtml">


      <h:outputLabel for="tplOther" rendered="false"
      styleClass="formFont">#{messages.templateother}: </h:outputLabel>


      <h:inputTextarea id="tplOther" rendered="false"
      value="#{templateHome.instance.tplOther}"
      style=" width : 190px; height: 80px;" styleClass="formFont2">

      </h:inputTextarea>


      </s:decorate>


      <rich:panel headerClass="headerFont">
      <f:facet name="header">Upload Document</f:facet>
      <h:panelGrid columns="1" cellspacing="1" width="70%"
      columnClasses="#{tableLnF.getBackgroundSettingsFull('noColor')}">

      <h:column>
      <s:fileUpload data="#{templateHome.uploadFile}" accept="application/pdf" contentType="#{templateHome.contentType}"
      fileName="#{templateHome.fileName}"/>

      </h:column>
      </h:panelGrid>

      </rich:panel>



      <h:commandButton id="save"
      value="#{messages.buttonsave}" action="#{templateHome.persist}"
      rendered="#{!templateHome.managed}" styleClass="defaultButton"
      style=""
      onclick="if (!confirm('Are you sure you want to create a new template?')) return false;">
      <s:conversationPropagation type="join" />
      </h:commandButton> <h:commandButton id="update" value="#{messages.buttonupdate}"
      action="#{templateHome.update}" rendered="#{templateHome.managed}"
      styleClass="defaultButton" style=""
      onclick="if (!confirm('Are you sure you want to update this template?')) return false;" />
      <h:commandButton id="delete" value="#{messages.buttondelete}"
      action="#{templateHome.remove}" rendered="#{templateHome.managed}"
      styleClass="defaultButton" style=""
      onclick="if (!confirm('Are you sure you want to delete this template?')) return false;" />
      <s:button propagation="end" id="done" value="#{messages.buttoncancel}"
      view="/templateList.xhtml" styleClass="defaultButton" style="" />


      </rich:panel>
      </h:form>
      </ui:define>
      </ui:composition>







      --------------------

      Thanking you