1 Reply Latest reply on May 21, 2009 12:21 PM by gopi balagala

    Rendring with Hash Map

    gopi balagala Newbie
      Hi,

                  i have a scenario where i have four fields say dbversion, driver,db name,url.
      here when select version which is a drop down i should populate the values into the fields
      based on version which i should get from database.

      here the problem is once i had populated the values into the fields, when i am editing that
      filds am able to edit,but , again when i select a version from the dbversion field am not
      able to populate the values corresponding to that version from database into these fields,

      but if i dont edit any of the fields am able to populate the values based on value selected
      from the dropdown (db version field)


      ---------------------------------
      below the code:
      --------------------------------


      Xhtml
      ---------------------------------

      <s:span
                                                   rendered="#{doMobeeDatabase.use_datasource_ref eq 'UseDatabaseDriver'}">
                                                   <h:panelGrid id="versionGrid" columns="1" cellspacing="2"
                                                        width="100%" cellpadding="0" columnClasses="columnFull">
                                                        <s:decorate for="dbVersion" template="/layout/edit.xhtml">
                                                             <ui:define name="label">
                                                                  <h:outputText for="dbVersion" styleClass="formFont">#{messages.epdbversion}</h:outputText>
                                                             </ui:define>

                                                              <h:selectOneMenu id="dbVersion" required="true"  immediate="true"
                                                                  requiredMessage="#{messages.validatedbversion}"
                                                                  value="#{doMobeeDatabase.db_version}" style="width : 195px;"
                                                                  styleClass="formFont2">
                                                                  <f:selectItem itemLabel="--------Select a Version--------" itemValue="" />
                                                                  <f:selectItems value="#{dbendPointHome.getDbList()}" />
                                                                  <a:support event="onchange" ajaxSingle="true"
                                                                       action="#{dbendPointHome.dataBaseDetailsMap()}"
                                                                       reRender="drivername1Grid,epdbNameGrid,urlGrid">
                                                                  </a:support>
                                                             </h:selectOneMenu>   
                                                        </s:decorate>
                                                   </h:panelGrid>

                                                   <h:panelGrid id="drivername1Grid" columns="1" cellspacing="2"
                                                        width="100%" cellpadding="0" columnClasses="columnFull">
                                                        <s:decorate for="drivername1" template="/layout/edit.xhtml">
                                                             <ui:define name="label">
                                                                  <h:outputText for="drivername1" styleClass="formFont">#{messages.databasedrivername}</h:outputText>
                                                             </ui:define>
                                                             <h:inputText id="drivername1" required="true" disabled="true"
                                                                  requiredMessage="#{messages.validatedrivername}"
                                                                  value="#{doMobeeDatabase.db_driver_name}"
                                                                  style="width : 195px;" styleClass="formFont3"></h:inputText>

                                                        </s:decorate>
                                                   </h:panelGrid>


                                                   <h:panelGrid id="epdbNameGrid" columns="1" cellspacing="2"
                                                        width="100%" cellpadding="0" columnClasses="columnFull">
                                                        <s:decorate for="epdbName" template="/layout/edit.xhtml">
                                                             <ui:define name="label">
                                                                  <h:outputText for="epdbName" styleClass="formFont">#{messages.epdbname}</h:outputText>
                                                             </ui:define>


                                                             <h:inputText id="epdbName" value="#{doMobeeDatabase.db_name}" 
                                                                  required="true" maxlength="50"  
                                                                  requiredMessage="#{messages.validatedbname}"
                                                                  style=" width : 195px;" styleClass="formFont2">
                                                             </h:inputText>
                                                        </s:decorate>
                                                   </h:panelGrid>

                                                   <h:panelGrid id="urlGrid" columns="1" cellspacing="2"
                                                        width="100%" cellpadding="0" columnClasses="columnFull">
                                                        <s:decorate for="url" template="/layout/edit.xhtml">
                                                             <ui:define name="label">
                                                                  <h:outputText for="url" styleClass="formFont">#{messages.url}</h:outputText>
                                                             </ui:define>
                                                                  
                                                           <h:inputTextarea id="url" value="#{doMobeeDatabase.db_url}"
                                                                  required="true" requiredMessage="#{messages.vaildateurl}"
                                                                  style=" height:30px; width : 195px;" styleClass="formFont2" >
                                                             <f:validateLength  maximum="255"/>
                                                             </h:inputTextarea>
                                                             
                                                        </s:decorate>
                                                   </h:panelGrid>
                                                   <h:panelGrid columns="1" cellspacing="2" width="100%"
                                                        cellpadding="0" columnClasses="columnFull">
                                                        <s:decorate for="epuser1" template="/layout/edit.xhtml">
                                                             <ui:define name="label">
                                                                  <h:outputText for="epuser1" styleClass="formFont">#{messages.username}</h:outputText>
                                                             </ui:define>
                                                             <h:inputText id="epuser1"
                                                                  value="#{doMobeeDatabase.db_username}" required="true"
                                                                  requiredMessage="#{messages.validateusername}"
                                                                  maxlength="50" style=" width : 195px;"
                                                                  styleClass="formFont2">
                                                             </h:inputText>
                                                        </s:decorate>
                                                   </h:panelGrid>

                                                   <h:panelGrid columns="1" cellspacing="2" width="100%"
                                                        cellpadding="0" columnClasses="columnFull">
                                                        <s:decorate for="eppassword1" template="/layout/edit.xhtml">
                                                             <ui:define name="label">
                                                                  <h:outputText for="eppassword1" styleClass="formFont">#{messages.password}</h:outputText>
                                                             </ui:define>

                                                             <h:inputSecret id="eppassword1" required="true" redisplay="true"
                                                                  requiredMessage="#{messages.validatepassword}"
                                                                  value="#{doMobeeDatabase.db_password}" maxlength="20"
                                                                  style=" width : 195px;" styleClass="formFont2">
                                                             </h:inputSecret>
                                                        </s:decorate>
                                                   </h:panelGrid>

                                              </s:span>
                                         </s:span>

                                         <h:panelGrid columns="1" cellspacing="2" width="100%"
                                              cellpadding="0" columnClasses="columnFull">
                                              <s:decorate for="epdbTable" template="/layout/edit.xhtml">
                                                   <ui:define name="label">
                                                        <h:outputText for="epdbTable" styleClass="formFont">#{messages.epdbtable}</h:outputText>
                                                   </ui:define>

                                                   <h:inputText id="epdbTable" value="#{doMobeeDatabase.db_table}"
                                                        maxlength="50" required="true"
                                                        requiredMessage="#{messages.validatetablename}"
                                                        style=" width : 195px;" styleClass="formFont2">
                                                   </h:inputText>
                                              </s:decorate>
                                         </h:panelGrid>

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

      DbAction Class:
      ---------------------

      @Begin(join=true)
           public String dataBaseDetailsMap() {

                
                log.info("VALUE:"+doMobeeDatabase.getDb_version());
                if ((doMobeeDatabase.getDb_version() != null)) {
                     MobeeDb db = dbHashMap.get(doMobeeDatabase.getDb_version());

                     
                     
                     log.info("DB:"+db);
                     log.info("Driver name:" +db.getDriverName());
                     log.info("URL name:" +db.getDataBaseUrl());
                     log.info("DB name:" +db.getDbName());
                     
                     doMobeeDatabase.setDb_driver_name(db.getDriverName());
                     doMobeeDatabase.setDb_url(db.getDataBaseUrl());
                     doMobeeDatabase.setDb_name(db.getDbName());

                     log.info("driver name"+doMobeeDatabase.getDb_driver_name());
                     
                     log.info("DataBase NAME"+doMobeeDatabase.getDb_url());
                     log.info("URL"+doMobeeDatabase.getDb_name());

                } /*else{
                     log.info("else....");
                     doMobeeDatabase.setDb_driver_name(null);
                     doMobeeDatabase.setDb_url(null);
                     doMobeeDatabase.setDb_name(null);
                     
                     
                } */

                return "";

           }


      ---------