1 2 Previous Next 15 Replies Latest reply on Jun 5, 2006 5:19 PM by craig1980

    Passing request paramter between page

    craig1980

      Hi all. I have this problem. I have a page where there a list of items; i want to read a detail of one of these items. In order to this thing i have created a new portal page; let's call it itemDetail; i have written the link in my jsp page in this way:

      <a href="itemDetail?itemId=12"> Vedi dettaglio </a>
      


      In my portelt class code i have done, in doDispatch method, this thing:

      public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException {
      
      
      }
      


        • 1. Re: Passing request paramter between page
          craig1980

          I'm sorry i have pushed the submit button....
          Hi all. I have this problem. I have a page where there a list of items; i want to read a detail of one of these items. In order to this thing i have created a new portal page; let's call it itemDetail; i have written the link in my jsp page in this way:

          <a href="itemDetail?itemId=12"> Vedi dettaglio </a>
          



          In my portlet class code i have done, in doDispatch method, this thing:

          public void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException {
          
           String itemId = request.getParameter("itemId");
          log.debug("Searching this item id: "+itemId);
          }
          

          But the item id is null.... how can i solve thi problem?
          Where am i wrong?
          My environment is this one:
          JVM 1.4.2
          JBoss AS: 4.0.3SP1
          JBoss Portal 2.2.1

          Thanks to all



          • 2. Re: Passing request paramter between page

            Read the spec and see how renderParameters are passed from jsps to portlets.

            • 3. Re: Passing request paramter between page
              craig1980

              Hi.
              First of all i thank you for your reply.
              By saiyng "see the spec" do you refer to JBossPortalreferenceGuide.pdf in section InterportletCommunication?
              Thanks.

              • 4. Re: Passing request paramter between page
                • 5. Re: Passing request paramter between page
                  craig1980

                  Hi all.
                  I really am not able to understand how this is possible.
                  Let's image that i have page where there is a portlet that shows a list of objects.
                  Let's image that this page is in a three columns layout. Well i want to see the detail of one of this item in a two column layout; the first and the most normal thing i could do is the put an <a href to the page by passing a request parameter that says the item id i want to see. In this page i have a portlet that in the doView or processAction method tries to get this request parameter. But this parameter is no longer available. I have read the portlet spec 1.0; in the section "passing parameter toJSP and servlet" is indicated the ReqestDispatcher class....well i have tried also by using this class but nothing to...i'm not able to pass a request parameter from a portlet in page to another portlet to page B....is this thing against the spec or am i wrong anything?
                  In the second case.... can anybody show me a very little sample?
                  Thanks to all.
                  Angelo

                  • 6. Re: Passing request parameter between pages
                    ivanlatysh

                    You see, you should accept that each portlet is a separate application.
                    In your case, if I understood your question correctly, you went the wrong way.
                    You should not write a separate portlet to display the details, your portlet should render different view based on your selection.

                    Here is a simple example:
                    You have list of names from address book:
                    * John
                    * Dough
                    these URL is special action URL that looks like:

                    <a href="http://www.myportal.com/auth/index.html?ctrl:cmd=action&ctrl:window=default.Default.MyServletWindow&view_name=John">John</a>

                    As you see this action will come to your portlet (you can't sent it to other portlet because you don't know other portlet instance name)

                    Now your portlet know that user want to see detail for user John and render different view with John details.

                    But the point is that you stay inside of your portlet.

                    Hope it helps.

                    • 7. Re: Passing request paramter between page
                      craig1980

                      Hi. First of all thanks for your help. By some few words you have opened my mind...you are right i didn't think to the fact that every portlet is an application....so my approach to the problem was really incorrect....thanks; i'll try to use your suggestion.
                      Bye.

                      • 8. Re: Passing request paramter between page
                        ivanlatysh

                        I am using WebModels framework that does all dirty work for you so you can focus on development. That ease action handling and rendering.

                        • 9. Re: Passing request paramter between page
                          craig1980

                          Hi again.
                          I have understood that every portlet is a different application...O.K.
                          So i must write my one portlet so that it can render different view based on my action.
                          But i was thinking to this scenario:
                          i'ld like that all my layout changes...from three columns it must become two columns.....moreover in the detail page i'ld like to have only the detail portlet and no other portlet.... Is a such thing possible without changing page?I don't think so... Infact i must change all my page layout and not only the view of a single portlet....So is a similar scenario possible?And is it solvable?

                          Thanks again.

                          • 10. Re: Passing request paramter between page
                            ivanlatysh

                            Theoretically it is possible.

                            And there is a few ways to achieve it.

                            As you know each portlet is a separate application, but noone stoping you to use portlet as a 'view' (from MVC pattern). If you look at the problem from such point of view, you can externalize your business logic into separate layer (EJB for instance) and use different portlets to display different views.
                            It doesn't sound bad, but I wouldn't go this root.

                            Now let check portlet specs, and pay some attention to the point that portlet can be present more than once on the same page. Frankly speaking you can add your portlet instance more than once on the same page. So you can use a single portlet to render different views.
                            It does sound a bit better, but you will face a few challanges while implementing this approach.

                            At the end I would suggest you to stick to conventional way if you want your application to be portable.

                            P.S. Hope I understood you right.

                            • 11. Re: Passing request paramter between page
                              craig1980

                              Hi. Thanks for your replies.
                              I like this exchange of ideas... you are opening more and more my mind.

                              So if i have understood you are sayng that i should write a page with more instances of my portlet; in this way i'ld be able to display different view by usign one portlet....OK. This could be a very good solution...but i'm thinking to this scenario:
                              i'm in page A. This page is in a three columns template; in this page there are two instances of my portlet (let's call them a1 and a2) and another portlet (let's call it a3). I have this situation a1 and a2 two instances of my portlet, a3 instance of another portlet; these portlets are in the central column.
                              Now in the left column there are other two portlets (let's call them b1 and b2): one is my "Menu" and another is a google searchMotor.
                              In the right column there are other two portlet a banner and a login to the portal portlet; let's call them c1 and c2.

                              Now the portlet a1 shows a list of objects. Well i'ld like that when a user clicks on a link what is showed to the user is:
                              Portlet b1 and b2 on the left column, portlet a1 with the details of user choice in the central. Portlets a2, c1 and c2 must no longer be present.
                              So by starting from a three columns template i must arrive to a two columns template where there are different portlet.

                              Now it's this thing that i'm not able to understand....how could i implement a such thing.

                              • 12. Re: Passing request paramter between page
                                ivanlatysh

                                Here you are trying to play with portal layout and it is something that you have no control over.
                                Your boundry is a portlet window, you can play there as much as you like but you can't do anything outside of it.
                                If you need to change page layout depending on user choice you should do it withing your portlet.

                                • 13. Re: Passing request paramter between page
                                  craig1980

                                  Hi.
                                  Infact this is my requirement i must change portal layout by user choice. But i think this is a very normal requirement. So is it possible that nobody has had it? If anybody has resolved this problem can he/she give me a little sample?
                                  Thanks again for your pacience.
                                  Regards Angelo.

                                  • 14. Re: Passing request paramter between page
                                    craig1980

                                    Hi all.
                                    Has anybody tried to solve this scenario?
                                    Thanks to all.

                                    1 2 Previous Next