You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ma...@bmw.ch on 2007/01/03 09:15:26 UTC

RE: CamelCase page names/URLs in Tapestry

> In AppFuse 2.0, we're requiring JDK 5 and using annotations 
> where it seems appropriate.  AFAIK, we can eliminate .page 
> files if we use annotations instead.  Is that true?  If so, 

Yes that's true.

> how do you define how a @TextField works (displayName, 
> validation rules, etc.)?  Do you use annotations on your 
> model object?  A link to documentation or an example would be great.

Have a look at
http://tapestry.apache.org/tapestry4.1/tapestry-annotations/index.html

Generally, you can push what used to be in the .page (or .jwc) file into
either annotations or the template or both. So, you can either write

@Component( id="myTextField", type="TextField",
			    bindings={"displayName=blubberDi"} )
	public abstract IComponent getMyTextField();


in your page-class (which I'd prefer to categorize as controller rather
than model).
Or you could write:

<input jwcid="myTextField@TextField" displayName="blubberDi" />

You can mix as you like. My rule is to put things in the Java-Class if
and only if I actually use the annotated element (getter) in my code. Of
course, there are valid reasons to put more into the class (e.g., if you
want to hand the template to web-designers, you'll want them to only
contain jwcid's)

hth,
Marcus

> 
> Matt
> 
> 
> Schulte Marcus wrote:
> > 
> > You'd have to map between .page- and template-file-name and 
> the Java 
> > class name if you don't want to break the convention for Java class 
> > names.
> > 
> > Since Tap-4 I don't have .page files anymore. So non-CamelCase page 
> > names would simply not be an option for me - even if I found them 
> > aesthetically more pleasing (which I'm not)
> > 
> > Marcus
> > 
> >> -----Original Message-----
> >> From: mraible [mailto:matt@raibledesigns.com]
> >> Sent: Friday, December 29, 2006 6:11 AM
> >> To: users@tapestry.apache.org
> >> Subject: CamelCase page names/URLs in Tapestry
> >> 
> >> 
> >> Are CamelCase page names and URLs the standard with Tapestry 
> >> applications?
> >> I'm used to doing more lowercase things, for example:
> >> 
> >> http://server/app/userList.html
> >> 
> >> I'm even starting to warm up to doing things all lowercase:
> >> 
> >> http://server/app/userlist.html
> >> 
> >> However, according to HLS, CamelCase is the recommended (and
> >> preferred) way of doing things w/in the Tapestry community.
> >> 
> >> http://server/app/UserList.html
> >> 
> >> Is that true?  This seems odd to me.  I can understand 
> that using an 
> >> uppercase first letter makes everything match, but it leads to 
> >> non-standard URLs, no? I guess Tapestry has never been too keen on 
> >> pretty URLs, so maybe this isn't an issue for most users?
> >> 
> >> Background:
> >> ----------------------
> >> Howard did a thorough review of the Tapestry code in 
> AppFuse about 6 
> >> months ago.  He sent me a private e-mail, which I posted as a JIRA 
> >> issue:
> >> 
> >> http://issues.appfuse.org/browse/APF-404
> >> 
> >> We've since broken up this issue into several subtasks, 
> and the one 
> >> I'm referring to in particular can be found at:
> >> 
> >> http://issues.appfuse.org/browse/APF-499
> >> 
> >> <description>
> >> In Tapestry, the established convention is that page names are 
> >> CamelCase.
> >> Further, the XML specification (.page file), HTML template 
> and Java 
> >> class should all be named the same. Likewise for components.
> >> </description>
> >> 
> >> If UserList.html is the preferred standard among Tapestry users, 
> >> we'll follow it - I just want to make sure that Howard and the 
> >> community agree on this one.
> >> 
> >> Thanks,
> >> 
> >> Matt
> >> --
> >> View this message in context: 
> >> http://www.nabble.com/CamelCase-page-names-URLs-in-Tapestry-tf
> >> 2893433.html#a8083998
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >> 
> >> 
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> 
> >> 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> > 
> 
> --
> View this message in context: 
> http://www.nabble.com/CamelCase-page-names-URLs-in-Tapestry-tf
> 2893433.html#a8093597
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 

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


Re: CamelCase page names/URLs in Tapestry

Posted by Howard Lewis Ship <hl...@gmail.com>.
I know I have one potential client, The Name Withheld Corporation, that's
interested in Tapestry but needs the URLs to be case-insensitive.

Back in the Tapestry 2.x days, this wouldn't be so difficult.  You started
with the application specification, which matched each possible page name to
a specification path.  The specification explicitly listed the Java
class.    Making that pipeline case-insensitive is easy as cake.

However, with Tapestry 3 and 4, things got more complex.  More of the time,
Tapestry was "discoverring" a Tapestry page on the fly:  a request comes in,
a page name is in the URL somewhere, Tapestry hunts around for the .page
file, and works from there to the .html and the Java class.  In most cases
you needed the exact file name, including case.

The issue is that the Servlet API (especially the earlier ones) didn't give
you much of a chance to figure these things out.  Likewise, ClassLoader
doesn't let you search with a filter, you can simply check if some known
name actually exists.

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getResourcePaths(java.lang.String)
was added in 2.3 and we'll see.  That would allow us to scan the
WEB-INF/classes folder (or sub folders), which would be a start. I wish
there was something like that on ClassLoader or event URLClassLoader.

I don't want to start down the path of putting in any container or even JDK
dependencies.  Quite a pickle. I have some ideas.


On 1/3/07, Marcus.Schulte@bmw.ch <Ma...@bmw.ch> wrote:
>
> > In AppFuse 2.0, we're requiring JDK 5 and using annotations
> > where it seems appropriate.  AFAIK, we can eliminate .page
> > files if we use annotations instead.  Is that true?  If so,
>
> Yes that's true.
>
> > how do you define how a @TextField works (displayName,
> > validation rules, etc.)?  Do you use annotations on your
> > model object?  A link to documentation or an example would be great.
>
> Have a look at
> http://tapestry.apache.org/tapestry4.1/tapestry-annotations/index.html
>
> Generally, you can push what used to be in the .page (or .jwc) file into
> either annotations or the template or both. So, you can either write
>
> @Component( id="myTextField", type="TextField",
>                             bindings={"displayName=blubberDi"} )
>         public abstract IComponent getMyTextField();
>
>
> in your page-class (which I'd prefer to categorize as controller rather
> than model).
> Or you could write:
>
> <input jwcid="myTextField@TextField" displayName="blubberDi" />
>
> You can mix as you like. My rule is to put things in the Java-Class if
> and only if I actually use the annotated element (getter) in my code. Of
> course, there are valid reasons to put more into the class (e.g., if you
> want to hand the template to web-designers, you'll want them to only
> contain jwcid's)
>
> hth,
> Marcus
>
> >
> > Matt
> >
> >
> > Schulte Marcus wrote:
> > >
> > > You'd have to map between .page- and template-file-name and
> > the Java
> > > class name if you don't want to break the convention for Java class
> > > names.
> > >
> > > Since Tap-4 I don't have .page files anymore. So non-CamelCase page
> > > names would simply not be an option for me - even if I found them
> > > aesthetically more pleasing (which I'm not)
> > >
> > > Marcus
> > >
> > >> -----Original Message-----
> > >> From: mraible [mailto:matt@raibledesigns.com]
> > >> Sent: Friday, December 29, 2006 6:11 AM
> > >> To: users@tapestry.apache.org
> > >> Subject: CamelCase page names/URLs in Tapestry
> > >>
> > >>
> > >> Are CamelCase page names and URLs the standard with Tapestry
> > >> applications?
> > >> I'm used to doing more lowercase things, for example:
> > >>
> > >> http://server/app/userList.html
> > >>
> > >> I'm even starting to warm up to doing things all lowercase:
> > >>
> > >> http://server/app/userlist.html
> > >>
> > >> However, according to HLS, CamelCase is the recommended (and
> > >> preferred) way of doing things w/in the Tapestry community.
> > >>
> > >> http://server/app/UserList.html
> > >>
> > >> Is that true?  This seems odd to me.  I can understand
> > that using an
> > >> uppercase first letter makes everything match, but it leads to
> > >> non-standard URLs, no? I guess Tapestry has never been too keen on
> > >> pretty URLs, so maybe this isn't an issue for most users?
> > >>
> > >> Background:
> > >> ----------------------
> > >> Howard did a thorough review of the Tapestry code in
> > AppFuse about 6
> > >> months ago.  He sent me a private e-mail, which I posted as a JIRA
> > >> issue:
> > >>
> > >> http://issues.appfuse.org/browse/APF-404
> > >>
> > >> We've since broken up this issue into several subtasks,
> > and the one
> > >> I'm referring to in particular can be found at:
> > >>
> > >> http://issues.appfuse.org/browse/APF-499
> > >>
> > >> <description>
> > >> In Tapestry, the established convention is that page names are
> > >> CamelCase.
> > >> Further, the XML specification (.page file), HTML template
> > and Java
> > >> class should all be named the same. Likewise for components.
> > >> </description>
> > >>
> > >> If UserList.html is the preferred standard among Tapestry users,
> > >> we'll follow it - I just want to make sure that Howard and the
> > >> community agree on this one.
> > >>
> > >> Thanks,
> > >>
> > >> Matt
> > >> --
> > >> View this message in context:
> > >> http://www.nabble.com/CamelCase-page-names-URLs-in-Tapestry-tf
> > >> 2893433.html#a8083998
> > >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> > >>
> > >>
> > >>
> > ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > >> For additional commands, e-mail: users-help@tapestry.apache.org
> > >>
> > >>
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> > >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/CamelCase-page-names-URLs-in-Tapestry-tf
> > 2893433.html#a8093597
> > Sent from the Tapestry - User mailing list archive at Nabble.com.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com