1 Reply Latest reply on Jul 23, 2008 11:56 AM by iamnew2jboss

    Portlet rendering through servlet

    iamnew2jboss

      Hello There

      Thomas, Julian,

      I've a business requirement of rendering a portlet from a Servlet. There won't be JSPs with:

      <portal:page>
      <portal:pageparam>
      <xportal:portlet> etc.

      Instead, servlet would need to read and render the portlet deployed in the "webapps" directory.

      Below is some code that I'm playing with.

      
       QName name = new QName("urn:jboss:portal:simple:google", "zipcode");
       boolean frozen = true;
       PageParameterDef parameterDef = new PageParameterDef(name, "94939", frozen);
      
       Map<QName, PageParameterDef> paramDefs;
       paramDefs = new HashMap<QName, PageParameterDef>();
       paramDefs.put(name, parameterDef);
      
       int size = paramDefs.size();
       out.write("The size is::::: " + size);
      
       Mode initialMode = Mode.VIEW;
       final Set<Mode> DEFAULT_MODES = Collections.unmodifiableSet(Tools.toSet(Mode.VIEW, Mode.EDIT, Mode.HELP));
       final Set<WindowState> DEFAULT_WINDOW_STATES = Collections.unmodifiableSet(Tools.toSet(WindowState.NORMAL, WindowState.MAXIMIZED, WindowState.MINIMIZED));
      
      
       WindowDef windowDef = new WindowDef("PagePortlet", "2-PagePortlet", "1", initialMode, DEFAULT_MODES, DEFAULT_WINDOW_STATES);
      
      
      
       Map<String, WindowDef> windowDefs;
       windowDefs = new HashMap<String, WindowDef>();
       paramDefs = new HashMap<QName, PageParameterDef>();
       windowDefs.put("1", windowDef);
      
      
      
       WindowState ws = WindowState.MAXIMIZED;
       WindowDef windowDefNew = windowDefs.get("1");
      
      
       try {
       response.setContentType("text/html;charset=UTF-8");
       application = getServletContext();
      
      
       out.write("\n");
       out.write("\n");
       out.write("\n");
       out.write("\n");
       out.write("\n");
       out.write("\n");
       out.write("\r\n");
       out.write("application::: " + application.toString());
       out.write("\n");
       out.write("windowDef " + windowDefs);
       out.write("\n");
       out.write("windowDefNew.getApplicationName(): " + windowDefNew.getApplicationName());
      
       } catch (Throwable t) {
       }



      The output i'm getting in the browser is:
      The size is::::: 1 application::: org.apache.catalina.core.ApplicationContextFacade@1083717 windowDef {1=org.jboss.portal.portlet.portal.jsp.WindowDef@58cca9} windowDefNew.getApplicationName(): 2-PagePortlet

      I tried to figure out the rendering logic from the "sources" but couldnt find the appropriate classes. Can anybody please guide me in a right direction so that I can render the portlet window through servlet?

      Is it possible to get an architectural diagram of all the classes involved and their relationship with each other?

      Thank you in advance.
      Regards.