2 Replies Latest reply on Sep 9, 2005 9:22 AM by mholzner

    portlet title showing as null when not implementing doView()

    scientist

      Hello,

      I experienced a portlet behaviour that appeared somehow confusing to me. A test portlet I implemented had always the title "null", whatever I configured as portlet-info / title in the portlet.xml. Now i figured out that it depends on the fact I didn't implement the doView() method but only the render() method. I replaced the render() with the doView(), so the title was displayed correctly.

      Is this a reasonable behaviour according to the spec?

        • 1. Re: portlet title showing as null when not implementing doVi
          sjlib

          Thats interesting. I noticed my Tapestry 4.0 portlets doing the same thing. It doesn't seem to me that there should be a reliance on implementing doView() to display the title. I mean it doesn't seem like reasonable behavior.

          • 2. Re: portlet title showing as null when not implementing doVi

            the portlet spec encourages you to extend GenericPortlet and overwrite the doXYZ methods. This is for a simple reason: the render method does things for you, one of those things being setting the title. If you decide to overwrite this, you'll need to take care of the title yourself!

            from javax.portlet.GenericPortlet:

             public void render(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
             {
             response.setTitle(getTitle(request));
             doDispatch(request, response);
             }
            
             protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
             {
             if (!WindowState.MINIMIZED.equals(request.getWindowState()))
             {
             PortletMode portletMode = request.getPortletMode();
             if (PortletMode.VIEW.equals(portletMode))
             {
             doView(request, response);
             }
             else if (PortletMode.HELP.equals(portletMode))
             {
             doHelp(request, response);
             }
             else if (PortletMode.EDIT.equals(portletMode))
             {
             doEdit(request, response);
             }
             }
             }