You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nathan Kopp <nk...@mailshell.com> on 2005/03/17 04:27:03 UTC

two personal Tapestry modifications

Converting my struts pages to tapestry pages was getting a little tedious,
so I grabbed the 3.0.2 source from CVS and tweaked two things.

1) If a component is duplicated in the HTML file, tapestry will
automatically clone the component (kind of a blend between copy-of and an
implicit component) instead of throwing an exception.  I noticed that HLS
commented on a Wiki somewhere that this might be the standard behavior of
Tapestry 3.1.  I haven't personally tried 3.1 yet to see if this is true.

2) I added a shorthand notation for the implicit (anonymous) "Insert"
component.  Borrowing syntax from JSP2.0, JSTL, Velocity, and Freemarker,
the shortcut takes the form: "${ognl:your.ognl.expression.goes.here}".  This
has the same effect as "<span jwcid="@Insert"
value="ognl:your.ognl.expression.goes.here"/>".  (In fact, internally it
expands out the shorthand form into a "span" token.)  The "ognl:" can be
replaced with other expression type prefixes, and is optional.  If the
expression prefix is not specified, "ognl:" is assumed.

Tweak #2 was actually quite easy to create, and didn't affect much code.
Tweak #1 was a bit more difficult, and involved adding a "type" property to
the ComponentSpecification bean (and corresponding interface).  I can
probably make diffs if anyone wants to look at them.

I'm wondering what others of you think about these tweaks, especially the
second one (shorthand Insert component).  I realize that this makes the
tapestry syntax slightly resemble various scripting languages (I'm NOT
trying to start a philosophical scripting-vs-component debate), and it might
not be as useful for mocking up pages in some circumstances (since you don't
have the dummy text which will be replaced, and the OGNL code is visible in
the mocked-up page).  Still, when hand-coding pages, it can save a
significant amout of typing (or copy/pasting).

My motivation was that, when I started converting my JSP2.0 pages over to
Tapestry, I realized that tapestry's implicit "@Insert" component was
reminding me much of the bean property JSP tags from the pre-JSP-EL days.  I
was rather happy when JSP 2.0 introduced the expression language, and I
couldn't imagine using something that reminded me of those old JSP tags.

Comments?

-Nathan


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


Re: two personal Tapestry modifications

Posted by Vjeran Marcinko <vj...@tis.hr>.
----- Original Message ----- 
From: "Nathan Kopp" <nk...@mailshell.com>
To: <ta...@jakarta.apache.org>
Sent: Thursday, March 17, 2005 4:27 AM
Subject: two personal Tapestry modifications


> 2) I added a shorthand notation for the implicit (anonymous) "Insert"
> component.  Borrowing syntax from JSP2.0, JSTL, Velocity, and Freemarker,
> the shortcut takes the form: "${ognl:your.ognl.expression.goes.here}".
This
> has the same effect as "<span jwcid="@Insert"
> value="ognl:your.ognl.expression.goes.here"/>".  (In fact, internally it
> expands out the shorthand form into a "span" token.)  The "ognl:" can be
> replaced with other expression type prefixes, and is optional.  If the
> expression prefix is not specified, "ognl:" is assumed.
>
> I'm wondering what others of you think about these tweaks, especially the
> second one (shorthand Insert component).  I realize that this makes the
> tapestry syntax slightly resemble various scripting languages (I'm NOT
> trying to start a philosophical scripting-vs-component debate), and it
might
> not be as useful for mocking up pages in some circumstances (since you
don't
> have the dummy text which will be replaced, and the OGNL code is visible
in
> the mocked-up page).  Still, when hand-coding pages, it can save a
> significant amout of typing (or copy/pasting).

Personally, I like it the way it is now (@Insert). I know that is requires a
bit more typing, but this is Tapestry way, and therefore fully consistent
with all other components. IMO, it would only confuse few more people out
there. And as I can see, you are also aware of mocking-up issue.

-Vjeran



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 15.3.2005


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


Re: two personal Tapestry modifications

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Mar 16, 2005, at 10:27 PM, Nathan Kopp wrote:
> 2) I added a shorthand notation for the implicit (anonymous) "Insert"
> component.  Borrowing syntax from JSP2.0, JSTL, Velocity, and 
> Freemarker,
> the shortcut takes the form: "${ognl:your.ognl.expression.goes.here}". 
>  This
> has the same effect as "<span jwcid="@Insert"
> value="ognl:your.ognl.expression.goes.here"/>".  (In fact, internally 
> it
> expands out the shorthand form into a "span" token.)  The "ognl:" can 
> be
> replaced with other expression type prefixes, and is optional.  If the
> expression prefix is not specified, "ognl:" is assumed.

I like this one!

Purists that mandate that the specification and template should be 
completely separate will disagree, but in my applications and 
environment I mostly stick with the informal components in the 
template.

> I'm wondering what others of you think about these tweaks, especially 
> the
> second one (shorthand Insert component).  I realize that this makes the
> tapestry syntax slightly resemble various scripting languages (I'm NOT
> trying to start a philosophical scripting-vs-component debate), and it 
> might
> not be as useful for mocking up pages in some circumstances (since you 
> don't
> have the dummy text which will be replaced, and the OGNL code is 
> visible in
> the mocked-up page).

I don't mind seeing expressions in the mock-ups.

> My motivation was that, when I started converting my JSP2.0 pages over 
> to
> Tapestry, I realized that tapestry's implicit "@Insert" component was
> reminding me much of the bean property JSP tags from the pre-JSP-EL 
> days.  I
> was rather happy when JSP 2.0 introduced the expression language, and I
> couldn't imagine using something that reminded me of those old JSP 
> tags.
>
> Comments?

However, on my last big project, we started using @Insert (though 
formally with jwcid="someName").  Later we needed to add formatting 
across the board for objects that were dates, times, and currency.  It 
was trivial to write a custom @Write component that wrapped @Insert 
with a tiny bit of conversion in a .java file for certain object types. 
  All we had to do was replace our use of Insert with Write everywhere.  
With this even more informal syntax, it would make this sort of 
transformation more difficult.

I still like it.

	Erik


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