(And I thought I was being so clever about the Context idea).

Another issue is that the emerging VSTL is useful for if's and set's
but shares JSTL's wordiness for straight output
(e.g. <c:out "${model.property}"/>  instead of just $model.property).

But mixed in with veltag, you could easily render a block of Velocity
in the middle of a page.

The more I think about it, the more I like this idea.  Be nice for
those of us who use JSP and Velocity all the time.   I'd think the
tasks to build this out into production-ready toolkit would be
something like this:

* modify Velocity core to support evaluation of expressions
* create new VSTL tag library in part that parallels JSTL
* add in macro capability (?)
* merge in veltag (?)
* document, create examples, website, etc.

This would be a nice sub-project of a future Velocity TLP.  :-)

What do you think Jeff?  Is this feasible or have we hijacked your
idea into something new?

WILL

On 8/22/06, Nathan Bubna <[EMAIL PROTECTED]> wrote:
On 8/22/06, Will Glass-Husain <[EMAIL PROTECTED]> wrote:
> I was driving up this morning (Silicon Valley commute) thinking about
> this.  Maybe we could call it VSTL  (Velocity Standard Tag Library)?

:)  yeah, that's basically what we're dreaming up.  it would be nice.
JSTL makes JSP much more tolerable, but as a Velocity user, it's still
frustrating.

> New implementation idea... use a custom Context object that serves as
> an adapter to the PageContext.    This way you wouldn't need to
> populate a Context ahead of time.  Whenever an object is needed, it is
> just pulled directly from the page/request/session PageContext.  (same
> as JSTL).

Veltag has one of those.

http://svn.apache.org/repos/asf/jakarta/velocity/engine/trunk/experimental/veltag/src/java/org/apache/taglibs/velocity/JSPContext.java

i have an improved version with toolbox support on my local drive.
it's part of my experimenting for VelocityTools 2.0 (where i'm trying
to turn Veltag into a VelocityViewTag that parallels the
VelocityViewServlet in tool support and all that).

It's not all working/compiling yet, but i could check it into a SVN
whiteboard directory so others can play, if any are interested.

> Similarly, <v:set> would store the object in the PageContext (is
> request scope the default for JSTL?) with an optional scope parameter
> to put it in one of the other scopes.
>
> We should really make a Wiki page about this...

+1  Go here to create it:

http://wiki.apache.org/jakarta-velocity/VSTL

:)

> WILL
>
>
>
>
>
> On 8/20/06, Will Glass-Husain <[EMAIL PROTECTED]> wrote:
> > Incidentally, why stop at <v:set>?  I'd also expect to see <v:if>,
> > <v:choose>/<v:when> (for if/then/else), <v:out>.
> >
> > One big advantage of Velocity over JSTL is the ability to easily
> > create macros.  Defining a macro <v:macro> at the top of the page then
> > using it below would be quite nice.  It'd be trickier to implement
> > though.  The above tags could all execute stand-alone VTL, but
> > <v:macro> would need to have some kind of connection with the tags
> > later in the page.
> >
> > WILL
> >
> > On 8/20/06, Will Glass-Husain <[EMAIL PROTECTED]> wrote:
> > > Hi Jeff,
> > >
> > > Now I get it.  If you built a simpler tag that always stored a String
> > > object this would be easy-- just use Velocity.evaluate as I suggest.
> > > But you want to evaluate an expression to a resulting object.
> > >
> > > Seems to me that you want this to act similar to the Velocity #set.
> > > You might start by looking at the class
> > > o.a.v.runtime.parser.node.ASTSetDirective.  The key line is:
> > >
> > >         Object value = right.value(context);
> > >
> > > which evaluates the right hand side of the #set expression.
> > >
> > > One way of approaching this is to consider that Velocity.evaluate()
> > > basically ends up calling Node.render() which is a recursive series of
> > > parser nodes that output to a Writer.  You need a similar starting
> > > point to call Node.value() which will recursively evaluate an
> > > expression.
> > >
> > > Just a few quick thoughts, hope they point you in a useful direction...
> > >
> > > WILL
> > >
> > > On 8/19/06, Jeff Schnitzer <[EMAIL PROTECTED]> wrote:
> > > > I'm just evaluating Velocity expressions.  The result of the expression
> > > > should be an object, whereas Velocity.evaluate() renders output to a
> > > > Writer as text.  The method I'm looking for would look something like 
this:
> > > >
> > > > public Object evaluate(Context ctx, String expression);
> > > >
> > > > For example:
> > > >
> > > > ctx.put("now", Calendar.getInstance());
> > > > TimeZone tz = (TimeZone)evaluate(ctx, "now.timeZone");
> > > >
> > > > The Introspector seems to be much, much lower level than this.
> > > >
> > > > Thanks,
> > > > Jeff
> > > >
> > > > Will Glass-Husain wrote:
> > > > > Not sure I get it.  Are you making a new expression language or just
> > > > > evaluating Velocity expressions?
> > > > >
> > > > > The introspector is what resolves objects and methods in Velocity.
> > > > >
> > > > > WILL
> > > > >
> > > > > On 8/19/06, Jeff Schnitzer <[EMAIL PROTECTED]> wrote:
> > > > >> Velocity.evaluate() renders textual output to a Writer.  For the
> > > > >> expression language to work, I need to resolve objects.  I can't find
> > > > >> anything in the javadocs that might give me a hook.
> > > > >>
> > > > >> Any suggestions?
> > > > >>
> > > > >> I know, I need to wade through the code, but a few starting pointers
> > > > >> would help.
> > > > >>
> > > > >> Thanks,
> > > > >> Jeff
> > > > >>
> > > > >>
> > > > >> Will Glass-Husain wrote:
> > > > >> > Wow!  As a both a Velocity enthusiast and JSTL junkie that sounds 
like
> > > > >> > a really useful tag.
> > > > >> >
> > > > >> > It doesn't sound that hard to me.  Extract the expression, call
> > > > >> > Velocity.evaluate, and set the request attribute.  I guess you'd 
have
> > > > >> > to set up the context with all the beans first.
> > > > >> >
> > > > >> > WILL
> > > > >> >
> > > > >> >
> > > > >> > On 8/17/06, Jeff Schnitzer <[EMAIL PROTECTED]> wrote:
> > > > >> >> Short version:  I wish for a JSP custom tag that will effectively
> > > > >> let me
> > > > >> >> use Velocity expressions instead of the anemic JSTL expressions.
> > > > >> >>
> > > > >> >> Long version:
> > > > >> >>
> > > > >> >> Velocity already has a custom JSP tag that lets me do this:
> > > > >> >>
> > > > >> >> <vel:velocity>
> > > > >> >>     #if(true) cool velocity stuff #end
> > > > >> >> </vel:velocity>
> > > > >> >>
> > > > >> >> However, what I really really want is something that lets me use
> > > > >> >> velocity expressions the way I would use JSTL expressions.  The 
most
> > > > >> >> important is this:
> > > > >> >>
> > > > >> >> <vel:set var="foo" value="${cool.velocity(syntax)}" />
> > > > >> >>
> > > > >> >> The inability of JSTL expressions to call arbitrary java methods
> > > > >> results
> > > > >> >> in muchhacking and hair pulling.  Velocity expressions rock.  I 
want
> > > > >> >> them :-)
> > > > >> >>
> > > > >> >> How hard would it be to make a <vel:set> tag?  I looked around the
> > > > >> APIs
> > > > >> >> but couldn't find anything helpful.
> > > > >> >>
> > > > >> >> Thanks,
> > > > >> >> Jeff
> > > > >> >>
> > > > >> >> 
---------------------------------------------------------------------
> > > > >> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > >> >> For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >> >>
> > > > >> >>
> > > > >> >
> > > > >> >
> > > > >>
> > > > >>
> > > > >> ---------------------------------------------------------------------
> > > > >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > >> For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > Forio Business Simulations
> > >
> > > Will Glass-Husain
> > > [EMAIL PROTECTED]
> > > www.forio.com
> > >
> >
> >
> > --
> > Forio Business Simulations
> >
> > Will Glass-Husain
> > [EMAIL PROTECTED]
> > www.forio.com
> >
>
>
> --
> Forio Business Simulations
>
> Will Glass-Husain
> [EMAIL PROTECTED]
> www.forio.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to