Cameron,

You can map an existing object into multiple IntakeGroups that map to the
same object.  
Intake use the QueryKey of that object plus the value of the key attribute
in the matching field tag of it's group within intake.xml. 

I have posted a quickie example using what you sent.  However there is a
more in-depth how-to at: 
http://jakarta.apache.org/turbine/turbine-2/services/intake-service.html


<form name="aform" action="your.turbine.action" action="post">

#foreach($item in $inventory)
#* 
 * Create a IntakeGroup for each Inventory
 * object in the list.  Then map that
 * object into a Group.  This will create
 * a unique form field name based on the QueryKey of
 * each inventory object which is retrieved
 * by $ig.Id.Key.  It will also map
 * the properties in $ig.Id.Value to the
 * Id property in your object (getId() setId(id).
*#
#set($ig = $intake.Invetory.mapTo($item))
<input type="checkbox" name="$ig.Id.Key" value="$ig.Id.Value"> $item.name
<br>

Reason for request: <input type="text" name="$ig.Reason.Key"
value="$ig.Reason.Value"><br>

#end

<input type="submit" name="eventSubmit_doSomething" value="Checkout">

</form>

Example intake.xml snippet for this form/object:
<group key="inv" name="Inventory" mapToObject="com.yourcomp.Inventory">
 <field key="id" name="Id" type="String" mapToProperty="Id"/>
 <field key="id" name="Reason" type="String" mapToProperty="Reason"/>
</group>


hth,
Scott


> -----Original Message-----
> From: Cameron Cole [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, February 17, 2002 1:55 PM
> To: Turbine Users List
> Subject: Intake, Torque/Peers and HTML forms
> 
> 
> Hello all,
> 
> I have been playing with Turbine for the past few days and 
> have a small
> application working. Of course a few questions have arisen and I have
> been unable to find the answers to these questions so I 
> thought I would
> post a quick note to the list.
> 
> 1. Intake can create the binding between an html form and a 
> java object.
> What, if possible, is the best practise to create bindings between
> multiple objects in a list and multiple form elements? I can probably
> explain what I mean better with an example. Consider a simple 
> inventory
> mgmt system with only one simple object an Inventory.class item. If
> someone wishes to "check out" a piece of inventory, or 
> several pieces of
> inventory, they need to give a reason for each piece of inventory they
> are checking out. The velocity template would look something like this
> (condensed):
> 
> <table>
> #foreach ($item in $inventory)
>       <tr>
>       <td><input type="checkbox" name="id" value="$item.id"></td>
>       <td>$item.name</td>
>       <td><input type="text" name="help here" value=""></td>
>       </tr>
> #end
>       <tr>
>       <td colspan="3">
>       <input type="submit" name="eventSubmit_doSomething" 
> value="Checkout">
>       </td>
>       </tr>
> </table>
> 
> It is easy to create the association between the checkboxes 
> and the true
> java objects via their unique id and the properties of a 
> checkbox/radio
> button/drop down list. However, how can I create a unique binding
> between each java object and the text box? I don't want to do 
> something
> like: <input type="text" name="reason:$item.id"> and then 
> have to parse
> it out in the action. It also ruins all the neat bindings you can do
> with peers and the intake service.
> 
> Is there a document I have missed reading or misinterpreted while
> reading? If so can someone please shed some light on this 
> problem. Must
> I do parsing in the action?
> 
> Thanks in advance for your help,
> 
> -cam.
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

Reply via email to