tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Howard Lewis Ship <hls...@gmail.com>
Subject Re: How to instantiate components in code
Date Sun, 12 Dec 2004 19:02:29 GMT
So, you want the type of editor to be conditional based on a parameter
of your component?

Remember that Tapestry pages are shared, they must be equally useful
to all potential users. It would be silly for user A's submission of a
text field to fail because user B just was editting a field that
required a drop down list.

Page pooling, and the lack of flexibility you get, is a consequence of
the need for Efficiency (along with Simplicity, Consistency,  and
Feedback) as a driving principal of Tapestry.

Conditionals are a valid approach.  Alternately, surround each element
with a Block and choose the correct block dynamically.  Or, put all
the components in an anonymous Block and simply select one of those
components to render dynamically.

On Sun, 12 Dec 2004 08:45:26 -0800 (PST), Chris Nelson
<cnelson4eii@yahoo.com> wrote:
> Apologize if I should be asking this on the users list
> first, but it didn't seem like this had been answered
> there.
> I am making good progress with Trails, but ran into
> something I just can't figure out how to do easily in
> Tapestry.  I have a component called ProperttyEditor
> that renders a form input component for a bean
> property based on the property's type (and other
> information contained in it's PropertyDescriptor).
> Right now, it uses a big nasty set of Conditionals
> like so:
>     <td jwcid="isIdentifier" element="td">
>         <span jwcid="identifier" />
>     </td>
>     <td jwcid="isDate" element="td">
>         <input jwcid="dateField" />
>     </td>
>     <td jwcid="isNumeric" element="td">
>         <input jwcid="numberField" />
>     </td>
>     <td jwcid="isString" element="td">
>         <input jwcid="stringField"  />
>     </td>
>     <td jwcid="isObject" element="td">
>         <span jwcid="selectObject"  />
>     </td>
>     <td jwcid="isCollection" element="td">
>         <span jwcid="collectionEditor"  />
>     </td>
> Yuck, right?  Well, what I'd rather do is have some
> sort of factory that spits out the correct component.
> As well as cleaning up this code, it would let me do
> cool things like being able to have the PropertyEditor
> class from the PropertyDescriptor be a Tapestry
> component and just instatiate it.
> However, instantiating components in code does not
> seem very easy.  Am I missing something?  Can someone
> point me at a way to do this?  A code example perhaps?
> Is this something that will be way easier in 3.1, and
> if so, is 3.1 in a state where I should be thinking
> about moving to it?
> Thanks in advance,
> Chris Nelson
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
> http://mobile.yahoo.com/maildemo
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org

Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

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

View raw message