4 Replies Latest reply on Nov 29, 2005 12:01 AM by udaiibhaskar

    processAction in Jboss portals

    udaiibhaskar

      hi,

      i am a newbie to portals, and i have a problem in processAction() method

      --------------------------------------------------------------------------------------
      package com.mhd.cda.iu;

      import java.io.IOException;
      import javax.portlet.ActionRequest;
      import javax.portlet.ActionResponse;
      import javax.portlet.GenericPortlet;
      import javax.portlet.PortletConfig;
      import javax.portlet.PortletException;
      import javax.portlet.PortletRequestDispatcher;
      import javax.portlet.PortletURL;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      import javax.portlet.UnavailableException;

      public class SearchPortlet extends GenericPortlet {
      public static final String VIEW_JSP = "/jsp/SearchView.jsp";
      public void init(PortletConfig portletConfig) throws UnavailableException,

      PortletException {
      super.init(portletConfig);
      }

      protected void doView(RenderRequest request, RenderResponse response)throws PortletException, IOException {
      response.setContentType(request.getResponseContentType());
      PortletURL url = response.createActionURL();
      System.out.println("123445....." + url);
      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
      rd.include(request, response);
      }

      public void processAction(ActionRequest request, ActionResponse esponse)
      throws PortletException, java.io.IOException {
      String keyword=request.getParameter("keyword");
      String category=request.getParameter("category");
      String location=request.getParameter("location");
      SearchBO keyCateLoc=new SearchBO();
      boolean yes=keyCateLoc.searchKCLBo(keyword, category, location);
      }
      }

      --------------------------------------------------------------------------------------
      in the above program the processAction method is getting some values from SearchView.jsp now this values are passed to myBO object (or class) which will return boolean value, so if it is true then i should navigate the portlet to Results.jsp (How can i navigate to Results.jsp)

        • 1. Re: processAction in Jboss portals
          arvind_pv

          Hi,

          I'm also a newbie to the Portal Specification, please check the code given below.

          public class SearchPortlet extends GenericPortlet {
           private boolean resultsFlag = false;
           public static final String VIEW_RESULT = "/jsp/Results.jsp";
           public static final String VIEW_JSP = "/jsp/SearchView.jsp";
           public void init(PortletConfig portletConfig) throws UnavailableException, PortletException {
           super.init(portletConfig);
           }
          
           protected void doView(RenderRequest request, RenderResponse response)throws PortletException, IOException {
           response.setContentType(request.getResponseContentType());
           PortletRequestDispatcher portletRequestDispatcher = null;
           if(resultsFlag) {
           portletRequestDispatcher = context.getRequestDispatcher(VIEW_RESULT);
           } else {
           portletRequestDispatcher = context.getRequestDispatcher(VIEW_JSP);
           }
           portletRequestDispatcher.include(request, response);
           }
          
           public void processAction(ActionRequest request, ActionResponse esponse) throws PortletException, java.io.IOException {
           String keyword=request.getParameter("keyword");
           String category=request.getParameter("category");
           String location=request.getParameter("location");
           SearchBO keyCateLoc=new SearchBO();
           boolean yes=keyCateLoc.searchKCLBo(keyword, category, location);
           resultsFlag = yes;
           }
          }


          • 2. Re: processAction in Jboss portals

            Hello,

            Your portlets should be designed thread safe - like servlets. So your usage of an instance variable,

            resultsFlag
            , will only work as long as your portlet handles a single request from a single user. The moment two different users use invoke the processAction(), you will have contention issues for the correct value of resultsFlag.

            Also, notice in your code that you never reset resultsFlag to false, so once it gets set to true, it's always true!

            Cheers.

            • 3. Re: processAction in Jboss portals
              arvind_pv

              Hi bsmithjj,

              I thank you for giving me valuable suggestion.

              Arvind


              • 4. Re: processAction in Jboss portals
                udaiibhaskar

                Hi bsmithjj and arvind,

                Thank for ur help.

                bye,
                uday.