I don't know that I used anything in particular; I just ended up
gluing stuff together that I already had. The key thing is to realize that
your component has to do two completely different things.

        During the render pass, it has to pull data *out* of the bean and
use it to output widgets to the responseoutputstream. You also need to set
each widget with a unique, and repeatable, ID so you can get it back later.
I use EDIT.<FieldName>

        During the rewind pass, it has to pluck data out of the HTTPRequest
via:

        String key = "EDIT." + fieldname;
        String value = cycle.getRequestContext().getParameter(key);

        Then you have to data-type convert the value (which always comes
back from HTTP as a string) to the appropriate value type for your bean e.g.
if the field is an integer and your value is "14" you need to change it to
an Integer Object.

        I have some old custom code I use to do these sorts of bean-setting
conversions. You might check out Apache Commons BeanUtils though, I think
they offer similar functionality in a friendlier and self-contained package.

        --- Pat

> -----Original Message-----
> From: Todd Orr [mailto:[EMAIL PROTECTED]
> Sent: Sunday, October 09, 2005 8:00 AM
> To: Tapestry users
> Subject: Re: Dynamic Web Forms
> 
> That's a shame. I was hoping that Tapestry would have some native
> solution.
> At least I'll be able to wrap it in a component. Otherwise, I will not get
> approval to introduce Tapestry into our code base.
> 
> Thanks for your help. Could you please point me to any resources you used
> in
> building this solution. I'm still learning a lot about Tapestry, and will
> probably need a crutch or two.
> 
> Thanks
> 
> On 10/8/05, Patrick Casey <[EMAIL PROTECTED]> wrote:
> >
> >
> > Tom,
> >
> > I solved a problem similar to what you're describing, but I had to
> > do an end-run around Tapestry to do it. Basically I've got a
> > "dynamicblock"
> > component that takes as its input a java bean and a list of field names.
> > It
> > then uses existing metadata and introspection to sort out the proper
> > widgets
> > for each field you want displayed.
> >
> > Then it writes out the widgets using good, old fashioned, java and
> > sets their ids manually (they're not tapestry widgets). On the rewind, I
> > then pull the widget's back out of the servletrequest by their IDs and
> use
> > some old code of mine to set the bean's fields by name.
> >
> > It all works just fine for me, but it's basically an end-run around
> > Tapestry.
> >
> > --- Pat
> >
> > > -----Original Message-----
> > > From: news [mailto:[EMAIL PROTECTED] On Behalf Of tom
> > > Sent: Saturday, October 08, 2005 8:23 AM
> > > To: [email protected]
> > > Subject: Re: Dynamic Web Forms
> > >
> > > Thanks for the quick reply. I believe this will help. However, a
> larger
> > > problem
> > > seems to be conditional display and validation. Is there a way to
> > specify
> > > conditional behavior? What I mean is that suppose I have queried my db
> > for
> > > the
> > > questions to display on the form and I get back something like:
> > >
> > > ID Text Type DataType
> > > 123 How many widgets do you want? TextField Numeric
> > > 124 What's your favorite widget color? TextField String
> > > 125 Do you ski? Checkbox Boolean
> > >
> > > I will then package this data into some kind of collection of objects
> > and
> > > make
> > > this available to my Tapestry page.
> > >
> > > I see that it is possible to display these form elements. Is it
> possible
> > > to show
> > > different types of form elements based on the Type? Furthermore, is it
> > > possible
> > > to use the Tapestry validation mechanism that is appropriate for a
> > > DataType
> > > conditionally based on the DataType returned?
> > >
> > > I know how this type of situation is handled in CF. It usually
> requires
> > a
> > > lot of
> > > hand coding of html and if-thens in a loop. Tapestry is much more
> > elegant
> > > in how
> > > it handles Web forms, etc. so I am hoping that there is an equally
> > elegant
> > > solution for my problem.
> > >
> > > Forgive me for asking so many questions. I do not see any type of
> > article
> > > anywhere on the internet even slightly similar to my query. I very
> much
> > > appreciate the insights of the users on this list.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to