2 Replies Latest reply on May 12, 2009 2:04 PM by jyothi.a_jyothisree.yahoo.co.in

    rendered attribute in modalpanel

    vasavi
      Hi, i have tried to edit the records of a list page in the list page itself using modalpanel. And i have succeeded in editing the records. But when i want to create a new record, it must display only save and cancel buttons. And when i edit the record, it should display update and cancel buttons.

      I have tried this with the rendered attribute. but i could not able to get it. Can anybody help me in doing this.

      My code is:

      <!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"
          xmlns:a4j="http://richfaces.org/a4j"
          template="../layout/template.xhtml">

      <ui:define name="body">

           <h:form id="deployedLocation" styleClass="edit">
              <a4j:region>
                          <rich:extendedDataTable id="makeListTable" var="_make" rows="4"
                               selectionMode="single" height="190px"
                              value="#{makes}"
                           rendered="#{makes.rowCount > 0}">
                                                     
                               <rich:column id="makeCode" width="140px" sortable="true"
                                    sortBy="#{_make.makeCode}"
                                    filterBy="#{_make.makeCode}"
                                    filterEvent="onkeyup" label="Make Code">
                                  <f:facet name="header">
                                       <h:outputText styleClass="headerText" value="Make Code"/>
                                  </f:facet>
                                    <h:outputText value="#{_make.makeCode}"/>
                               </rich:column>
                               
                               
                            <rich:column id="description" width="140px" sortable="true"
                                    sortBy="#{_make.description}"
                                    filterBy="#{_make.description}"
                                    filterEvent="onkeyup" label="Description">
                                  <f:facet name="header">
                                       <h:outputText styleClass="headerText" value="Description"/>
                                  </f:facet>
                                    <h:outputText value="#{_make.description}"/>
                               </rich:column>
                               
                               <rich:column id="FActive" width="100px" sortable="true"
                                    sortBy="#{_make.FActive}" label="Active">
                                  <f:facet name="header">
                                       <h:outputText styleClass="headerText" value="Active"/>
                                  </f:facet>
                                    <h:outputText value="#{_make.FActive}"/>
                               </rich:column>
                               
                               <rich:column>
                      <f:facet name="header">
                              Actions
                      </f:facet>
                      <a4j:commandLink ajaxSingle="true" id="editlink" action="#{makeAction.selectMake}"
                          oncomplete="#{rich:component('editPanel')}.show()">
                          <h:graphicImage value="/img/ico_edit.gif" style="border:0"/>
                          <f:param name="param" value="#{_make.makeId}"></f:param>
                      </a4j:commandLink>
                      <rich:toolTip for="editlink" value="Edit"/>
                      <a4j:commandLink ajaxSingle="true" id="deletelink" action="#{makeAction.selectMake}"
                          oncomplete="#{rich:component('deletePanel')}.show()">
                          <h:graphicImage value="/img/ico_delete.gif" style="border:0"/>
                          <f:param name="param" value="#{_make.makeId}"></f:param>
                      </a4j:commandLink>
                          <rich:toolTip for="deletelink" value="Delete"/>
                  </rich:column>
                               
                          <f:facet name="footer">
                      <rich:datascroller renderIfSinglePage="true" maxPages="5"/>
                  </f:facet>
             </rich:extendedDataTable>
              </a4j:region>          
                    <a4j:commandLink ajaxSingle="true" id="newlink" action="#{makeAction.addMake}"
                          oncomplete="#{rich:component('editPanel')}.show()">
                          <h:graphicImage value="/img/ico_new.gif" style="border:0" length="30" width="30"/>
                         
                 </a4j:commandLink>
                          
                          
                     </h:form>
                     
                     <rich:modalPanel id="editPanel" autosized="true" width="450">
              <f:facet name="header">
                  <h:outputText value="Edit Current Make" />
              </f:facet>
              <f:facet name="controls">
                  <h:panelGroup>
                      <h:graphicImage value="/img/ico_close.gif"
                          id="hidelink" styleClass="hidelink"/>
                      <rich:componentControl for="editPanel" attachTo="hidelink"
                          operation="hide" event="onclick" />
                  </h:panelGroup>
              </f:facet>
              <h:form>
                  <rich:messages style="color:red;"></rich:messages>
                  <h:panelGrid columns="1">
                  <a4j:outputPanel ajaxRendered="true">
                      <h:panelGrid columns="1">
                          <s:decorate id="makeCode" template="../layout/edit.xhtml">
                  <ui:define name="label">Make Code</ui:define>
                  <h:inputText value="#{make.makeCode}"/>
              </s:decorate>

              <s:decorate id="description" template="../layout/edit.xhtml">
                  <ui:define name="label">Description</ui:define>
                  <h:inputText value="#{make.description}"/>
              </s:decorate>

              <s:decorate id="FActive" template="../layout/edit.xhtml">
                  <ui:define name="label">F Active</ui:define>
                   <h:inputText value="#{make.FActive}"/>
              </s:decorate>
             
                      </h:panelGrid>
                      <rich:message showSummary="true" showDetail="false" for="price"/>
                     
                  </a4j:outputPanel>
                  </h:panelGrid>
                  <a4j:commandButton value="Update"
                      action="#{makeAction.update}"
                      oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" rendered="#{makeAction.managed}"/>
                  <a4j:commandButton value="Save"
                      action="#{makeAction.persist}"
                      oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" disabled="#{!makeAction.wired}" rendered="#{makeAction.managed}"/>
                  <a4j:commandButton value="CANCEL"
                      oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />   
              </h:form>
          </rich:modalPanel>
          <rich:modalPanel id="deletePanel" autosized="true" width="200">
              <f:facet name="header">
                  <h:outputText value="Delete this make from list?"
                      style="padding-right:15px;" />
              </f:facet>
              <f:facet name="controls">
                  <h:panelGroup>
                      <h:graphicImage value="/img/ico_close.gif"
                          styleClass="hidelink" id="hidelink2" />
                      <rich:componentControl for="deletePanel" attachTo="hidelink2"
                          operation="hide" event="onclick" />
                  </h:panelGroup>
              </f:facet>
              <h:form>
                  <table width="100%">
                      <tbody>
                          <tr>
                              <td align="center" width="50%">
                      <a4j:commandButton value="Yes" ajaxSingle="true"
                          action="#{makeAction.remove}"
                          oncomplete="#{rich:component('deletePanel')}.hide();"
                          reRender="locationListTable" />
                              </td>
                              <td align="center" width="50%">
                      <a4j:commandButton value="Cancel"
                          onclick="#{rich:component('deletePanel')}.hide();return false;" />
                              </td>
                          </tr>
                      </tbody>
                  </table>
              </h:form>
          </rich:modalPanel>
          <a4j:status onstart="#{rich:component('wait')}.show()" onstop="#{rich:component('wait')}.hide()"/>
          <rich:modalPanel id="wait" autosized="true" width="200" height="120" moveable="false" resizeable="false">
              <f:facet name="header">
                  <h:outputText value="Processing"/>
              </f:facet>
              <h:outputText value="Wait Please..."/>
          </rich:modalPanel>
          <rich:messages></rich:messages>
               
      </ui:define>

      </ui:composition>




      Thanks in advance...