----- Original Message -----
From: "Eric Mckenna" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 09, 2003 9:53 PM
Subject: [OS-webwork] Can I concatenate text in the name attribute?


> I have a form that creates some child objects, so the form has repeated
form
> values.  I'm trying to add some other text (a prefix) in the name tag to
> distinguish each child's values from one another, hence the status tag and
> prefix.
> Here's basically what im trying to achieve,
> <input type="text" name="child1[0].someName"   value="123" />
> <input type="text" name="child1[1].someName"   value="456" />
> <input type="text" name="child1[2].someName"   value="789" />
> ...
> <input type="text" name="child2[0].someName"   value="012" />
> <input type="text" name="child2[1].someName"   value="123" />
> <input type="text" name="child2[2].someName"   value="234" />
> ...
>
> I started with using the status tag on iterator:
> <ww:iterator value="someList" status="'status'">
>     <ww:textfield="'LabelName'" name="[EMAIL PROTECTED]"
> value="someValue/>
> </ww:iterator>
>
> <ww:iterator value="someList" status="'status'">
>     <ww:textfield="'LabelName'" name="[EMAIL PROTECTED]"
> value="someValue/>
> </ww:iterator>
>
> I've tried several different methods to get the name to resolve correctly.
> i.e.
> name="'prefix['@status'].someName'"
> name="'[EMAIL PROTECTED]'"
> name="'[EMAIL PROTECTED]'"
> name="prefix[{'@status'}].someName"
> but nothing seems to work.
>
> Am I missing something?  Does an expression only get resolved in value
> attributes?
>

The short answer to the subject "Can I concatenate text...." is no, you
can't concatenate with the expression language.

The textfield tag tries to resolve the name tag. So it tries to look it up
on the value stack. So for example you wrote: "[EMAIL PROTECTED]"
That means that the value stack is trying to find a method called
"[EMAIL PROTECTED]()"  which it of course does not find.
If you are unsure of if you're expression is  resolved the way you want you
can try it with the property tag to verify that the output is correct.

So to accomplish what you are trying to do you can skip the textfield tag
and do as Cuong Tran suggested.
Another possible solution is to have a set of concat methods in a utility
action/bean. Then you could change the call to:
name="@concatBean/concat('prefix1[', @status, '].someName')"

This would call a concat method in the concatBean with 3 parameters that
should be concatenated and returned.

I am planning to add concatenation support for WW1.4.1. Then you would be
able to write:
name="'prefix1[' + @status + '].someName'"   which is what you want I
believe.

Cheers,

Dick Zetterberg
[EMAIL PROTECTED]




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to