0 Replies Latest reply on Oct 22, 2008 5:52 AM by gopibalagala.bgopimca.gmail.com

    Select one menu

    gopibalagala.bgopimca.gmail.com
      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.
      .

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

      <!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">
      <!--
      <script type="text/javascript">
             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';
               }
             }
         </script> -->
        
                <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">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplName"
                                                   styleClass="formFont">#{messages.templatename}</h:outputLabel>
                                              <s:span rendered="#{required}" styleClass="required">*</s:span>

                                              </td>
                                              <td><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>
                                              </td>
                                         </tr>
                                    </table>
                               </s:decorate>
                               <div style="clear: both" />

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplType"
                                                   styleClass="formFont">#{messages.templatetype}</h:outputLabel>
                                              <s:span rendered="#{required}" styleClass="required">*</s:span>

                                              </td>
                                              <td><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>
                                              </td>
                                         </tr>
                                    </table>
                               </s:decorate>
                               <div style="clear: both" />

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><b><h:outputLabel
                                                   for="language" styleClass="formFont">#{messages.language}:</h:outputLabel></b>
                                              <s:span rendered="#{required}" styleClass="required">*</s:span>
                                              </td>
                                              <td><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>
                                              </td>
                                         </tr>
                                    </table>
                               </s:decorate>
                               <div style="clear: both" />


                               <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>
                               <div style="clear: both" />
                        
                        
                         <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><b><h:outputLabel
                                                   for="template" styleClass="formFont">Select a Template:</h:outputLabel></b>
                                              
                                              </td>
                                              <td><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>
                                              
                                              </td>
                                         </tr>
                                    </table>
                               </s:decorate>
                               <div style="clear: both" />
                       
                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplSms" rendered="false" 
                                                   styleClass="formFont">#{messages.templatesms}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />

                               

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplUssd" rendered="false"
                                                   styleClass="formFont">#{messages.templateussd}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />
                               

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplGprs" rendered="false"
                                                   styleClass="formFont">#{messages.templategprs}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />

                               


                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplWap" rendered="false"
                                                   styleClass="formFont">#{messages.templatewap}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />

                               

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplIvr" rendered="false"
                                                   styleClass="formFont">#{messages.templateivr}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />

                               


                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplMail" rendered="false"
                                                   styleClass="formFont">#{messages.templatemail}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />

                               

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplWeb" rendered="false"
                                                   styleClass="formFont">#{messages.templateweb}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate>     <div style="clear: both" />

                          

                               <s:decorate for="name" template="/layout/edit.xhtml">
                                    <table width="700px">
                                         <tr>
                                              <td align="left" width="25%"><h:outputLabel for="tplOther" rendered="false"
                                                   styleClass="formFont">#{messages.templateother}: </h:outputLabel>

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

                                              </h:inputTextarea></td>
                                         </tr>
                                    </table>
                               </s:decorate><div style="clear: both" />

                               
           <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>


                       <div class="actionButtons">
                               <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="" /></div>


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


      Thanking you