You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Axl Rose <ax...@gmail.com> on 2005/06/25 20:07:10 UTC
TAPESTRY + VELOCITY
Hello everyone!
I have been thinking in using tapestry + velocity. I want to reduce
the code i have to write in the html tapestry=3DB4s template, i was
thinking in using velocity for that, i mean, i want to encapsulate the
tapestry code for the components tags like this:
$component.getComponent(parameters)
i mean i want to add a line like this into the tapestry template and
make a call like that to the getComponent method from a class that
encapsulates the tapestry tag for the component.
I want to do some class like this:
public class ComponentRender {
public String getComponent(TagParameters){
String str =3D3D new String();
str =3D3D "<span jwcid=3D3D"formid" ....></span>"; //here i want to use the
parameters for the tag
return str;
}
}
My questin is..., is it possible?
I=3DB4m new in both tapestry and velocity, i don=3DB4t know if it is possib=
le
Please, tell me if you know!
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: TAPESTRY + VELOCITY
Posted by Robert Zeigler <ro...@scazdl.org>.
I don't think it's impossible... just depends on how much work you want
to put into it.
The trick would probably be to do something like the following...
write your template in vtl.
Write a base component, maybe "BaseVelocityTemplateComponent" or
something.
In the renderComponent method, grab the component template, read it in
as text, then run it through a velocity context
Implement a custom ITemplateResolver (I think that's the correct
interface... something like that) that returns the parsed template
string as the template.
Delegate further rendering to the BaseComponent's renderComponent
implementation.
I'm not 100% sure what you're trying to accomplish. Personally, there
are only a couple of use cases where I'd love to be able to put in VTL.
They are pretty-much for very simple cases, like,
<h2>$someHeading</h2>
or
<div class="$dynamicClass">
Stuff like that. Anything else, and I think it would be
counterproductive. The binding abilities are pretty dang cool in
tapestry. So, something like
<input type="text" jwcid="@TextField" value="ognl:someProperty"/>
is much better than the vtl alternative
<input type='text" value="$someProperty"/>
Because the tapestry version auto-updates your property for you, whereas
with the VTL version, the value is filled into the html form, but on
form submit, you're still responsible for updating the property with the
new value.
If you can be more explicit about what it is you want to accomplish,
that might help.
Robert
Axl Rose wrote:
> Hello everyone!
>
> I have been thinking in using tapestry + velocity. I want to reduce
> the code i have to write in the html tapestry=3DB4s template, i was
> thinking in using velocity for that, i mean, i want to encapsulate the
> tapestry code for the components tags like this:
>
> $component.getComponent(parameters)
>
> i mean i want to add a line like this into the tapestry template and
> make a call like that to the getComponent method from a class that
> encapsulates the tapestry tag for the component.
>
> I want to do some class like this:
>
> public class ComponentRender {
>
> public String getComponent(TagParameters){
>
> String str =3D3D new String();
> str =3D3D "<span jwcid=3D3D"formid" ....></span>"; //here i want to use the
> parameters for the tag
> return str;
>
> }
>
> }
>
> My questin is..., is it possible?
>
> I=3DB4m new in both tapestry and velocity, i don=3DB4t know if it is possib=
> le
>
> Please, tell me if you know!
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org