You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Marinó A. Jónsson" <ma...@centrum.is> on 2003/07/23 02:36:30 UTC

Struts 1.1 support

yeah ... definately looking forward to official Struts 1.1 support next :)

I miss seeing a listing for Tiles and Modules in the Status doc though.  As
I've already stated I have að working TilesTool to contribute (although it
lacks support for put-lists).  I could also use struts modules in my
projects ... so maybe I can lend a hand with that?

Cheers,
Marino

-----Original Message-----
From: Tim Colson [mailto:tcolson@cisco.com] 
Sent: 17. júlí 2003 14:29
To: velocity-dev@jakarta.apache.org
Cc: Gabriel Sidler
Subject: RE: [ANNOUNCEMENT] Velocity Tools 1.0 released

Whoo Hoo! Great work Nathan! :-)

I removed the temporary docs on happysearch.com. 

Gabe, perhaps the docs here should be removed to, now that there is an
official version.
http://www.teamup.com/jakarta-velocity-tools/tools/docs/ 

Looking forward to official Struts 1.1 support next! (I'll be able to
use it within a few weeks, so I'll get busy converting the taglib to a
tool so Velocity can access the client-side javascript validation the
Validator provides.)

Cheers,
Timo


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Struts 1.1 support

Posted by Nathan Bubna <na...@esha.com>.
Marinó A. Jónsson said:
> I actually missed Tom's email so thanks for reposting :)  There are three
> main differences between my version and his ...
>
> my version supports nested tiles
> my version supports tile-controllers
> my version doesn't require a velocity-macro

sounds good.

> Tiles are _very_ simple to use and I have already prepared a little demo-app
> you can use to get up to speed :)  It features the TilesTool used with
> Velocity and Struts, and also an example of how to use a tile-controller.

sounds even better.

> Do you want it sent to nathan@esha.com?

sure.  or wiki or you can try posting to the list. (not sure if that'll work,
attachments seem to be stripped these days.  though i think *.txt files might
work.)

> Regarding module support I'll start looking at StrutsUtils :)

:) great!

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Struts 1.1 support

Posted by Nathan Bubna <na...@esha.com>.
Marinó A. Jónsson said:
...
> http://nagoya.apache.org/wiki/apachewiki.cgi?TilesTool
>
> (you can also find it under 'Contributed Code and Examples' in the
> VelocityProjectPages :)

i just linked to it on the VelocityTools wiki page as well.

> This is just the TilesTool class though ... Nathan, my offer to email the
> demo-app still stands :)

yeah, pass it my way or wiki or whatever you feel like.  (Wiki is good for
community interaction--don't wanna leave Tim out in the cold ;)

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


[VELTOOLS] Struts 1.0 Javascript Validation Tool

Posted by Tim Colson <tc...@cisco.com>.
> -----Original Message-----
> From: Marinó A. Jónsson [mailto:marinoj@centrum.is] 
> Sent: Wednesday, July 23, 2003 8:43 AM
> how is your client-side javascript validation access coming? 
> ... I'm pretty curious about that ;)

I just posted a quick hack version on the Wiki. :-)

http://nagoya.apache.org/wiki/apachewiki.cgi?VelocityValidationTool

The good news is that it seems to actually even work, the bad news is
that I probably need to get Struts 1.1 to run locally before I can start
upgrading it to use the commons validation and Struts 1.1 features.

But at least this is a start for those of us currently stuck in 1.0
land. <grin>

Cheers,
Timo


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


RE: Struts 1.1 support

Posted by "Marinó A. Jónsson" <ma...@centrum.is>.
<grinrightbackatyah> :P

how is your client-side javascript validation access coming? ... I'm pretty
curious about that ;)

Cheers,
Marino

-----Original Message-----
From: Tim Colson [mailto:tcolson@cisco.com] 
Sent: 23. júlí 2003 15:33
To: 'Velocity Developers List'
Subject: RE: Struts 1.1 support

> Ok Timo - the TilesTool has been posted so you can satisfy 
> your extreme curiousity ;)
Fantastic. :-)

> This is just the TilesTool class though ... 
> Nathan, my offer to email the demo-app still stands :)
Oh! I was hoping you'd post the demo-app there too, I'm intensely
interested in that too. <grin>

Timo


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


RE: Struts 1.1 support

Posted by Tim Colson <tc...@cisco.com>.
> Ok Timo - the TilesTool has been posted so you can satisfy 
> your extreme curiousity ;)
Fantastic. :-)

> This is just the TilesTool class though ... 
> Nathan, my offer to email the demo-app still stands :)
Oh! I was hoping you'd post the demo-app there too, I'm intensely
interested in that too. <grin>

Timo


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


RE: Struts 1.1 support

Posted by "Marinó A. Jónsson" <ma...@centrum.is>.
Damn - this Wiki is pretty cool :D

Ok Timo - the TilesTool has been posted so you can satisfy your extreme
curiousity ;)

http://nagoya.apache.org/wiki/apachewiki.cgi?TilesTool

(you can also find it under 'Contributed Code and Examples' in the
VelocityProjectPages :)

This is just the TilesTool class though ... Nathan, my offer to email the
demo-app still stands :)

Cheers,
Marino


-----Original Message-----
From: Tim Colson [mailto:tcolson@cisco.com] 
Sent: 23. júlí 2003 14:28
To: 'Velocity Developers List'
Subject: RE: Struts 1.1 support

Marino -

> Do you want it sent to nathan@esha.com?
How about posting this onto the Wiki so we can all have a look - I'm
extremely curious. :-)

http://nagoya.apache.org/wiki/apachewiki.cgi?VelocityProjectPages

Thanks!
Tim


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


RE: Struts 1.1 support

Posted by Tim Colson <tc...@cisco.com>.
Marino -

> Do you want it sent to nathan@esha.com?
How about posting this onto the Wiki so we can all have a look - I'm
extremely curious. :-)

http://nagoya.apache.org/wiki/apachewiki.cgi?VelocityProjectPages

Thanks!
Tim


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


RE: Struts 1.1 support

Posted by "Marinó A. Jónsson" <ma...@centrum.is>.
I actually missed Tom's email so thanks for reposting :)  There are three
main differences between my version and his ... 

my version supports nested tiles
my version supports tile-controllers 
my version doesn't require a velocity-macro  

Tiles are _very_ simple to use and I have already prepared a little demo-app
you can use to get up to speed :)  It features the TilesTool used with
Velocity and Struts, and also an example of how to use a tile-controller.
Do you want it sent to nathan@esha.com?

Regarding module support I'll start looking at StrutsUtils :)

Cheers,
Marino


-----Original Message-----
From: Nathan Bubna [mailto:nathan@esha.com] 
Sent: 23. júlí 2003 05:08
To: Velocity Developers List
Subject: Re: Struts 1.1 support

Marinó A. Jónsson said:
...
> I miss seeing a listing for Tiles and Modules in the Status doc though.
As
> I've already stated I have að working TilesTool to contribute (although it
> lacks support for put-lists).  I could also use struts modules in my
> projects ... so maybe I can lend a hand with that?

yeah, i would love it if you'd lend a hand!  i haven't used either Tiles or
Modules, and really don't know a lot about them.  any help you could give
would be fantastic. patches and contributions are more than welcome.
sometimes it feels like a one man show these days.  i'm very eager to get
more
developers involved (and hopefully some will merit becoming committers).

i've looked into Tiles a little.  Tom Czarniecki also posted a TilesTool
that
he made to the user list.  but i'm not sure how to use it or evaluate it
given
my current level of understanding.  i'd be interested to hear your thoughts
on
it and see your code too (an example of how to use it might help me
understand
:).  anyway, i've reposted his email at the bottom of this one in case you
missed it.

Nathan Bubna
nathan@esha.com

-----------------------------------------------------------------
from: tomcz@ozemail.com.au
-----------------------------------------------------------------
Hi there,
I would like to contribute my version of a tiles tool for velocity. This
tool is designed to be used as part of a velocity toolbox and provides a
simple way of accessing struts-tiles defintions to allow velocity templates
to be used in the struts-tiles framework rather than jsp pages. This tool
does not parse nested component contexts since that is not required for my
purposes but it can easily be extended.

I use this tool with the following velocimacro:
## Parse a VM template returned by a Tiles definition.
#macro(tilesParse $name)
#if( $tiles.exists($name) )
#parse( $tiles.get($name) )
#end
#end

Source code follows:
/*
 * $Id: TilesTool.java,v 1.1 2003/07/13 03:51:24 Tom Exp $
 */
package com.tomczarniecki.velocity;

import org.apache.struts.taglib.tiles.ComponentConstants;
import org.apache.struts.tiles.ComponentContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;

/**
 * TODO: add description
 *
 * @author  Tom Czarniecki
 * @version $Revision: 1.1 $
 */
public class TilesTool implements ViewTool {

    //
------------------------------------------------------------------------
    // Class variables and constants

    //
------------------------------------------------------------------------
    // Instance variables

    private ViewContext m_viewCtx;

    //
------------------------------------------------------------------------
    // Constructor(s)

    //
------------------------------------------------------------------------
    // Public methods

    public void init(Object obj) {
        if (obj instanceof ViewContext) {
            m_viewCtx = (ViewContext) obj;
        } else {
            throw new IllegalArgumentException(
                    "Tool can only be initialized with a ViewContext");
        }
    }

    public String get(String name) {
        Object ctx =
m_viewCtx.getRequest().getAttribute(ComponentConstants.COMPONENT_CONTEXT);
        if (ctx instanceof ComponentContext) {
            ComponentContext compCtx = (ComponentContext) ctx;
            Object value = compCtx.getAttribute(name);
            if (value instanceof String) {
                return (String) value;
            } else {
                Velocity.warn("Invalid ComponentContext attribute class for
key '" + name +
                        "': expected " + String.class + ", actual " +
getClassName(value));
            }
        } else {
            Velocity.warn("Invalid HttpServletRequest attribute class for
key '" +
                    ComponentConstants.COMPONENT_CONTEXT + "': expected " +
                    ComponentContext.class + ", actual " +
getClassName(ctx));
        }
        return "";
    }

    public boolean exists(String name) {
        String value = get(name);
        return (value.length() > 0);
    }

    //
------------------------------------------------------------------------
    // Private methods

    private String getClassName(Object obj) {
        return (obj != null) ? obj.getClass().getName() : "null";
    }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org


Re: Struts 1.1 support

Posted by Nathan Bubna <na...@esha.com>.
Marinó A. Jónsson said:
...
> I miss seeing a listing for Tiles and Modules in the Status doc though.  As
> I've already stated I have að working TilesTool to contribute (although it
> lacks support for put-lists).  I could also use struts modules in my
> projects ... so maybe I can lend a hand with that?

yeah, i would love it if you'd lend a hand!  i haven't used either Tiles or
Modules, and really don't know a lot about them.  any help you could give
would be fantastic. patches and contributions are more than welcome.
sometimes it feels like a one man show these days.  i'm very eager to get more
developers involved (and hopefully some will merit becoming committers).

i've looked into Tiles a little.  Tom Czarniecki also posted a TilesTool that
he made to the user list.  but i'm not sure how to use it or evaluate it given
my current level of understanding.  i'd be interested to hear your thoughts on
it and see your code too (an example of how to use it might help me understand
:).  anyway, i've reposted his email at the bottom of this one in case you
missed it.

Nathan Bubna
nathan@esha.com

-----------------------------------------------------------------
from: tomcz@ozemail.com.au
-----------------------------------------------------------------
Hi there,
I would like to contribute my version of a tiles tool for velocity. This
tool is designed to be used as part of a velocity toolbox and provides a
simple way of accessing struts-tiles defintions to allow velocity templates
to be used in the struts-tiles framework rather than jsp pages. This tool
does not parse nested component contexts since that is not required for my
purposes but it can easily be extended.

I use this tool with the following velocimacro:
## Parse a VM template returned by a Tiles definition.
#macro(tilesParse $name)
#if( $tiles.exists($name) )
#parse( $tiles.get($name) )
#end
#end

Source code follows:
/*
 * $Id: TilesTool.java,v 1.1 2003/07/13 03:51:24 Tom Exp $
 */
package com.tomczarniecki.velocity;

import org.apache.struts.taglib.tiles.ComponentConstants;
import org.apache.struts.tiles.ComponentContext;
import org.apache.velocity.app.Velocity;
import org.apache.velocity.tools.view.context.ViewContext;
import org.apache.velocity.tools.view.tools.ViewTool;

/**
 * TODO: add description
 *
 * @author  Tom Czarniecki
 * @version $Revision: 1.1 $
 */
public class TilesTool implements ViewTool {

    //
------------------------------------------------------------------------
    // Class variables and constants

    //
------------------------------------------------------------------------
    // Instance variables

    private ViewContext m_viewCtx;

    //
------------------------------------------------------------------------
    // Constructor(s)

    //
------------------------------------------------------------------------
    // Public methods

    public void init(Object obj) {
        if (obj instanceof ViewContext) {
            m_viewCtx = (ViewContext) obj;
        } else {
            throw new IllegalArgumentException(
                    "Tool can only be initialized with a ViewContext");
        }
    }

    public String get(String name) {
        Object ctx =
m_viewCtx.getRequest().getAttribute(ComponentConstants.COMPONENT_CONTEXT);
        if (ctx instanceof ComponentContext) {
            ComponentContext compCtx = (ComponentContext) ctx;
            Object value = compCtx.getAttribute(name);
            if (value instanceof String) {
                return (String) value;
            } else {
                Velocity.warn("Invalid ComponentContext attribute class for
key '" + name +
                        "': expected " + String.class + ", actual " +
getClassName(value));
            }
        } else {
            Velocity.warn("Invalid HttpServletRequest attribute class for
key '" +
                    ComponentConstants.COMPONENT_CONTEXT + "': expected " +
                    ComponentContext.class + ", actual " + getClassName(ctx));
        }
        return "";
    }

    public boolean exists(String name) {
        String value = get(name);
        return (value.length() > 0);
    }

    //
------------------------------------------------------------------------
    // Private methods

    private String getClassName(Object obj) {
        return (obj != null) ? obj.getClass().getName() : "null";
    }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org