You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "jignesh(india)" <ji...@aspl.in> on 2007/10/24 09:04:35 UTC
Problem while setting object directly from tag
Hi,
I am having problem while setting my selected list object directly to my
bean class.
My code looks like given below:-
<s:select name="user.item" list="itemList" listValue="name"/>
public MyAction extends ActionSupport {
...
public List<Item> getItemList() {
return ("a list with itemobjects in it");
}
public User getUser() {
return "user object";
}
}
public class User {
private Item item;
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
}
}
public class Item {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
My listKey contains the Object of type Item.
But when i am trying to save my user object gives me following error.
Error : Invalid field value for field "user.item".
Can anybody help me to find solution.
Thanks in advanced,
Jignesh
--
View this message in context: http://www.nabble.com/Problem-while-setting-object-directly-from-%3Cs%3Aselect%3E-tag-tf4682431.html#a13380117
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Problem while setting object directly from tag
Posted by Igor Vlasov <vi...@mail.ru>.
The list property targets to "model" with data for rendering <select tag.
In <option tag you recieve "Item.toString" as value attribute.
After post Struts cannot set this "value" to user.item property.
I think you must use in itemId as value for <option value attibute
and use <s:select name="user.item.itemId"..../>
jignesh(india) wrote:
>
> Hi,
> I am having problem while setting my selected list object directly to my
> bean class.
> My code looks like given below:-
>
> <s:select name="user.item" list="itemList" listValue="name"/>
>
> public MyAction extends ActionSupport {
> ...
> public List<Item> getItemList() {
> return ("a list with itemobjects in it");
> }
> public User getUser() {
> return "user object";
> }
> }
> public class User {
> private Item item;
> public Item getItem() {
> return item;
> }
> public void setItem(Item item) {
> this.item = item;
> }
> }
>
> public class Item {
> private String name;
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> }
> My listKey contains the Object of type Item.
> But when i am trying to save my user object gives me following error.
> Error : Invalid field value for field "user.item".
>
> Can anybody help me to find solution.
> Thanks in advanced,
> Jignesh
>
--
View this message in context: http://www.nabble.com/Problem-while-setting-object-directly-from-%3Cs%3Aselect%3E-tag-tf4682431.html#a13421986
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org