1 2 Previous Next 17 Replies Latest reply on Jul 23, 2007 5:47 PM by explorer

    Multiple instance of same portlet on same page

    kumarkn

      hi,

      I am facing some problems with Multiple instance of same portlet on same page. I am creating a simple portlet which will be redirected to a JSP page having some input fields and having some buttons. Based on the user login I am enabling/disabling the buttons using javascript.(document.formName.buttonName.disabled = true)
      I created multiple instances of same portlet in the Dashboard.

      I found that for one instance the buttons are disabled/enabled as per the logic but for the second instance its throwing java script error as (document.formName.buttonName is null or not an object) the two instances(JSP) has the same FORM name in a single page. Is that I have to include some portlet tags in jsp to avoid this behavior.

      Thanks in advance.

        • 1. Re: Multiple instance of same portlet on same page
          theute

          Use a different namespace for your HTML elements.

          See the portlet spec.

          • 2. Re: Multiple instance of same portlet on same page
            kumarkn

            Added to the above query.

            Tried to fix the issue by looping through all the forms in the document and get the correct form name and apply the logic. It is working until i submit the form, once submitted the logic goes off. This issue is not happening always, its happening for frequent form submission.

            Thanks.

            • 3. Re: Multiple instance of same portlet on same page
              brownfielda

              Hadn't ever thought about this problem.

              Digging through the portlet spec (as per Thomas' recommendation) found the solution in PLT 22.4.

              • 4. Re: Multiple instance of same portlet on same page
                kumarkn

                Thanks for your reply.

                I can able to fix the issue by giving the namespace tag. But i have few other problems with mulitple instance of same portlet on same page. I am invoking the javascript before the body tag

                alert("Test");


                ...


                On submit of this form again i am redirecting to the same JSP page in the portlets doView method but I am not getting the alert message on the submission of the form. When i do a refresh i am getting the alert. For random Submission the entire page is refreshed automatically and i am getting the alert.

                Kindly help me to fix this issue.

                • 5. Re: Multiple instance of same portlet on same page
                  kumarkn

                  Thanks for your reply.

                  I can able to fix the issue by giving the namespace tag. But i have few other problems with mulitple instance of same portlet on same page. I am invoking the javascript before the body tag

                  <script language="JavaScript" >
                   alert("Test");
                  </script>
                  <body>
                  ...
                  </body>
                  

                  On submit of this form again i am redirecting to the same JSP page in the portlets doView method but I am not getting the alert message on the submission of the form. When i do a refresh i am getting the alert. For random Submission the entire page is refreshed automatically and i am getting the alert.

                  Kindly help me to fix this issue.

                  • 6. Re: Multiple instance of same portlet on same page
                    soshah

                    Try this and see if its still random

                    <script language="JavaScript" >
                     function callOnLoad()
                     {
                     alert("Test");
                     }
                    </script>
                    <body onload="javascript:callOnLoad();">
                    ...
                    </body>
                    


                    Basically making the code execute using DOM events.

                    Thanks

                    • 7. Re: Multiple instance of same portlet on same page
                      kumarkn

                      Tried with the Onload event but still its not working.

                      • 8. Re: Multiple instance of same portlet on same page
                        soshah

                        Are you by any chance using the "Partial Refresh" feature of the Portal?

                        Reason I say that is with "Partial Refresh" only portions of your page a loaded and the Page is not fully refreshed.


                        If you page is being fully refreshed, the onload event on your body should be getting called

                        Thanks

                        • 9. Re: Multiple instance of same portlet on same page
                          kumarkn

                          No i am not using the partial refresh feature.
                          No one more thing is that the link tag for styles is also not working similar to the javascript.

                          • 10. Re: Multiple instance of same portlet on same page
                            soshah

                            And this onload javascript works just fine when only one instance of the portlet is placed on the page?

                            At this point you may have to do some javascript debugging on your browser.

                            The part is actually completely independent of what the portlets are doing on the page. The Portlets are just aggregated markup on the Page, so the

                            javascript should be like any other web application

                            Thanks

                            • 11. Re: Multiple instance of same portlet on same page
                              kumarkn

                              I did the following for the partial refresh

                              Log in as admin and added the Partial refresh property for that page but disabled the partial refresh by unchecking it.Then log in as the user and copied that particular page to my dashboard. Now everything is working fine. The problem is with the partial refresh, i have not enabled the feature but by default it is enabled so i disabled it as i mentioned. Is that the javascript and the link tags to style wont work for partial refresh(Multiple instance of same portlet on same page)?

                              Thank you very much for your kind help.

                              • 12. Re: Multiple instance of same portlet on same page
                                soshah

                                I don't think the onload javascript execution issue has anything to do with the fact you have instances of the same portlet on the same page.

                                This issue is more related to the way AJAX based Partial refresh works, and when that happens, only your pages DOM model is getting updated, but the actual Page is not getting refreshed (typical AJAX usecase).

                                Hence, the Page is not doing a complete refresh, the onLoad event is not fired, and your JavaScript is not executed.

                                I bet if you put the

                                <Script language="JavaScript">
                                 alert('Test');
                                </Script>
                                


                                inside your Portlet markup, they will probably work even in "Partial Refresh" mode

                                Thanks

                                • 13. Re: Multiple instance of same portlet on same page
                                  brownfielda

                                  Possibly related: The portlet spec says something about disallowed HTML tags. I believe head and body were among them.

                                  Is this relevant when using JSP?

                                  Maybe dispatcher.include("myJSP.jsp") parses those tags out when returning control to the portlet.

                                  • 14. Re: Multiple instance of same portlet on same page
                                    theute

                                    Well at the end there is a unique HTML page with a unique html, head and body tags. So in your portlet you mustn't produce those tags.

                                    1 2 Previous Next