14 Replies Latest reply on Nov 7, 2008 7:24 AM by Paul Baker

    ModalPanel Example with Parameters

    Paul Baker Apprentice

      Does anyone have an example of how ModalPanel could update a field in the parent window?

      I have read the thread at:
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=111804

      I'm just learning the details of javascript and I'm unable to access my "passed parameter" or I am accessing it incorrectly.

      I assume that I need to pass the id of the field that I want to update and perhaps the form that it resides in.... An example would be great!!

      Thanks in advance.

        • 1. Re: ModalPanel Example with Parameters
          Paul Baker Apprentice

          A little more info....

          I invoke ShowModelPanel using

          <a href="javascript:Richfaces.showModalPanel('mp',{width:450, top:200}, {formid:'somevalue'})">Select Flight</a>


          ModelPanel looks like:

          <rich:modalPanel id="mp" width="400" height="420" zindex="2000" onshow="alert(event.parameters.formid);">


          The following error is generated:

          javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: /flight/flightMenu.jsp(64,1) Unable to find setter method for attribute: onshow


          I am using RichFaces 3.0.2 SnapShot.. I'm sure that it am making it much harder than it is... An example would be greatly appreciated...



          • 2. Re: ModalPanel Example with Parameters
            Ilya Shaikovsky Master

            Please check it on the 3.1.0 RC2 or latest build. Should works.

            • 3. Re: ModalPanel Example with Parameters
              Paul Baker Apprentice

              Will do...

              Does anyone have any examples that they could share where modalPanel updates a parents field?

              • 4. Re: ModalPanel Example with Parameters
                Paul Baker Apprentice

                 

                Please check it on the 3.1.0 RC2 or latest build. Should works.


                Where can I get: 3.1.0 RC2 or > ???

                • 6. Re: ModalPanel Example with Parameters
                  Paul Baker Apprentice

                  Still no examples... I tried the latest release (3.1.0 RC2) but it is not compatabile with JBoss 4.2.1 (or there is a configuation change that is not documented). See thread

                  http://www.jboss.com/index.html?module=bb&op=viewtopic&t=116924

                  Any help will be GREATLY appreciated.... :)[/url]

                  • 7. Re: ModalPanel Example with Parameters
                    Paul Baker Apprentice

                    Umm... I continue this thread by myself... :(

                    I am running 3.1.0 RC3 and still no luck passing parameters to a ModalPanel...

                    I am just trying to get the example to work... no luck so far (with any release).....

                    <a href="javascript:Richfaces.showModalPanel('mp',{width:450, top:200}, {formid:300})">Select Flight</a>


                    <rich:modalPanel id="mp" width="400" height="420" zindex="2000" onshow="alert(event.parameters.formid);">


                    The onshow dialog displays: undefined

                    I tried several combinations...

                    My objective is to display a modal window with an input text field. The user enters text and presses OK. The parent dialog is upated with the entered text. PLease help!

                    • 8. Re: ModalPanel Example with Parameters
                      Tomislav Jakopec Novice

                      I have same problem, following up this thread, waiting for solution :)

                      • 9. Re: ModalPanel Example with Parameters
                        Paul Baker Apprentice

                        Part of the problem is that the js for showModalPanel only accepts two arguments not three as shown in the examples. So, the following does work:

                        <a href="javascript:Richfaces.showModalPanel('mp',{width:450, top:200, formid:300})">Select Flight</a>


                        <rich:modalPanel id="mp" width="400" height="420" zindex="2000" onshow="alert(event.parameters.formid);">


                        I am new to RichFaces and to javaScript and I thought there would have been someone out there that has already solved my problem.. Anyway I have bought a javascript book and when I solve it, I'll post the solution... :)

                        Here is the entry for showModalPanel (note two arguments not three):

                        Richfaces.showModalPanel = function (id, opts) {
                         var panel = $(id);
                         if (!panel) {
                         panel = Richfaces.findModalPanel(id);
                         }
                         panel.modalPanel.show(opts);
                        }




                        • 10. Re: ModalPanel Example with Parameters
                          Marcelo Krebber Newbie

                          im actually using a litte bit of a different approach to pass parameters to a modal panel, using a4j:jsScript, as follows:

                          to call the scrip (notice that myparameter below is(!) relevant):

                          ...
                          <h:graphicImage value="./myimage.gif" style="cursor:pointer"
                           onclick="showMypanel('#{mybean.myparameter}')">
                          </h:graphicImage>
                          ..
                          


                          and the script itself:


                          <h:form>
                           <a4j:jsFunction name="showMyPanel"
                           reRender="id_mypanel" oncomplete="javascript:Richfaces.showModalPanel('id_mypanel')">
                           <a4j:actionparam name="myparameter" assignTo="#{mybackingBean.mycurrentparameter}" />
                           </a4j:jsFunction>
                          </h:form>
                          
                          


                          the code will first assing the current selection to the bean, so that it can be picked up by the modal panel - see the oncompletion call.

                          only problem with this however, is that it works reliably for Firefox, IE sometimes refuses to execute "javascript:Richfaces.showModalPanel" - i suspect this might be an isse with the richfaces implementation. any idea on that ?

                          i use richfaces 3.1 RC3.

                          marc

                          • 11. Re: ModalPanel Example with Parameters
                            David Spark Newbie

                            I use similar code but since upgrading to Seam2CR1 (from Seam2Beta) it no longer worked. The panel was no longer shown. I managed to solve this problem by enclosing the code for the modalPanel in <a4j:region> tags (which weren't needed for it to work previously).

                            The problem now is that the content of the panel is not correctly reRendered. My backing bean has the correct data to be shown on the panel but the panel does not show it. All I can think is that it's not actually reRendering it (or maybe it's doing the reRender before assigning the actionParam now?)

                            • 12. Re: ModalPanel Example with Parameters
                              Ilya Shaikovsky Master

                              david may be your request isn't processed normally because of another components? Only in this case region could help you.

                              • 13. Re: ModalPanel Example with Parameters
                                Ilya Shaikovsky Master

                                Marc.. what do you mean by " IE sometimes refuses to execute "javascript:Richfaces.showModalPanel" ?? What kind of errors appear?

                                • 14. Re: ModalPanel Example with Parameters
                                  Paul Baker Apprentice

                                  I have yet to be able to pass parameters to the modalPanel via Javascript. I have seen solutions in this formum where an ajax roundtrip is performed to get pass information or load fields in the modalPanel (by rerendering the modalPanel). However, that would not be an acceptable solution in a high volume environment.

                                  I am using:
                                  Richfaces 3.3.0 SNAPSHOT 2008-11-05

                                  Has anyone been able to use a pure javascript solution to pass parameters using the documented method?

                                  The documentation refers to 2+ parameters that may be passed to show a modalPanel. The first parmeter is the modalPanel "id". The second parameter is some stype attributes, and the third parameter is the dynamic values passed to the modalPanel.

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

                                  Where is the second parameter documented?

                                  How do I pass multiple parameters?

                                  Please provide examples.

                                  http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/html/modalPanel.html

                                  You can pass your parameters during modalPanel opening or closing. This passing could be performed in the following way:

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

                                  Thus, except the standard modalPanel parameters you can pass any of your own parameters.

                                  Also modalPanel allows to handle its own opening and closing events on the client side. The "onshow" and "onclose" attributes are used in this case.

                                  The following example shows how on the client side to define opening and closing event handling in such a way that your own parameters could also be obtained:

                                  Example:
                                  onshow="alert(event.parameters.param1)"

                                  Here, during modalPanel opening the value of a passing parameter is output.


                                  btw - I want to thank all of the developers of Richfaces for making a fantastic extension to JSF!!!!