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 Ashwin Jayaprakash <as...@rediffmail.com> on 2002/04/30 06:07:50 UTC
JetSpeed VelocityPortlet extension
Is there a way to have a custom Velocity Portlet where
we can put some objects into the Context and so can be
accessed from the Velocity Template?
Apparently, overriding the "getContent(RunData)" and
pushing some objects into it by doing this - (see code
below), does not work, as the populateContext id
overwritten by the parent i.e VelocityPortlet. So, I
ended up copying the entire code of
VelocityPortlet.java and adding a few lines of my own
code. Is there another way to do it?
//-------- start ------------------
public ConcreteElement getContent( RunData rundata )
{
Context context = TurbineVelocity.getContext();
context.put( "myname", "Ashwin Jayaprakash" );
context.put( "dob", "Aug 24, 1996" );
context.put( "site", "www.javaforu.com" );
TurbinePull.populateContext(context, rundata);
return super.getContent( rundata );
}
//-------- end ------------------
Thanks,
Ashwin.
_________________________________________________________
Click below to visit monsterindia.com and review jobs in India or
Abroad
http://monsterindia.rediff.com/jobs
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JetSpeed VelocityPortlet extension
Posted by ra...@networks.groupvu.com.
You don't neeed to extend the VelocityPortlet, simply do the following:
- extend
org.apache.jetspeed.modules.actions.portlets.VelocityPortletAction to
write you own FooAction.
- define at least the buildNormalContext() of this FooAction to fill up
the Portlet context
with your own variables (if you have defined Turbine tools, they'll
automatically
available in your portlet).
- write your template(s) for this portlet, eg foo.vm
- in the registry, associate your Action and base template to the
VelocityPortlet:
<portlet-entry name="Foo" type="ref" parent="Velocity">
<meta-info>
<title>Foo</title>
<description>My Foo portlet</description>
</meta-info>
<parameter name="template" value="foo"/>
<parameter name="action" value="portlets.FooAction"/>
<media-type ref="html"/>
</portlet-entry>
And you're set !
> Is there a way to have a custom Velocity Portlet where
> we can put some objects into the Context and so can be
> accessed from the Velocity Template?
>
> Apparently, overriding the "getContent(RunData)" and
> pushing some objects into it by doing this - (see code
> below), does not work, as the populateContext id
> overwritten by the parent i.e VelocityPortlet. So, I
> ended up copying the entire code of
> VelocityPortlet.java and adding a few lines of my own
> code. Is there another way to do it?
>
> //-------- start ------------------
> public ConcreteElement getContent( RunData rundata )
> {
> Context context = TurbineVelocity.getContext();
> context.put( "myname", "Ashwin Jayaprakash" );
> context.put( "dob", "Aug 24, 1996" );
> context.put( "site", "www.javaforu.com" );
>
> TurbinePull.populateContext(context, rundata);
>
> return super.getContent( rundata );
> }
> //-------- end ------------------
>
>
> Thanks,
> Ashwin.
>
> _________________________________________________________
> Click below to visit monsterindia.com and review jobs in India or Abroad
> http://monsterindia.rediff.com/jobs
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
Raphaƫl Luta - raphael.luta@networks.groupvu.com
Professional Services Manager
Vivendi Universal Networks - Paris
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>