You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by אלחנן מעין <em...@msn.com> on 2007/04/28 23:04:41 UTC

i think i figured the problem with doubleselect

this is my tag:
<s:doubleselect
		label="Client and task"
		 name="client"
		 list="clients"
		 doubleList="tasks"
		 doubleName="selectedTask"
		  />

this is my action:

public class ProblemPage extends ActionSupport {
	private static final long serialVersionUID = 1L;


	public List getClients(){
		Client c=new Client();

		List ts =new ArrayList();
		ts.add(new Task(1,"dev"));
		ts.add(new Task(2,"prog"));
	//	c.setTasks(ts);

		List l=new ArrayList();
		l.add(c);
		return l;
	}
	public List getTasks(){
		List l=new ArrayList();
		l.add("2");
		return l;
	}
}

as you can see the client class itself has tasks property, originally the 
client class should have been retirieved from the database ,with tasks 
related to it, once the user has selected a specific client from the task, 
the 2nd combo should display the tasks for that selected client alone.

here is the problem.
first if i name the method getTasks, and reference the doubleList as tasks, 
it will return an empty list

(in this example i havn't populated the client class).
but i populate the client class with tasks (un-remarking that in the code), 
struts2 will faill with exception of :

SEVERE: Servlet.service() for servlet default threw exception
tag 'doubleselect', field 'list', name 'client': The requested list key 
'clients' could not be resolved as a 
collection/array/map/enumeration/iterator type. Example: people or 
people.{name} - [unknown location]
	at org.apache.struts2.components.Component.fieldError(Component.java:231)
	at org.apache.struts2.components.Component.findValue(Component.java:293)
	at 
org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)

so what do you suggest, and why this is so?

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: i think i figured the problem with doubleselect

Posted by אלחנן מעין <em...@msn.com>.
ok this is me talking to me:
the first problem of the Exception is solved (i set a list instead of set to 
my class).
now my tag is so:
<s:doubleselect
		 label="Client and task"
		 name="client"
		 list="clients"
		 listKey="id"
		 listValue="name"
		 doubleList="tasks"
		 doubleName="task"
		 doubleListKey="id"
		 doubleListValue="name"/>


and my action is so:

public class ProblemPage extends ActionSupport {
	private static final long serialVersionUID = 1L;

	private Client client;
	public Client getClient() {
		return client;
	}
	public void setClient(Client client) {
		this.client = client;
	}
	private Task task;
	public Task getTask() {
		return task;
	}
	public void setTask(Task task) {
		this.task = task;
	}
	private List clients=new ArrayList();
	public ProblemPage(){
		Client c=new Client(1,"elhanan");
		c.setId(1);

		Set<Task> ts=new HashSet<Task>();
		ts.add(new Task(1,"dev"));
		ts.add(new Task(2,"prog"));
		c.setTasks(ts);

		clients.add(c);

		Client c1=new Client(2,"mike");

		ts=new HashSet<Task>();
		ts.add(new Task(3,"maint"));
		ts.add(new Task(4,"analasys"));
		c1.setTasks(ts);

		clients.add(c1);
	}
	public List getClients(){
		return clients;
	}

everything seems to be working as it should ,except for one thing, when i 
change the first seleciton in the client combo to the second one, the gap 
between the two combos dissapreas, so changing a selection in the first 
combo allways moves the 2nd combo, how is that possilbe?


>From: "אלחנן מעין" <em...@msn.com>
>Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
>To: user@struts.apache.org
>Subject: i think i figured the problem with doubleselect
>Date: Sun, 29 Apr 2007 00:04:41 +0300
>
>this is my tag:
><s:doubleselect
>		label="Client and task"
>		 name="client"
>		 list="clients"
>		 doubleList="tasks"
>		 doubleName="selectedTask"
>		  />
>
>this is my action:
>
>public class ProblemPage extends ActionSupport {
>	private static final long serialVersionUID = 1L;
>
>
>	public List getClients(){
>		Client c=new Client();
>
>		List ts =new ArrayList();
>		ts.add(new Task(1,"dev"));
>		ts.add(new Task(2,"prog"));
>	//	c.setTasks(ts);
>
>		List l=new ArrayList();
>		l.add(c);
>		return l;
>	}
>	public List getTasks(){
>		List l=new ArrayList();
>		l.add("2");
>		return l;
>	}
>}
>
>as you can see the client class itself has tasks property, originally the 
>client class should have been retirieved from the database ,with tasks 
>related to it, once the user has selected a specific client from the task, 
>the 2nd combo should display the tasks for that selected client alone.
>
>here is the problem.
>first if i name the method getTasks, and reference the doubleList as tasks, 
>it will return an empty list
>
>(in this example i havn't populated the client class).
>but i populate the client class with tasks (un-remarking that in the code), 
>struts2 will faill with exception of :
>
>SEVERE: Servlet.service() for servlet default threw exception
>tag 'doubleselect', field 'list', name 'client': The requested list key 
>'clients' could not be resolved as a 
>collection/array/map/enumeration/iterator type. Example: people or 
>people.{name} - [unknown location]
>	at org.apache.struts2.components.Component.fieldError(Component.java:231)
>	at org.apache.struts2.components.Component.findValue(Component.java:293)
>	at 
>org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)
>
>so what do you suggest, and why this is so?
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today it's FREE! 
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org