I've been posting this thread to the dev list accidentally, and thought it
might be helpful in the future to people on turbine-user....




Phew! Got it.

Had to dig deep. Here's an example for the next person looking for the
answer to this one...


// for example, I created a list of values to set. java.util.ArrayList al =
new java.util.ArrayList(); al.add(new Integer(12)); al.add(new Integer(13));
al.add(new Integer(14));

// to use reflect.Method, need all parameters stored in an object array
Object[] oarray = { al };

// here's the magic
//get group
Group intakeGroup = intake.get(IntakeGroupName, IntakeTool.DEFAULT_KEY); //
get field setter from intake service java.lang.reflect.Method m =
org.apache.turbine.services.intake.TurbineIntake.getFieldSetter(IntakeGroupN
ame,IntakeGroupFieldName);
// invoke the set method
m.invoke(intakeGroup,oarray);


Perhaps there should be a more convenient way to do this?

-d




-----Original Message-----
From: Gaasch, Derek [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, February 16, 2003 5:24 PM
To: 'Turbine Developers List'
Subject: RE: set multivalue intake field in screen class

Intake does have the ability to map multiple values to a field:

<field name="xxx" key="xxx" type="int" displayName="xxx:"
multiValued="true">

It works fine if you have a select box in a form, and perform a post -- i.e.
all the selected values are mapped to the appropriate field of the Intake
object. The multi-valued list is a list of workingdogs.Record objects, and
can be retrieved from a velocity screen...

However, I want to set those values before any post is performed. But doing
so has proven to be a convoluted task...

=d





-----Original Message-----
From: Marc Lustig [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, February 16, 2003 4:40 PM
To: Turbine Developers List
Subject: AW: set multivalue intake field in screen class

I assume you are using a select-field that allows to mark multiple items. I
don't think you can use Intake to automatically map multiple values of a
field. AFAIK Intake can only map single values. What I would do is
retrieving the currently assigned values from db and manually add the
"selected" attributes to the corresponding <option>-fields. If you need
Intake to validate the form, you can setTemp the current values or put them
in the path.

Marc


> -----Urspr�ngliche Nachricht-----
> Von: Gaasch, Derek [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 17. Februar 2003 00:21
> An: 'Turbine Developers List'
> Betreff: set multivalue intake field in screen class
>
>
>
>
> I'm successfully using a multivalue intake field for user input, 
> however I am having trouble pre-setting a multivalue field... I've 
> created a screen for editing content that was already created. On that 
> form, I need to preset the values of the intake tool with values 
> pulled from the db. Any suggestions how to do so? I've tried a variety 
> of things, like
>
> java.util.ArrayList al = new java.util.ArrayList(); al.add(new 
> Integer(12)); al.add(new Integer(13));
> al.add(new Integer(14));
>
> Object o = categorizergroup.get("CategoryId").getValue();
> o=al;
>
> I know that a multivalue field is a List of workingdog.Record objects 
> (i.e. when referencing them in the screen class, I know to use
> $row.getValue("xxx"), but that hasn't helped me much. Any ideas would be
> greatly appreciated .
>
> Thanks!
>
> -d
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to