You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by JIM WEAVER <we...@gmail.com> on 2005/06/09 02:53:58 UTC

Form Component Development

Hi,

For our tapestry project we developed a DateField component that
renders as three form elements (a droplist for month and day (1-31),
and a text field for year).  The component maps this to a
java,util.date as an auto parameter.

This component is an AbstractComponent, and *incluces* three tapestry
form components in it's html/jwc.  So we used composition rather than
inheritance.  The DateField component contains form components rather
than "being" a form component.

This differs from a similar example (credit card field) in the
tapestry book, where the component inherits from
AbstractFormComponent.  In that example, html for the various fields
is rendered from java code, which we didn't like the looks of at all
(smelled more like JSFs approach).

Wouldn't the example in the book have been possible / cleaner using composition?

Also, I don't see much treatment of inhertance for components in the
book.  I know I can inherit the classes, but what about properties
specified in the JWC?  Those would need to be duplicated by the
subclass?   Apologies - we are pretty new - this is our first tapestry
project.

Jim W.

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


Re: Form Component Development

Posted by Robert Zeigler <ro...@scazdl.org>.
JIM WEAVER wrote:
> Hi,
> 
> For our tapestry project we developed a DateField component that
> renders as three form elements (a droplist for month and day (1-31),
> and a text field for year).  The component maps this to a
> java,util.date as an auto parameter.
> 
> This component is an AbstractComponent, and *incluces* three tapestry
> form components in it's html/jwc.  So we used composition rather than
> inheritance.  The DateField component contains form components rather
> than "being" a form component.
> 
> This differs from a similar example (credit card field) in the
> tapestry book, where the component inherits from
> AbstractFormComponent.  In that example, html for the various fields
> is rendered from java code, which we didn't like the looks of at all
> (smelled more like JSFs approach).
> 
> Wouldn't the example in the book have been possible / cleaner using composition?

There's a time and a place for both, depending on the needs. I
frequently use composition to accomplish what I want; that's the point
of components, right? :)
On the other hand, there are occasionally components where "special"
behavior may be required, and so rendering in java and inheriting from
abstractformcomponent may work better.  For example, when I put together
a component that prompts a user for a value, optionally submits the form
it's in, and also allows a listener to be specified... there probably
was /some/ way I could have used composition to do this (actually... I
can think of some ways right off the top of my head now), but, the
inheritance track was actually more straightforward, cleaner, and easier
to understand.

> 
> Also, I don't see much treatment of inhertance for components in the
> book.  I know I can inherit the classes, but what about properties
> specified in the JWC?  Those would need to be duplicated by the
> subclass?   Apologies - we are pretty new - this is our first tapestry
> project.

That is correct; your "sub" component would have to redefine any
properties and/or parameters defined in the .jwc of the "parent" component.

Robert

> 
> Jim W.
> 
> ---------------------------------------------------------------------
> 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