You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jeffery Painter <pa...@kiasoft.com> on 2003/03/21 16:07:30 UTC
complex objects in forms
I've been beating my head on this for a day now and searched through many
of the docs for the most elegant way to solve a problem I'm having.
I have a Customer object, which has many other objects tied to it. I want
to allow the screen to capture as much of the data as possible on the
initial insert screen before pushing the user to "Next screen"...
I was successful in doing New Customer, add customer object to the
context, return step 2 of adding new customer etc, but I would rather get
the bare necessities all on the first screen, allow the user to come back
and update the object as needed later on.
I read on one thread a suggestion to use castor to create a map but this
seems like double work.. I could just as easily extract each and every
form element from the RunData parameters and create the objects manually
myself, but this seems like a lot of redundant coding.
I love the simplicity of the action call
public void doInsert(RunData data, Context context)
throws Exception
{
Product entry = new Product();
data.getParameters().setProperties(entry);
entry.setNew(true);
entry.save();
}
but when Product needs to map additional data, like a color and size
matrix that I'm trying to do, this simple method doesn't seem possible to
gather on one screen.
I've been using turbine for several months now and love it but would like
any help in pointing me in the right direction to do this.
I have not tried using Intake for form validation at this point.. the app
is still in development and fields are still volital.. I don't think it
would help in this case anyway.
Kind regards,
Jeff Painter
painter@kiasoft.com
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: complex objects in forms
Posted by Chris K Chew <ch...@fenetics.com>.
> From: Colin Chalmers [mailto:colin.chalmers@maxware.nl]
>
> I've got a problem where I have to have many objects of the same
> type in one
> page.
Hey Colin.
It has been a while since I did this, but the following gives the general
idea.
1. Make sure you use get/setQueryKey() instead of .Default in your screen
template when mapping each object. This way you get field names like
"<groupkey><querykey><namekey>", ie "TheGroup142firstname" or
"TheGroup123firstname". Otherwise, the default would make every firstname
field "TheGroup_01firstname" and you would lose the all the objects in your
form but one.
2. Put a hidden string field "querykey" for each object in the form. The
value of this should be the getQueryKey() for each object in the form. Each
of these fields need to have the same name.
3. In your action, call String[] querykeys =
data.getParameters().getStrings("querykey"). This captures a list of
querykeys contained in the form.
4. Also in your action, cycle through each member in the querykeys array
calling intake.get("TheGroup", querykey) and performing your validation and
persistence for that object.
I hope this helps,
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: complex objects in forms
Posted by Colin Chalmers <co...@maxware.nl>.
On the topic of Intake :-)
I've got a problem where I have to have many objects of the same type in one
page.
Is anyone doing this and can give some tips as to how to achieve it? I need
to access the page with (mostly) default values, number of objects is
variable but of same type.
Up until now I've only had to deal with say one or a couple of differing
objects in one page. Which I've got my head round pretty well.
Colin
----- Original Message -----
From: "Chris K Chew" <ch...@fenetics.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Friday, March 21, 2003 6:20 PM
Subject: RE: complex objects in forms
> > From: Jeffery Painter [mailto:painter@kiasoft.com]
> >
> > This is it exactly... your example for Customer -> shippingAddress is
> > exactly what I'm after... our customer records can have many
> > addresses and
> > was trying to figure out a good way to seperate this out.
> >
> > It will take me a day or so to wrap my head around this methodology but
> > I'm sure it will be worth it.
> >
> > I would be willing to write up a some documentation of my experience
> > combined with the facade technique to add to the turbine docs
> > when I'm finished.
>
> Hi Jeff.
>
> Yeah, we use the facade trick all the time.
>
> Unbelievably, I didn't have a section for this on the Wiki User's Guide
> Outline. I just added one in the Intake section, hopefully you will add
> your knowledge as you progress:
>
> http://nagoya.apache.org/wiki/apachewiki.cgi?JakartaTurbine2UsersGuide
>
> Thanks,
>
> Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: complex objects in forms
Posted by Chris K Chew <ch...@fenetics.com>.
> From: Jeffery Painter [mailto:painter@kiasoft.com]
>
> This is it exactly... your example for Customer -> shippingAddress is
> exactly what I'm after... our customer records can have many
> addresses and
> was trying to figure out a good way to seperate this out.
>
> It will take me a day or so to wrap my head around this methodology but
> I'm sure it will be worth it.
>
> I would be willing to write up a some documentation of my experience
> combined with the facade technique to add to the turbine docs
> when I'm finished.
Hi Jeff.
Yeah, we use the facade trick all the time.
Unbelievably, I didn't have a section for this on the Wiki User's Guide
Outline. I just added one in the Intake section, hopefully you will add
your knowledge as you progress:
http://nagoya.apache.org/wiki/apachewiki.cgi?JakartaTurbine2UsersGuide
Thanks,
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: complex objects in forms
Posted by Jeffery Painter <pa...@kiasoft.com>.
This is it exactly... your example for Customer -> shippingAddress is
exactly what I'm after... our customer records can have many addresses and
was trying to figure out a good way to seperate this out.
It will take me a day or so to wrap my head around this methodology but
I'm sure it will be worth it.
I would be willing to write up a some documentation of my experience
combined with the facade technique to add to the turbine docs when I'm finished.
Thanks
Jeff Painter
painter@kiasoft.com
On Fri, 21 Mar 2003, Chris K Chew wrote:
> Hi Jeff.
>
> It sounds like Intake will work well for the situation.
>
> One trick that we use often is to create a complex Facade class to which
> intake maps. You can store the facade object in user.setTemp() through a
> wizard, or have a big form that maps to the Facade, which maps to your
> target objects. Search turbine-user for the thread "intake: mapping the
> group against 2 objects possible?" on 02/19/2003 for a bigger explanation.
>
> Good luck,
>
> Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: complex objects in forms
Posted by Chris K Chew <ch...@fenetics.com>.
Hi Jeff.
It sounds like Intake will work well for the situation.
One trick that we use often is to create a complex Facade class to which
intake maps. You can store the facade object in user.setTemp() through a
wizard, or have a big form that maps to the Facade, which maps to your
target objects. Search turbine-user for the thread "intake: mapping the
group against 2 objects possible?" on 02/19/2003 for a bigger explanation.
Good luck,
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: complex objects in forms
Posted by Jeffery Painter <pa...@kiasoft.com>.
well, maybe intake is the solution :) pardon my ranting... I'll see if it
does the trick for me.
Jeff
On Fri, 21 Mar 2003, Jeffery Painter wrote:
>
> I've been beating my head on this for a day now and searched through many
> of the docs for the most elegant way to solve a problem I'm having.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org