9 Replies Latest reply on Jul 11, 2008 5:35 PM by mores

    Parameters and a ModalPanel

    paulaunderwood

      I am passng a parameter to my modal panel called name.. I know it is passing it correctly because it shows up if i do this...

      <rich:modalPanel id="mp" minHeight="75" minWidth="150"
       height="75" width="150" zindex="2000" onshow="alert(event.parameters.name);">
      


      I need to be able to display it as output text on the panel itself, how do I do that?

      Thanks in advance,
      Paula

        • 1. Re: Parameters and a ModalPanel
          pankaj.ghosh

          Has somebody cracked this issue???

          Thanks
          Pankaj

          • 2. Re: Parameters and a ModalPanel
            panky_p

            Hi,
            I am also facing the same problem, actualy I want to pass Id on which it will edit that parameter and return it to parent form.
            I have post for the same issue but no reply from forum.
            have you got the solution???
            If yes please let me know.


            Thanks!!

            • 3. Re: Parameters and a ModalPanel
              panky_p

              After adding onshow alert is also not working for me :-(

              how you got alert??

              please do reply

              Thanks[/img]

              • 4. Re: Parameters and a ModalPanel
                pankaj.ghosh

                Hi,

                Showing the value through alert did work for me.

                This call while showing modal panel

                Richfaces.showModalPanel('panelId', {left: auto}, {param1: value1});
                


                And this code in modal panel:
                <rich:modalPanel id="panelId" height="100" width="200" onshow="alert(event.parameters.param1)">
                .......
                </rich:modalPanel>
                
                will show alert with that value.
                
                
                For actually using the parameter in modal panel, I used a work around.
                In modal panel, I use a bean to display the values. From the a4j command button, first i call a backing bean action, set the value in the bean, reRender the modal panel contents(which uses the bean contents), and then on 'oncomplete' show the modal panel.
                Basically I am not passing any parameters to modal panel.
                
                This is the code:
                

                <rich:modalPanel id="mpCheckIn" minHeight="200" minWidth="450" height="200" width="500" resizeable="true">
                <a4j:outputPanel id="modalCheckInPanel" layout="inline">
                .....use bean here.....
                </a4j:outputPanel>
                </rich:modalPanel>

                and

                <a4j:commandButton id="editDocBtn"
                value="Edit" reRender="modalCheckInPanel"
                complete="javascript:Richfaces.showModalPanel('mpCheckIn')"
                action="....call bean and set properties in bean here....">
                </a4j:commandButton>


                
                
                If you need more help, you can mail me.
                I have spent enough days breaking my head on this. :-)


                • 5. Re: Parameters and a ModalPanel
                  pankaj.ghosh

                  Apologize for bad formatting.
                  Cant undo it. :-(

                  • 6. Re: Parameters and a ModalPanel
                    marc1

                    hallo, here is some sample code for passing parameters to a modal panel. this solution basically uses ajax for updating the values for the modal panel using <a4j:jsFunction>.


                    First, assume u have some button that when pressed will collect some information from the client, perhaps using javascript, pluas some other data, and pass that to the modal panel - this will happen on the "onclick" event.

                    <a4j:commandButton id="id_save" value="Apply"
                     onclick="javascript:myFunction('#{mybean.somedata}', getClientContent());" />
                    


                    next, we define the javascript function, which first passes the parameter data to the server, and "oncomplete" opens the modal panel. Two more things here - one, the name of the parameters on the client side is irrevelant and two, you may need to reRender the body (a panel maybe) of the modalpanel to pick changes dynamically:

                    <h:form>
                     <a4j:jsFunction name="myFunction" reRender="id_modalpanel_body" oncomplete="Richfaces.showModalPanel('id_mymodal_panel')">
                     <a4j:actionparam name="data" assignTo="#{anotherbean.parameterdata1}" />
                     <a4j:actionparam name="data1" assignTo="#{anotherbean.parameterdata2}" />
                     </a4j:jsFunction>
                    </h:form>
                    
                    
                    .... your modal panel here ....
                    


                    notice the <a4j:actionparam>'s will be executed first, the panel will be shown and its content updated thru the rerender.


                    that's it.

                    marcelo

                    • 7. Re: Parameters and a ModalPanel
                      panky_p

                      Hi,
                      Pankaj as you told I did try but I am not getting it done properly,
                      how can i check whether "onshow" is working or not?
                      actually I wat to pass Id of selected item to modalPanel but not getting it proper.

                      <a4j:commandButton value="Add" oncomplete="javascript:Richfaces.showModalPanel('addPanel',{width:820, top:'50px', left:'50px'},{param1: '#{itemList.itemId}'})"/>

                      and in modalPanel
                      <rich:modalPanel id="addPanel" minHeight="200" minWidth="250" zindex="2000" onshow="alert(event.parameters.param1)">

                      but i am not getting it!!

                      Thanks For Reply!!
                      Panky


                      • 8. Re: Parameters and a ModalPanel
                        pankaj.ghosh

                        Hey.....

                        From the code, it seems that the error is somewhere else. Maybe you are putting the modal panel in the wrong place. dunno....

                        Can you tell me, from the code that u gave, does it render the modal panel and does the alert show?? If yes, does alert show null value?
                        Try to remove the modal width and height parameters and try again.

                        And please paste your full webpage code.

                        Thanks
                        Pankaj

                        • 9. Re: Parameters and a ModalPanel
                          mores

                          How can this be done in java code ?

                          I have tried the following, but it is not working:

                          javax.faces.component.html.HtmlOutputLink link = new javax.faces.component.html.HtmlOutputLink();
                          link.setId( "add_comment_link" );
                          javax.faces.component.html.HtmlOutputText title = new javax.faces.component.html.HtmlOutputText();
                          title.setId( "add_comment_title" );
                          link.setValue( "#" );
                          title.setValue( "Add a comment" );
                          link.getChildren().add( title );
                          
                          org.richfaces.component.html.HtmlComponentControl cc = new org.richfaces.component.html.HtmlComponentControl();
                          cc.setId( "comment_control" );
                          cc.setFor( "simplePanel" );
                          cc.setAttachTo( "add_comment_title" );
                          cc.setOperation( "show" );
                          cc.setEvent( "onclick" );
                          link.getChildren().add( cc );
                          
                          javax.faces.component.UIParameter param = new javax.faces.component.UIParameter();
                          param.setName( "title" );
                          param.setValue( "My Title" );
                          link.getChildren().add( param );