You may want to check out my recent CVS commits - I have already commited files for this.

Currently the paths to controlheader & controlfooter are hard-coded, but I will fix that tomorrow. I'll just add the current servlet's path to the velocity context. So the parse line will be:

#parse ("${currentpath}/controlheader.vm")

Have a look at the current CVS HEAD for webwork, and try out the examples after changing the templateSuffix property in webwork.properties.

Cheers,
Scott

Robert Nicholson wrote:
I'm confused about all the rd.include talk?

What is wrong with the way things are now?

With the servlet mapping the way it is for .vm etc it all just comes out in the wash doesn't it?

Usually having access to the value stack from within a template isn't strictly necessary it is?

Here's a rough version of text.jsp as a VM that I wipped out whilst trying this out.

The issue for me was not wanting to hard code paths in my templates whilst maintaining the controlheader.jsp, controlfooter.jsp functionality.

Here's text.vm

#*
--
-- WebWork, Web Application Framework
--
-- Distributable under LGPL license.
-- See terms of license at opensource.org
--
--
-- text.jsp
--
-- Required Parameters:
-- * label - The description that will be used to identfy the control.
-- * name - The name of the attribute to put and pull the result from.
-- Equates to the NAME parameter of the HTML INPUT tag.
--
-- Optional Parameters:
-- * labelposition - determines were the label will be place in relation
-- to the control. Default is to the left of the control.
-- * size - SIZE parameter of the HTML INPUT tag.
-- * maxlength - MAXLENGTH parameter of the HTML INPUT tag.
-- * disabled - DISABLED parameter of the HTML INPUT tag.
-- * readonly - READONLY parameter of the HTML INPUT tag.
-- * onkeyup - onkeyup parameter of the HTML INPUT tag.
-- * tabindex - tabindex parameter of the HTML INPUT tag.
-- * onchange - onkeyup parameter of the HTML INPUT tag.
*#

#parse("controlheader.vm")

#set ( $name = $parameters.get("name") )
#set ( $size = $parameters.get("size") )
#set ( $maxlength = $parameters.get("maxlength") )
#set ( $nameValue = $parameters.get("nameValue") )
#set ( $disabled = $parameters.get("disabled") )
#set ( $readonly = $parameters.get("readonly") )
#set ( $onkeyup = $parameters.get("onkeyup") )
#set ( $tabindex = $parameters.get("tabindex") )
#set ( $onchange = $parameters.get("onchange") )
#set ( $id = $parameters.get("id") )

<input type="text" name="$name"
#if ($size)
size="$size"
#end
#if ($maxlength)
maxlength="$maxlength"
#end
#if ($nameValue)
nameValue="$nameValue"
#end
#if ($disabled)
disabled="$disabled"
#end
#if ($readonly)
readonly="$readonly"
#end
#if ($onkeyup)
onkeyup="$onkeyup"
#end
#if ($tabindex)
tabindex="$tabindex"
#end
#if ($onchange)
onchange="$onchange"
#end
#if ($id)
id="$id"
#end
/>

#parse("controlfooter.vm")

here's controlheader.vm

## Only show message if errors are available.
## This will be done if ActionFormSupport is used.

#set ( $name = $parameters.get("name") )
#set ( $error = $errors.get($name) )

#if ($error)
<tr>
#set ($labelposition = $parameters.get("labelposition") )
#if ($labelposition == "top")
<td align="left" valign="top" colspan="2">
#else
<td align="center" valign="top" colspan="2">
#end
<span class="errorMessage>$error></span>
</td>
</tr>
#end

## if the label position is top,
## then give the label it's own row in the table

<tr>

#set ( $labelposition = $parameters.get("labelposition") )
#if ($labelposition == "top")
<td align="left" valign="top" colspan="2">
#else
<td align="right" valign="top">
#end
#if ($error)
<span class="errorLabel">
#else
<span class="label">
#end #set ( $label = $parameters.get("label") )
$label:
</span>
</td>
#if ($labelposition == "top")
</tr><tr>
#end
<td>

...

This was all proof of concept.

I didn't quite understand how the file resource loader stuff works in velocity... I didn't want to have
to hard code any specific path in my #parse statements but I want to separate my velocity tag support
from my result views.

as the above stands .. controlheader.jsp has to be in the root context for this to load and that's not acceptable.


On Tuesday, January 28, 2003, at 08:50 AM, Scott Farquhar wrote:

(Also available here:
http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-111)

I have looked at changing the view tags over to velocity, and it is looking very promising. I have attached the text.vm & text.jsp files for a comparison, and it cleans the code up quite a bit.

As a first step, all the views can be duplicated in velocity, and then use the VelocityServlet to include them. This will not reduce the overhead of the rd.include() but will reduce the time for the included page to be parsed.

I have completed (&committed) this & added a corresponding '.vm' file for most ui tags. You need to change 'webwork.ui.templateSuffix' to 'vm' and you need to map the WebWorkVelocityServlet to '*.vm'. I have tested the examples, but nothing further.

However, when working through this, I came to a few problems:

- Getting the value from the top of the valueStack.
This is usually obtained with a "." or a "null" value passed to stack.findValue(). However, in velocity, all values must start with a character. Are their any other synonyms for the current value that I don't know about? Can we add one?

- Getting the templates (using servletPath).
Some servlet containers have problems with getRealPath(). We can always bundle default templates in the jar (a plus), but how do we access the templates? Rickard seems to do it with his WebWorkVelocityServlet - but I'm not sure how.

- Runtime dependencies
If we choose to short-circuit the rd.include(), then how do we prevent a runtime dependency with velocity? Do we use reflection & classloading to prevent it? Any nicer alternatives?

Todo:

- If anyone is up for changing ComponentTag.doEndTag() to not do a rd.include() if we are serving velocity? Rickard?

- Updating the remaining templates. Some of the templates I don't use (does anyone use selectcascading?), and so any help translating these would be appreciated.

- A standard set of macros/directives that deal with pushing & popping values onto the valueStack, and all other tags (i18n, subset etc).

I'm sure that there's more todo - yell if you know anything.

Cheers,
Scott


--

ATLASSIAN - http://www.atlassian.com
Expert J2EE Software, Services and Support
-------------------------------------------------------
Need a simple, powerful way to track and manage issues?
Try JIRA - http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

--

ATLASSIAN - http://www.atlassian.com
Expert J2EE Software, Services and Support
-------------------------------------------------------
Need a simple, powerful way to track and manage issues?
Try JIRA - http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to