Tuesday, June 4, 2013

which method will take priority if your portlet class has both doView and annotation method for view?

public class MyGenericPortlet extends GenericPortlet {
    @RenderMode(name = "VIEW")
    public void sayHello(RenderRequest request,    RenderResponse response) throws
    PortletException, IOException {
       
    PrintWriter out = response.getWriter();
    out.println("Hello World! This is implemented using GenericPortlet and "
            + "content coming from sayHello annotation method");
   

    }
@Override
    protected void doView(RenderRequest request, RenderResponse response)
            throws PortletException, IOException {
        // TODO Auto-generated method stub
        PrintWriter out = response.getWriter();
        out.println("Hello World! This is implemented using GenericPortlet and content coming from doView() method");
        //super.doView(request, response);
    }
    


....

}
  

The annotation method takes high priority. In the above portlet sayHello will be executed.


No comments:

Post a Comment