4 Replies Latest reply on Nov 25, 2008 6:18 PM by Val Sw

    pls help - click "Save" in model panel, parent form fields b

    Val Sw Expert

      Parent window have some form fields, I am able to open a model panel from parent form…

      a) When I click "Save" in model panel, parent form fields becomes null...

      b) My purpose is to allow user to fill some filed (like panelText1) in model panel and on clicking Save I can show the value entered in model panel in the parent form (s:label id="valueFromModelPanel"....)
      Please help what can be trick....

      <h:form id="project" styleClass="edit">
      <h:inputText id="projectCode" required="true" value="#{projectHome.instance.projectCode}"/>
      <h:inputText id="projectName" required="true" value="#{projectHome.instance.projectName}"/>

      ... other fields

      <s:label id="valueFromModelPanel" value="#{xxxxHome.instance.value}"/>

      <h:outputLink value="#" id="link">
      Show Modal Panel
      <rich:componentControl for="panel" attachTo="link" operation="show" event="onclick"/>
      </h:outputLink>
      <h:form>

      <rich:modalPanel id="panel" width="350" height="100">
      <f:facet name="header">
      <h:panelGroup>
      <h:outputText value="Modal Panel"></h:outputText>
      </h:panelGroup>
      </f:facet>
      <h:outputText value="This panel is called using Component Control Component"></h:outputText>

      <h:panelGroup>
      <h:form>
      <h:inputText id="panelText1" required="true" value="#{xxxxHome.instance.value}"/>
      <s:link value="Save" style="cursor:pointer" id="hidelink"/>
      <rich:componentControl for="panel" attachTo="hidelink" operation="hide" event="onclick"/>
      </h:form>
      </h:panelGroup>
      </rich:modalPanel>

        • 1. Re: pls help - click
          Ilya Shaikovsky Master

           

           <h:form>
           <h:outputText value="#{userBean.name}" id="update"/>
           <h:outputLink value="#" id="link">
           Show Modal Panel
           <rich:componentControl for="panel" attachTo="link" operation="show"
           event="onclick" />
           </h:outputLink>
           </h:form>
          
           <rich:modalPanel id="panel" width="350" height="100">
           <f:facet name="header">
           <h:panelGroup>
           <h:outputText value="Modal Panel"></h:outputText>
           </h:panelGroup>
           </f:facet>
           <h:outputText
           value="This panel is called using Component Control Component"></h:outputText>
          
           <h:panelGroup>
           <h:form>
           <h:inputText id="panelText1" required="true"
           value="#{userBean.name}" />
           <a4j:commandLink value="Save" style="cursor:pointer" id="hidelink" reRender="update" oncomplete="#{rich:component('panel')}.hide();"/>
           </h:form>
           </h:panelGroup>
           </rich:modalPanel>
          


          works fine for me.

          • 2. Re: pls help - click
            Val Sw Expert

            Thanks for the reply... I am facing small issue while including modal code to main xhtml.

            When I include TestPop.xhtml (which contains modal code) in Main xhtml, it shows the menu bar & footer because of "template="layout/template.xhtml"" (thus menu & header is displayed twice in main page).

            If I try to remove template from TestPop.xhtml nothing happens on clicking modal link from main page.

            Please suggest how can we handle this....

            Main xhtml
            ----------
            <!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:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich"
            template="layout/template.xhtml">

            <ui:define name="body">

            <h:form>
            <h:outputText value="test" id="update"/>
            <h:outputLink value="#" id="link">
            Show Modal Panel
            <rich:componentControl for="panel" attachTo="link" operation="show"
            event="onclick" />
            </h:outputLink>
            </h:form>
            <ui:include src="/TestPop.xhtml"/>
            </ui:define>
            </ui:composition>


            TestPop.xhtml
            -------------
            <!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:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich"
            template="layout/template.xhtml">

            <ui:define name="body">
            <rich:modalPanel id="panel" width="350" height="100">
            <f:facet name="header">
            <h:panelGroup>
            <h:outputText value="Modal Panel"></h:outputText>
            </h:panelGroup>
            </f:facet>
            <h:outputText
            value="This panel is called using Component Control Component"></h:outputText>

            <h:panelGroup>
            <h:form>
            <h:inputText id="panelText1" required="true"
            value="Vishal" />
            <a4j:commandLink value="Save" style="cursor:pointer" id="hidelink" reRender="update" oncomplete="#{rich:component('panel')}.hide();"/>
            </h:form>
            </h:panelGroup>
            </rich:modalPanel>
            </ui:define>
            </ui:composition>

            • 3. Re: pls help - click
              Ilya Shaikovsky Master

              in order to remove template attribute from included ui:composition succsessfully - please remove also ui:define tags there.

              • 4. Re: pls help - click
                Val Sw Expert

                Thanks for replying Ilya...

                I have a query, how can we pass parameter from main.xhtml to modal panel which is new xhtml...

                s:button below works fine param values are passed, I am stuck in passing when I try to open modal panel...

                pls help.

                <h:form>
                <h:outputLink value="#" id="link">Add treatment
                <rich:componentControl for="panel" attachTo="link" operation="show"
                event="onclick"/>
                <f:param name="reagentHjid"
                value="#{info.hjid}"/>
                <f:param name="treatmentFrom" value="Reagent"/>
                </h:outputLink>

                <s:button
                value="Add treatment"
                view="/TreatmentEdit.xhtml">
                <f:param name="reagentHjid"
                value="#{info.hjid}"/>
                <f:param name="treatmentFrom" value="Reagent"/>
                </s:button>
                </h:form>

                <ui:include src="/TreatmentEdit.xhtml"/>