> How does one use the "mapTo" feature of intake to map form data to
> business objects (manually created, not by torque)?  Here are 
> the steps
> I think I need to get it done so far...

For your business objects to be intake-compatible they must implement the
org.apache.turbine.om.Retrievable interface or if you are using the
decoupled fulcrum Intake service, org.apache.fulcrum.intake.Retrievable.  

Intake uses introspection to set the values of your B/O's from HTML form
fields and vice-versa.  The fields defined within a group need to be able to
be mapped into your B/O.  In most cases you will set "name" attribute to
match the property within your B/O.  If you want the field name to be
something other than the B/O's property's name it maps to, you will need to
supply the "mapToProperty" attribute of that field to be the same as the
property in your B/O.


hth,
Scott




> -----Original Message-----
> From: Dan K. [mailto:[EMAIL PROTECTED]]
> Sent: Friday, April 05, 2002 6:30 PM
> To: [EMAIL PROTECTED]
> Subject: intake's mapTo usage?
> 
> 
> 
> Hi,
> 
> I've read up the intake-service documentation but it's quite 
> confusing and
> the mail archive doesn't really address my newbie intake question:
> 
> How does one use the "mapTo" feature of intake to map form data to
> business objects (manually created, not by torque)?  Here are 
> the steps
> I think I need to get it done so far...
> 
> In the intake.xml file:
> - there must be a group tag with the "name", "key", and "mapToObject"
> attribute set, similar to:
> <group name="MyGroup" key="MyGroupKey" mapToObject="MyBusinessObject">
> 
> - the mapToObject="MyBusinessObject" has a corresponding
> MyBusinessObject.java with appropriate get/set methods for 
> the attributes
> in question. Is this right?
> 
> - add in some fields to the group (with their rules), similar to:
>     <field name="Username" key="Username" type="String">
>         <rule name="required" value="true">Username is required</rule>
>         ...some more rules if desired...
>     </field>
> 
> In the corresponding "Action" class:
> - get an instance of the intake object from the context, and set the
> business object with the corresponding group field values from intake,
> similar to:
>     IntakeTool intake = (IntakeTool)context.get("intake");
>     Group group = intake.get("MyGroup", IntakeTool.DEFAULT_KEY);
>     MyBusinessObject myBO = new MyBusinessObject();
>     if (group.isAllValid()) {
>         group.setProperties(myBO);
>     }
>     // at this point, myBO should be populated with the 
> correct attribute
>     // values, right?  So I can print it out like this:
>     System.out.println("myBO = "+myBO.toString());
> 
> In the template file (.vm file):
> - include this in a <form> tag:
>     $intake.declareGroups()
> - and then what?
> 
> I noticed in the intake-service doc it says to do something 
> similar to:
> #set ( $attributeValue = $issue.AttributeValue("URL") )
> #set ( $group = $intake.AttributeValue.mapTo($attributeValue) )
> 
> But that's something from scarab, of which I have no clue
> about...especially the first #set statement.
> 
> If someone can detail this out, then I'd appreciate it very much! TIA.
> I'm sure it'll be useful as a basis for an "intake quick start how-to"
> as well.
> 
> Regards,
> Dan
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

Reply via email to