You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by J Kary <jk...@yahoo.com> on 2001/09/27 19:54:56 UTC

Intake mapToObject field?

Hi,

I've been reading through the Intake docs and I was wondering about the
'mapToObject' attribute.  

1) When mapping a group to an object do all the fields have to map to
that object?

2) If so, then I guess the mapToProperty for a field is only good for
mapping a form name to _different_ object field name.  If the attribute
is not there, then the field name is assumed to be the property name.
(Correct?)

I think I may have misunderstood the document as allowing you to
specifically select where fields in the group would map to the group's
object.  

Can someone confirm this?
Take Care
Jason Kary


__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com

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


Re: Intake mapToObject field?

Posted by John McNally <jm...@collab.net>.
Jason Kary wrote:
> 
> Hi Jon,
> 
> Thanks for replying so quickly!
> 
> >> 2) If so, then I guess the mapToProperty for a field is only good for
> >> mapping a form name to _different_ object field name.  If the attribute
> >> is not there, then the field name is assumed to be the property name.
> >> (Correct?)
> >
> >
> > No mapToProperty is more like an alias. Example:
> >
> >  <field name="Name" key="name" type="String">
> >  </field>
> >
> >  <field name="NewName" key="newname" type="String"
> >                mapToProperty="Name">
> >  </field>
> >
> > That would map NewName to the set/getName() method in the Bean.
> 
> Ok.  So in the bean if we had the code:
> 
> Intake intake = (IntakeTool)context.get( "intake" );
> Group grp = intake.get( "NewRep", IntakeTool.DEFAULT_KEY );
> NewRep rep = new NewRep();
> 
> grp.setProperties( rep );
> 
> ...
> 
> Would there be a race condition for the name field? Would both field
> records set the name value?
> 
> Take Care
> Jason Kary
> 

There is nothing wrong with defining multiple fields that map to the
same property, but I would suspect that using them both in the same form
would be.  Why would you be trying to set the same property using two
different form fields?

john mcnally

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


Re: Intake mapToObject field?

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 12:13 PM, "Jason Kary" <jk...@cisco.com> wrote:

> Ok.  So in the bean if we had the code:
> 
> Intake intake = (IntakeTool)context.get( "intake" );
> Group grp = intake.get( "NewRep", IntakeTool.DEFAULT_KEY );
> NewRep rep = new NewRep();
> 
> grp.setProperties( rep );
> 
> ...
> 
> Would there be a race condition for the name field? Would both field
> records set the name value?
> 
> Take Care
> Jason Kary

In a bean, you should not reference Intake. Intake should be considered
"external" to the bean. You use intake to set the fields of a bean.

-jon


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


Re: Intake mapToObject field?

Posted by Jason Kary <jk...@cisco.com>.
Hi Jon,

Thanks for replying so quickly!

>> 2) If so, then I guess the mapToProperty for a field is only good for
>> mapping a form name to _different_ object field name.  If the attribute
>> is not there, then the field name is assumed to be the property name.
>> (Correct?)
> 
> 
> No mapToProperty is more like an alias. Example:
> 
>  <field name="Name" key="name" type="String">
>  </field>
> 
>  <field name="NewName" key="newname" type="String"
>                mapToProperty="Name">
>  </field>
> 
> That would map NewName to the set/getName() method in the Bean.


Ok.  So in the bean if we had the code:

Intake intake = (IntakeTool)context.get( "intake" );
Group grp = intake.get( "NewRep", IntakeTool.DEFAULT_KEY );
NewRep rep = new NewRep();

grp.setProperties( rep );

...

Would there be a race condition for the name field? Would both field 
records set the name value?

Take Care
Jason Kary


> 
>> I think I may have misunderstood the document as allowing you to
>> specifically select where fields in the group would map to the group's
>> object.  
> 
> 
> I don't think I understand what you are misunderstanding.
> 
> Essentially, the intake .xml file allows you to map specific Fields to an
> Object's methods with the addition of being able to also create aliases
> using the mapToProperty attribute.
> 
> 
> -jon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> 



Re: Intake mapToObject field?

Posted by Jason Kary <jk...@cisco.com>.
Jon and John,

I _think_ I understand what you guys are saying.  I've put together an 
example document which I will attach to this email.  Can you please tell 
me if Iam on the right track?


I am still fuzzy about the aliasing part of the intake specification.  
If you alias a field "NewLogin" to make too "Login" using the 
mapToObject attribute, then is it the case you will have the property 
'Login' set twice???

Take Care.
Jason Kary

Jon Stevens wrote:

> on 9/27/01 12:25 PM, "John McNally" <jm...@collab.net> wrote:
> 
>> Jon Stevens wrote:
>> 
>>> on 9/27/01 10:54 AM, "J Kary" <jk...@yahoo.com> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I've been reading through the Intake docs and I was wondering about the
>>>> 'mapToObject' attribute.
>>>> 
>>>> 1) When mapping a group to an object do all the fields have to map to
>>>> that object?
>>> 
>>> Yes. (keep reading)
>>> 
>> No.  The mapToObject attribute on <group> sets the default object for
>> all the fields in the group.  There is a mapToObject attribute on
>> <field> that can be used instead of or to override the one in group.  If
>> a particular field does not map to an object's property but you have
>> defined a default mapToObject for the group, you can turn off the
>> default behavior of assuming that object contains a property matching
>> the field name by using <field mapToProperty=""...
>> 
>> Using multiple objects per group is possible though not tested and there
>> may be some inconsistencies, as the behavior has not been completely
>> defined.
> 
> 
> John and I sit next to each other so we talked about this...
> 
> He says no, I say yes. Things are confusing. So, let me clarify:
> 
> All bean fields MUST map to intake fields within an intake group UNLESS you
> define the mapToProperty attribute within the intake field to map to a bean
> field. HOWEVER, you can set the mapToProperty="" which will allow you to not
> have the bean field and not get an error message in the log file.
> 
> I know it is confusing. I hope it makes more sense now.
> 
> -jon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
> 



Re: Intake mapToObject field?

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 12:25 PM, "John McNally" <jm...@collab.net> wrote:

> Jon Stevens wrote:
>> 
>> on 9/27/01 10:54 AM, "J Kary" <jk...@yahoo.com> wrote:
>> 
>>> Hi,
>>> 
>>> I've been reading through the Intake docs and I was wondering about the
>>> 'mapToObject' attribute.
>>> 
>>> 1) When mapping a group to an object do all the fields have to map to
>>> that object?
>> 
>> Yes. (keep reading)
>> 
> No.  The mapToObject attribute on <group> sets the default object for
> all the fields in the group.  There is a mapToObject attribute on
> <field> that can be used instead of or to override the one in group.  If
> a particular field does not map to an object's property but you have
> defined a default mapToObject for the group, you can turn off the
> default behavior of assuming that object contains a property matching
> the field name by using <field mapToProperty=""...
> 
> Using multiple objects per group is possible though not tested and there
> may be some inconsistencies, as the behavior has not been completely
> defined.

John and I sit next to each other so we talked about this...

He says no, I say yes. Things are confusing. So, let me clarify:

All bean fields MUST map to intake fields within an intake group UNLESS you
define the mapToProperty attribute within the intake field to map to a bean
field. HOWEVER, you can set the mapToProperty="" which will allow you to not
have the bean field and not get an error message in the log file.

I know it is confusing. I hope it makes more sense now.

-jon


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


Re: Intake mapToObject field?

Posted by John McNally <jm...@collab.net>.
Jon Stevens wrote:
> 
> on 9/27/01 10:54 AM, "J Kary" <jk...@yahoo.com> wrote:
> 
> > Hi,
> >
> > I've been reading through the Intake docs and I was wondering about the
> > 'mapToObject' attribute.
> >
> > 1) When mapping a group to an object do all the fields have to map to
> > that object?
> 
> Yes. (keep reading)
> 

No.  The mapToObject attribute on <group> sets the default object for
all the fields in the group.  There is a mapToObject attribute on
<field> that can be used instead of or to override the one in group.  If
a particular field does not map to an object's property but you have
defined a default mapToObject for the group, you can turn off the
default behavior of assuming that object contains a property matching
the field name by using <field mapToProperty=""...

Using multiple objects per group is possible though not tested and there
may be some inconsistencies, as the behavior has not been completely
defined.

> > 2) If so, then I guess the mapToProperty for a field is only good for
> > mapping a form name to _different_ object field name.  If the attribute
> > is not there, then the field name is assumed to be the property name.
> > (Correct?)
> 
> No mapToProperty is more like an alias. Example:

What Jason says above sounds right to me, though your description of the
behavior below is also correct.

john mcnally

> 
>  <field name="Name" key="name" type="String">
>  </field>
> 
>  <field name="NewName" key="newname" type="String"
>                mapToProperty="Name">
>  </field>
> 
> That would map NewName to the set/getName() method in the Bean.
> 
> > I think I may have misunderstood the document as allowing you to
> > specifically select where fields in the group would map to the group's
> > object.
> 
> I don't think I understand what you are misunderstanding.
> 
> Essentially, the intake .xml file allows you to map specific Fields to an
> Object's methods with the addition of being able to also create aliases
> using the mapToProperty attribute.
> 
> -jon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

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


Re: Intake mapToObject field?

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/27/01 10:54 AM, "J Kary" <jk...@yahoo.com> wrote:

> Hi,
> 
> I've been reading through the Intake docs and I was wondering about the
> 'mapToObject' attribute.
> 
> 1) When mapping a group to an object do all the fields have to map to
> that object?

Yes. (keep reading)

> 2) If so, then I guess the mapToProperty for a field is only good for
> mapping a form name to _different_ object field name.  If the attribute
> is not there, then the field name is assumed to be the property name.
> (Correct?)

No mapToProperty is more like an alias. Example:

 <field name="Name" key="name" type="String">
 </field>

 <field name="NewName" key="newname" type="String"
               mapToProperty="Name">
 </field>

That would map NewName to the set/getName() method in the Bean.

> I think I may have misunderstood the document as allowing you to
> specifically select where fields in the group would map to the group's
> object.  

I don't think I understand what you are misunderstanding.

Essentially, the intake .xml file allows you to map specific Fields to an
Object's methods with the addition of being able to also create aliases
using the mapToProperty attribute.


-jon


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