3 Replies Latest reply on Nov 8, 2005 1:13 PM by Bradley Smith

    how jsp should call processAction

    pedro costa Apprentice

      I suppose that, the method processAction is the right method to handle action. So i've this java file:

      
      package com.sample.portlet;
      
      import java.io.*;
      import java.io.IOException;
      
      import javax.portlet.*;
      
      public class Registo extends GenericPortlet {
      
       public static final boolean DEBUG = true;
      
       public void processAction(ActionRequest request, ActionResponse response)
       {
       System.out.println("TESTTTTTTTTTTTTTTTTTTTT");
       }
      
      
       public void doView(RenderRequest request, RenderResponse response)
       throws PortletException, IOException
       {
       response.setContentType("text/html");
      
       String jspName = getPortletConfig().getInitParameter("jspView");
       PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/RegistoOcorrencia.jsp");
       rd.include(request, response);
      
       if(DEBUG)
       {
       System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxx");
       System.out.println("JANELA 1");
       System.out.println(jspName);
       System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxx");
       }
       }
      }
      
      
      



      and now i want create a form in jsp file, that, when the form submits, the processAction is called. I don't know what should i put in the action field of the form.

      Can you give any small example?

      Thanks
      Pedro

        • 1. Re: how jsp should call processAction
          Bradley Smith Master

          You can go to portlet swap and download my submission, the JavaPlant MVC Portlet Framework under Framework Portlets here.
          In the distribution, you will find a set of JSP components for my RSS Portlet in this directory: mvc-portlet-fwk\samples\app\src\webapp\WEB-INF\jsp\portlets\RSSFeedPortlet

          Have a look at the edit.jsp - it demonstrates how you should create URL's correctly for your portlet's actions.

          Basically, when creating action URL's for portlets, you use the <portlet:actionURL> tag to create the value for your form's action attribute. If you need multiple action URL's, my RSS Portlet illustrates how to achieve this using the tag(s), JSTL, and some javascript.

          Good Luck!

          • 2. Re: how jsp should call processAction
            pedro costa Apprentice

            Maybe i've explained wrongly. I have a form in a jsp file. When i do submit, i want to have something that creates an java object. And it's this i can't do.

            I'm a newbie in this world, so i can't find any simple example. Can anybody help me, give any simple example, or explaining me?

            thanks,
            Pedro

            • 3. Re: how jsp should call processAction
              Bradley Smith Master

              Again - try my framework - it provides this feature ;-)

              You can configure your portlet to automatically create a PortletForm (an object - a form bean) and the request parameters will be used to set the properties of your form bean.

              It's here.

              It's also reasonably well documented.

              Good Luck!