You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by "Weaver, Scott" <Sw...@rippe.com> on 2003/09/09 00:13:40 UTC

RE: setTemplate using JSPAction (or even GenericMVCPortlet/Portle tAction now)

Please post a snippet of your registry.  That would help us immensely.  Some quick thoughts:

1. In viewtype, Jsp needs to be all caps

<parameter name="viewtype" value="JSP" hidden="false"             cachedOnName="true" cachedOnValue="true"/>

The GenericMVCAction.setTemplate(RunData, String) also works fine for me within my JSP portlet action.  I will give you some example reg entries.  Maybe that will help you in getting started:

(Excuse the formatting)

A nice base for JSP portlets using MVC:

<portlet-entry name="JspMVCPortlet" hidden="false" type="abstract" 
   application="false">
 <security-ref parent="default"/>   
 <classname>
   org.apache.jetspeed.portal.portlets.GenericMVCPortlet
 </classname>
 <parameter name="viewtype" value="JSP" hidden="false"
      cachedOnName="true" cachedOnValue="true"/>
 <url cachedOnURL="true"/>
 <category group="Jetspeed">jsp</category>
</portlet-entry>




And here is an example of its use:

<portlet-entry name="BaseHTMLPortlet" hidden="false" type="ref"
    parent="JspMVCPortlet" application="false">
 <security-ref parent="default"/>
 <meta-info>
   <title>Editable  Free-Form HTML portlet generator</title>
     <description>Use this this portlet generator to create
                  editable free-form HTML portlets.
     </description>
 </meta-info>
 <!-- Make sure this is the GenericMVCPortlet, or a subclass of it. -->
 <classname>
   org.apache.jetspeed.portal.portlets.GenericMVCPortlet
 </classname>
 <!-- My default template -->
 <parameter name="template" value="essential/editor/document.jsp"
      hidden="false" cachedOnName="true" cachedOnValue="true"/>
<!-- My action, make sure it is a subclass of GenericeMVCAction -->
 <parameter name="action"                              
    value="portlets.freeform.FreeformPortletAction"
    hidden="false" cachedOnName="true" cachedOnValue="true"/>
<!-- So we can use our own configure screens -->
 <parameter name="provides.customization" value="true"
    hidden="false" cachedOnName="true" cachedOnValue="true"/>

<!-- I left out a bunch of parameters 
   - that are not relative to the example
 -->

 <media-type ref="html"/>
 <url cachedOnURL="true"/>
</portlet-entry>


HTH,
*===================================*
* Scott T Weaver                    *
* Jakarta Jetspeed Portal Project   *
* weaver@apache.org                 *
*===================================*
  


> -----Original Message-----
> From: Gregory Joseph [mailto:gjoseph@kiala.com]
> Sent: Monday, September 08, 2003 1:02 PM
> To: Jetspeed Users List
> Cc: jetspeed-dev@jakarta.apache.org
> Subject: RE: setTemplate using JSPAction (or even
> GenericMVCPortlet/PortletAction now)
> 
> I am now using the GenericMVCPortlet, with an additional parameter in my
> local-portlets.xreg (viewtype=Jsp), but still no success: when i examine
> what
> is going on in the setTemplate method, i see usage of the
> getTemplateContext
> method from the TemplateInfo object of my rundata. If I look in
> templateInfo,
> i can see 3 "tempKeys", namely "VelocityActionContext", "VELOCITY_CONTEXT"
> and "00layout_template00", the 1st one being an instance of
> GenericActionContext, but with no available keys(this is where the
> nullpointerexception is thrown i think), the 2nd being an instance of
> VelocityContext, with a number of keys, but none of them being "template",
> and the last one being a string("/default.jsp")
> 
> I really don't know what to do. I expect I'm not the only one using
> multiple
> views on the same portlet right!?
> 
> Thanks for any help.
> 
> greg
> 
> -----Original Message-----
> From: Gregory Joseph
> Sent: vendredi 5 septembre 2003 18:28
> To: Jetspeed Users List
> Subject: RE: setTemplate using JSPAction
> 
> 
> Maybe this should be forwarded to the dev-ml.
> Anyway, I included the complete stacktrace below if that can help.
> 
> -----Original Message-----
> From: Gregory Joseph
> Sent: vendredi 5 septembre 2003 17:52
> To: Jetspeed Users List
> Subject: setTemplate using JSPAction
> 
> 
> Hi list,
> 
> In my action class extending jspAction, i try to use the setTemplate
> method,
> but it doesn't work. I throws a NullPointerException somewhere when trying
> to
> retrieve a "VelocityPortletContext" (how surprising when working with a
> JSPPortlet) Besides, I had to catch this exception myself, otherwise it
> wasn't appearing anywhere in the logs, not even a single error message...
> 
> I found this had been fixed a while ago:
> http://www.mail-archive.com/jetspeed-user@jakarta.apache.org/msg07770.html
> Bug when looking on the cvs view, i see there's been some refactoring
> afterwards, so i think the issue might have re-appeared.
> 
> Can someone confirm and/or propose a solution?
> 
> my code simply looks like:
> 
> //.....blahblah do stuff
> setTemplate(rundata, "mypage.jsp");
> 
> But then the portlet still displays the original template (the one set in
> the
> xreg file).
> (I also tried without the .jsp extension, but result is exactly the same)
> 
> 
> ---------------------------------------------------------------------
> java.lang.NullPointerException
>         at
> org.apache.jetspeed.modules.actions.portlets.PortletAction.getPortlet(Port
> let
> Action.java:208)
>         at
> org.apache.jetspeed.modules.actions.portlets.PortletAction.setTemplate(Por
> tle
> tAction.java:169)
>         at
> com.company.web.actions.SearchAction.doSearch(SearchAction.java:81)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorIm
> pl.
> java:25)
>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at
> org.apache.jetspeed.modules.actions.portlets.PortletActionEvent.fireEvent(
> Por
> tletActionEvent.java:215)
>         at
> org.apache.jetspeed.modules.actions.portlets.PortletActionEvent.executeEve
> nts
> (PortletActionEvent.java:176)
>         at
> org.apache.jetspeed.modules.actions.portlets.GenericMVCAction.perform(Gene
> ric
> MVCAction.java:148)
>         at
> org.apache.turbine.modules.ActionLoader.exec(ActionLoader.java:122)
>         at
> org.apache.turbine.modules.pages.DefaultPage.doBuild(DefaultPage.java:143)
>         at org.apache.turbine.modules.Page.build(Page.java:90)
>         at org.apache.turbine.modules.PageLoader.exec(PageLoader.java:123)
>         at org.apache.turbine.Turbine.doGet(Turbine.java:563)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Unknown
> Source)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(Unknown
> Source)
>         at org.apache.catalina.core.StandardWrapperValve.invoke(Unknown
> Source)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.inv
> oke
> Next(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invoke(Unknown
> Source)
>         at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardContextValve.invoke(Unknown
> Source)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.inv
> oke
> Next(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invoke(Unknown
> Source)
>         at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardContext.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardHostValve.invoke(Unknown
> Source)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.inv
> oke
> Next(Unknown Source)
>         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(Unknown
> Source)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.inv
> oke
> Next(Unknown Source)
>         at org.apache.catalina.valves.ErrorReportValve.invoke(Unknown
> Source)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.inv
> oke
> Next(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invoke(Unknown
> Source)
>         at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
>         at org.apache.catalina.core.StandardEngineValve.invoke(Unknown
> Source)
>         at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.inv
> oke
> Next(Unknown Source)
>         at org.apache.catalina.core.StandardPipeline.invoke(Unknown
> Source)
>         at org.apache.catalina.core.ContainerBase.invoke(Unknown Source)
>         at
> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
>         at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processCon
> nec
> tion(Http11Protocol.java:392)
>         at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.j
> ava
> :619)
>         at java.lang.Thread.run(Thread.java:536)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org