struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Igor Vlasov <vigo...@mail.ru>
Subject Re: Problem while setting object directly from <s:select> tag
Date Fri, 26 Oct 2007 07:14:56 GMT

The list property targets to "model" with data for rendering &lt;select tag.

In &lt;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  &lt;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


Mime
View raw message