You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Philipp Leusmann <ph...@rwth-aachen.de> on 2009/12/18 16:30:33 UTC
Problem with value attribute in select tag
Hi,
what exactly does the value-attribute of the select tag require? Is it one element of the list provided to the list-argument? Or is it the value which eventually makes the value-attribute of the html-rendered select tag?
I have something like the following and I do not find a way to work as expected:
public class SelectAction extends ActionSupport
{
private List<TestObject> list = new ArrayList();
private TestObject object;
public String execute()
{
TestObject to1 = new TestObject(1, "foo");
list.add(to1);
TestObject to2 = new TestObject(2, "bar");
list.add(to2);
object = to2;
}
[getters for the stuff above]
}
public class TestObject
{
private Integer id;
private String str;
public TestObject(Integer id, String str)
{
this.id = id;
this.str = str;
}
[getters]
}
And in the template (using Freemarker) I tried:
<@s.select name="bla" list=list listKey="id" listValue="str" value=object />
<@s.select name="bla" list=list listKey="id" listValue="str" value=object.id />
<@s.select name="bla" list=list listKey="id" listValue="str" value="${object.id}" />
<@s.select name="bla" list=list listKey="id" listValue="str" value=${object} />
None of the above worked.
Could anybody please tell me what the correct value-argument would be?
Thanks very much,
Philipp
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with value attribute in select tag
Posted by Philipp Leusmann <ph...@rwth-aachen.de>.
Thanks Bill, this works fine.
I am still wondering what the value-attribute is good for, then.
Philipp
Am 18.12.2009 um 17:48 schrieb Bill Bohnenberger:
> I do not use the value attribute in my s:select tags & they work fine.
>
> I do always use the headerKey & headerValue attributes though.
>
> Incidentally, the preselected (user-selected) key value is taken (stored)
> using the name attribute so in your example your SelectAction should define
> "bla" and provide setter & getter for same.
>
> - Bill
>
> On Fri, Dec 18, 2009 at 8:20 AM, Brian Thompson <el...@gmail.com>wrote:
>
>> I would try
>>
>> <@s.select name="bla" list=list listKey="id" listValue="str" value="%{
>> object.id}" />
>>
>> -Brian
>>
>>
>>
>> On Fri, Dec 18, 2009 at 9:30 AM, Philipp Leusmann <
>> philipp.leusmann@rwth-aachen.de> wrote:
>>
>>> Hi,
>>>
>>> what exactly does the value-attribute of the select tag require? Is it
>> one
>>> element of the list provided to the list-argument? Or is it the value
>> which
>>> eventually makes the value-attribute of the html-rendered select tag?
>>>
>>> I have something like the following and I do not find a way to work as
>>> expected:
>>>
>>> public class SelectAction extends ActionSupport
>>> {
>>> private List<TestObject> list = new ArrayList();
>>>
>>> private TestObject object;
>>>
>>> public String execute()
>>> {
>>> TestObject to1 = new TestObject(1, "foo");
>>> list.add(to1);
>>> TestObject to2 = new TestObject(2, "bar");
>>> list.add(to2);
>>> object = to2;
>>> }
>>>
>>> [getters for the stuff above]
>>>
>>> }
>>>
>>> public class TestObject
>>> {
>>> private Integer id;
>>>
>>> private String str;
>>>
>>> public TestObject(Integer id, String str)
>>> {
>>> this.id = id;
>>> this.str = str;
>>> }
>>>
>>> [getters]
>>> }
>>>
>>>
>>>
>>> And in the template (using Freemarker) I tried:
>>>
>>> <@s.select name="bla" list=list listKey="id" listValue="str"
>>> value=object />
>>>
>>> <@s.select name="bla" list=list listKey="id" listValue="str"
>> value=
>>> object.id />
>>>
>>> <@s.select name="bla" list=list listKey="id" listValue="str"
>>> value="${object.id}" />
>>>
>>> <@s.select name="bla" list=list listKey="id" listValue="str"
>>> value=${object} />
>>>
>>> None of the above worked.
>>>
>>>
>>> Could anybody please tell me what the correct value-argument would be?
>>>
>>> Thanks very much,
>>>
>>> Philipp
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with value attribute in select tag
Posted by Bill Bohnenberger <bi...@gmail.com>.
I do not use the value attribute in my s:select tags & they work fine.
I do always use the headerKey & headerValue attributes though.
Incidentally, the preselected (user-selected) key value is taken (stored)
using the name attribute so in your example your SelectAction should define
"bla" and provide setter & getter for same.
- Bill
On Fri, Dec 18, 2009 at 8:20 AM, Brian Thompson <el...@gmail.com>wrote:
> I would try
>
> <@s.select name="bla" list=list listKey="id" listValue="str" value="%{
> object.id}" />
>
> -Brian
>
>
>
> On Fri, Dec 18, 2009 at 9:30 AM, Philipp Leusmann <
> philipp.leusmann@rwth-aachen.de> wrote:
>
> > Hi,
> >
> > what exactly does the value-attribute of the select tag require? Is it
> one
> > element of the list provided to the list-argument? Or is it the value
> which
> > eventually makes the value-attribute of the html-rendered select tag?
> >
> > I have something like the following and I do not find a way to work as
> > expected:
> >
> > public class SelectAction extends ActionSupport
> > {
> > private List<TestObject> list = new ArrayList();
> >
> > private TestObject object;
> >
> > public String execute()
> > {
> > TestObject to1 = new TestObject(1, "foo");
> > list.add(to1);
> > TestObject to2 = new TestObject(2, "bar");
> > list.add(to2);
> > object = to2;
> > }
> >
> > [getters for the stuff above]
> >
> > }
> >
> > public class TestObject
> > {
> > private Integer id;
> >
> > private String str;
> >
> > public TestObject(Integer id, String str)
> > {
> > this.id = id;
> > this.str = str;
> > }
> >
> > [getters]
> > }
> >
> >
> >
> > And in the template (using Freemarker) I tried:
> >
> > <@s.select name="bla" list=list listKey="id" listValue="str"
> > value=object />
> >
> > <@s.select name="bla" list=list listKey="id" listValue="str"
> value=
> > object.id />
> >
> > <@s.select name="bla" list=list listKey="id" listValue="str"
> > value="${object.id}" />
> >
> > <@s.select name="bla" list=list listKey="id" listValue="str"
> > value=${object} />
> >
> > None of the above worked.
> >
> >
> > Could anybody please tell me what the correct value-argument would be?
> >
> > Thanks very much,
> >
> > Philipp
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
Re: Problem with value attribute in select tag
Posted by Brian Thompson <el...@gmail.com>.
I would try
<@s.select name="bla" list=list listKey="id" listValue="str" value="%{
object.id}" />
-Brian
On Fri, Dec 18, 2009 at 9:30 AM, Philipp Leusmann <
philipp.leusmann@rwth-aachen.de> wrote:
> Hi,
>
> what exactly does the value-attribute of the select tag require? Is it one
> element of the list provided to the list-argument? Or is it the value which
> eventually makes the value-attribute of the html-rendered select tag?
>
> I have something like the following and I do not find a way to work as
> expected:
>
> public class SelectAction extends ActionSupport
> {
> private List<TestObject> list = new ArrayList();
>
> private TestObject object;
>
> public String execute()
> {
> TestObject to1 = new TestObject(1, "foo");
> list.add(to1);
> TestObject to2 = new TestObject(2, "bar");
> list.add(to2);
> object = to2;
> }
>
> [getters for the stuff above]
>
> }
>
> public class TestObject
> {
> private Integer id;
>
> private String str;
>
> public TestObject(Integer id, String str)
> {
> this.id = id;
> this.str = str;
> }
>
> [getters]
> }
>
>
>
> And in the template (using Freemarker) I tried:
>
> <@s.select name="bla" list=list listKey="id" listValue="str"
> value=object />
>
> <@s.select name="bla" list=list listKey="id" listValue="str" value=
> object.id />
>
> <@s.select name="bla" list=list listKey="id" listValue="str"
> value="${object.id}" />
>
> <@s.select name="bla" list=list listKey="id" listValue="str"
> value=${object} />
>
> None of the above worked.
>
>
> Could anybody please tell me what the correct value-argument would be?
>
> Thanks very much,
>
> Philipp
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: Problem with value attribute in select tag
Posted by Philipp Leusmann <ph...@rwth-aachen.de>.
The documentation says it is: <http://struts.apache.org/2.1.8.1/docs/select.html>
But the examples are not really helpful.
Philipp
Am 18.12.2009 um 16:43 schrieb Gabriel Belingueres:
> I believe that the "value" attribute is not used in this tag.
>
> 2009/12/18 Philipp Leusmann <ph...@rwth-aachen.de>:
>> Hi,
>>
>> what exactly does the value-attribute of the select tag require? Is it one element of the list provided to the list-argument? Or is it the value which eventually makes the value-attribute of the html-rendered select tag?
>>
>> I have something like the following and I do not find a way to work as expected:
>>
>> public class SelectAction extends ActionSupport
>> {
>> private List<TestObject> list = new ArrayList();
>>
>> private TestObject object;
>>
>> public String execute()
>> {
>> TestObject to1 = new TestObject(1, "foo");
>> list.add(to1);
>> TestObject to2 = new TestObject(2, "bar");
>> list.add(to2);
>> object = to2;
>> }
>>
>> [getters for the stuff above]
>>
>> }
>>
>> public class TestObject
>> {
>> private Integer id;
>>
>> private String str;
>>
>> public TestObject(Integer id, String str)
>> {
>> this.id = id;
>> this.str = str;
>> }
>>
>> [getters]
>> }
>>
>>
>>
>> And in the template (using Freemarker) I tried:
>>
>> <@s.select name="bla" list=list listKey="id" listValue="str" value=object />
>>
>> <@s.select name="bla" list=list listKey="id" listValue="str" value=object.id />
>>
>> <@s.select name="bla" list=list listKey="id" listValue="str" value="${object.id}" />
>>
>> <@s.select name="bla" list=list listKey="id" listValue="str" value=${object} />
>>
>> None of the above worked.
>>
>>
>> Could anybody please tell me what the correct value-argument would be?
>>
>> Thanks very much,
>>
>> Philipp
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem with value attribute in select tag
Posted by Gabriel Belingueres <be...@gmail.com>.
I believe that the "value" attribute is not used in this tag.
2009/12/18 Philipp Leusmann <ph...@rwth-aachen.de>:
> Hi,
>
> what exactly does the value-attribute of the select tag require? Is it one element of the list provided to the list-argument? Or is it the value which eventually makes the value-attribute of the html-rendered select tag?
>
> I have something like the following and I do not find a way to work as expected:
>
> public class SelectAction extends ActionSupport
> {
> private List<TestObject> list = new ArrayList();
>
> private TestObject object;
>
> public String execute()
> {
> TestObject to1 = new TestObject(1, "foo");
> list.add(to1);
> TestObject to2 = new TestObject(2, "bar");
> list.add(to2);
> object = to2;
> }
>
> [getters for the stuff above]
>
> }
>
> public class TestObject
> {
> private Integer id;
>
> private String str;
>
> public TestObject(Integer id, String str)
> {
> this.id = id;
> this.str = str;
> }
>
> [getters]
> }
>
>
>
> And in the template (using Freemarker) I tried:
>
> <@s.select name="bla" list=list listKey="id" listValue="str" value=object />
>
> <@s.select name="bla" list=list listKey="id" listValue="str" value=object.id />
>
> <@s.select name="bla" list=list listKey="id" listValue="str" value="${object.id}" />
>
> <@s.select name="bla" list=list listKey="id" listValue="str" value=${object} />
>
> None of the above worked.
>
>
> Could anybody please tell me what the correct value-argument would be?
>
> Thanks very much,
>
> Philipp
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org