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 Church Michael R <MR...@qinetiq.com> on 2006/02/02 13:34:01 UTC

Portlet fails to call Velocity Template

Hello All (once again),

Using Jetspeed 2 as a complete novice is a nightmare. The documentation for
it is incomplete, and referring to the documentation/tutorial for Jetspeed
1.6 is pointless (because Jetspeed 1.6 bears no resemblance to Jetspeed 2).

I have been trying all morning to create me a simple Portlet that uses a
Velocity template for rendering its content in View mode. The Portlet
extends GenericVelocityPortlet, so I imagine that calling super.doView() in
my doView() will be sufficient. I have also set a context variable in my
doView() that I want the Velocity template to make use of.

However, the portlet does not render the content that I have set up in my
.vm file. The HTML fragment for the portlet IS displayed, properly titled
and with the required EDIT and HELP buttons in the title bar, but the
content part of the fragment is empty.

Bearing in mind that I am setting up the portlet by hand (can't use maven,
no internet connection on my development PC), what do I have to do to get
the .vm file to be used?

Looking at the example demo portlet, I notice that it has a few extras files
than mine does:

    jetspeed-portlet.xml
    veltag.tld
    c.tld

What are these? Are they significant for Velocity template use?

Any help would be greatly appreciated. See below for what I believe to be
relevant information about my setup.

Cheers,
Mike

---------------------------------------------------

I currently have the following files deployed in my jetspeed-2/webapps
folder:

    simple/WEB-INF
      |
      +---classes-----simple.class
      |
      +---lib------+--portal-bridges-common-1.0.jar
      |            +--portal-bridges-velocity-1.0.jar
      |            +--velocity-1.4.jar
      |            +--velocity-tools-1.1.jar
      |
      +---tld---------portlet.tld
      |
      +---velocity-+--toolbox.xml
      |            +--velocity.properties
      |            +--velocity-macros.vm
      |
      +---view--------simple-view.vm
      |
      +---portlet.xml
      |
      +---web.xml

I stole the velocity directory as is from jetspeed2/webapps/demo/WEB-INF. It
has not been changed.

The tld/portlet.tld file is generated for me as the portlet is deployed.

The web.xml file is, of course, modified for me on deployment.

I have arranged for the portlet.xml file to have the appropriate entries for
<init-param> and <supports> for my simple portlet:

    <init-param>
        <name>ViewPage</name>
        <value>/WEB-INF/view/simple-view.vm</value>
    </init-param>

    <supports>
        <mime-type>text/html</mime-type>
        <portlet-mode>VIEW</portlet-mode>
        <portlet-mode>EDIT</portlet-mode>
        <portlet-mode>HELP</portlet-mode>
    </supports>

My portlet's doView() looks like this:

    pubic void doView(RenderRequest request, RenderResponse response)
    {
        String testStr = "test";
        response.setContentType("text/html");
        this.getContext(request).put("thing", testStr);
        super.doView(request, response);
    }

---------------------------------------------------


Mike Church
Software Engineering

QinetiQ
Bldg Lovell Rm 109
Malvern Technology Centre
St. Andrews Road, Malvern
Worcestershire, WR14 3PS
Tel: 
01684 896085 
Email: 
mrchurch@QinetiQ.com 
Web: 
www.QinetiQ.com 
QinetiQ - The Global Defence and Security Experts. 


The Information contained in this E-Mail and any subsequent correspondence
is private and is intended solely for the intended recipient(s).
For those other than the recipient any disclosure, copying, distribution,
or any action taken or omitted to be taken in reliance on such information
is prohibited and may be unlawful.

Emails and other electronic communication with QinetiQ may be monitored.
Calls to QinetiQ may be recorded for quality control,
regulatory and monitoring purposes.

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: Portlet fails to call Velocity Template

Posted by Aaron Evans <aa...@yahoo.ca>.
Church Michael R <MRCHURCH <at> qinetiq.com> writes:

> 
> However, the portlet does not render the content that I have set up in my
> .vm file. The HTML fragment for the portlet IS displayed, properly titled
> and with the required EDIT and HELP buttons in the title bar, but the
> content part of the fragment is empty.
> 
> Looking at the example demo portlet, I notice that it has a few extras files
> than mine does:
> 
>     jetspeed-portlet.xml
>     veltag.tld
>     c.tld
> 
> What are these? Are they significant for Velocity template use?
> 

Michael,
.tld files are "tag library definitions".  As I recall, c.tld is part of the
standard JSTL (java standard tag library).  veltag.tld is no doubt related to
velocity and this is probably your culprit.

I don't know much about using velocity templates, especially in portlets. 
However, I do know that when you use tags and the .tld files are not found
for them, then often they get displayed literally, so that may be what is 
happening here.

I have a question for you though.  Do you have a velocity background? Because
if not, I would suggest using JSPs for your portlets instead...


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org