tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Nelson <cnelson4...@yahoo.com>
Subject How to instantiate components in code
Date Sun, 12 Dec 2004 16:45:26 GMT
Apologize if I should be asking this on the users list
first, but it didn't seem like this had been answered

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 jwcid="isDate" element="td">
    	<input jwcid="dateField" />
    <td jwcid="isNumeric" element="td">
        <input jwcid="numberField" />
    <td jwcid="isString" element="td">
        <input jwcid="stringField"  />
    <td jwcid="isObject" element="td">
    	<span jwcid="selectObject"  />
    <td jwcid="isCollection" element="td">
    	<span jwcid="collectionEditor"  />

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. 

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

View raw message