You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Marc Lustig <ma...@marclustig.com> on 2002/09/25 23:10:07 UTC

how to map with multiple Peers

Hi,

another Intake-related problem: I have a form that should go into 2
different tables (Peers).
Inbetween Intake should validate the fields and on success populate the
Peer-Objects.

I understand it is possible to populate a Peer with form-fields that belong
all to this Peer by using code like this in my action method:

        IntakeTool intake = (IntakeTool) context.get("intake");
	  Group group = intake.get("KundeAnlegenGroup", IntakeTool.DEFAULT_KEY);
	  if (!group.isAllValid()) {
	  	//Log.debug("Gruppenelemente ungültig");
		setTemplate(data,"kunden,Anlegen.vm");
		return;
	  } else {
	  	Kunden k = new Kunden();
		group.setProperties(k);
		k.save();
		setTemplate(data,"kunden,Verwaltung.vm");
	  }

Q: Is it possible to populate multiple Peers automatically?
How do I assign the fields to one of those Peers?
I do have mapToObject and mapToPropterty attributes in each of the
field-elements in my group-definition in intake.xml.

but
Kunden k = new Kunden();
group.setProperties(k);

assigns all my fields to the single Peer Object.
What code to use to populate the Peer-Objects according to the
group-definition in intake.xml, so that both Peer Objects are populated
accordingly.

Regards

Marc


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: how to map with multiple Peers

Posted by Scott Eade <se...@backstagetech.com.au>.
> From: "Marc Lustig" <ma...@marclustig.com>
> 
> Q: Is it possible to populate multiple Peers automatically?
> How do I assign the fields to one of those Peers?
> I do have mapToObject and mapToPropterty attributes in each of the
> field-elements in my group-definition in intake.xml.

If the objects have nothing in common (or you want to set the things that
are in common to the same values) can you not just go:

Foo foo = new Foo();
group.setProperties(foo);
Bar bar = new Bar();
group.setProperties(bar);

You could no doubt use the individual fields and map the values manually.


HTH,

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


AW: how to map with multiple Peers

Posted by Marc Lustig <ma...@marclustig.com>.
> >Marc Lustig:
> >Q: Is it possible to populate multiple Peers automatically?
> >How do I assign the fields to one of those Peers?
>
> Use multiple groups in the form, one for each Peer entity.  Or you can
> create a Facade class that fronts the two entities.  The first
> way makes you
> have to do the isAllValid logic twice, and the second way causes
> you to have
> to manage another class.  I guess it depends which would be better.
>
> If the two entities are populated together, what keeps them from being in
> the same table to begin with?

Thanks, Chris.
Well this is a special case. It's a form for a new user entry.
I use table TURBINE_USER for the login and passwd fields only.
All the other fields I put into an app-table KUNDEN.
This is my way to extend the Turbine User on the table level.

I still need to check out if I have to extend User functionality on the
object-level. On the way...

Greetings
Marc


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: how to map with multiple Peers

Posted by Chris K Chew <ch...@fenetics.com>.
>Marc Lustig:
>Q: Is it possible to populate multiple Peers automatically?
>How do I assign the fields to one of those Peers?

Use multiple groups in the form, one for each Peer entity.  Or you can
create a Facade class that fronts the two entities.  The first way makes you
have to do the isAllValid logic twice, and the second way causes you to have
to manage another class.  I guess it depends which would be better.

If the two entities are populated together, what keeps them from being in
the same table to begin with?

Chris


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>