You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jaan Tark <ja...@mail.ee> on 2007/05/15 12:51:04 UTC
url, fill collection
Hello,
i have a class
public class Person {
private String name;
// gettter, setter
}
contained in
public class Master extends ActionSupport {
private Vector<Person> persons;
//getters, setters
publis String execute() {
return SUCCESS;
}
}
i can retrieve persons in jsp like this:
<s:iterator value="persons">
<s:property value="name">
</s:iterator>
how to i fill the vector via URL (GET)?
(e.g. "....?persons.name=test)
if the vector contains primitive types - int, string ... , i''m able to
fill it ... but having trouble with vector (collections) that contain
smth like shown
rgds
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: url, fill collection
Posted by Lance <la...@marketpipe.com>.
java.util.Set does not guarantee that the order of it's elements remain
constant and does not provide set(int,Object) or get(int) methods.
Use a List or an array in the web tier and perhaps convert to a set in
validation / middle tier.
Cheers,
Lance.
Jaan Tark wrote:
> continues ....
>
> so i can make it all work with vectors ... but not sets
>
> so if my action class has:
> private Vector<Person> asd;
>
> then, via browser url ... i can set it like:
> ?asd.name=smth
>
> but, if i'm using a Set instead the Vector
> ?asd.name=smth
>
> i'm getting "ERRROR ... ParametersIterceptor ... [setParameters]:
> Unexpected Exception catched: Error setting expression
>
> if testing with Vector<String> and Set<String> ... everything works
>
> am I in somekind of syntax trouble? ...
>
>
> rgds
>
> ---------------------------------------------------------------------
> 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: url, fill collection
Posted by Jaan Tark <ja...@mail.ee>.
continues ....
so i can make it all work with vectors ... but not sets
so if my action class has:
private Vector<Person> asd;
then, via browser url ... i can set it like:
?asd.name=smth
but, if i'm using a Set instead the Vector
?asd.name=smth
i'm getting "ERRROR ... ParametersIterceptor ... [setParameters]:
Unexpected Exception catched: Error setting expression
if testing with Vector<String> and Set<String> ... everything works
am I in somekind of syntax trouble? ...
rgds
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: url, fill collection
Posted by Lance <la...@marketpipe.com>.
You could use a lazy list and a factory to create your empty person objects.
private List persons =
org.apache.commons.collections.list.LazyList.decorate(new Vector(), new
InstantiateFactory(Person.class));
Cheers,
Lance.
Jaan Tark wrote:
> problem solved, ignore
>
> gonna write the problem description and solution as soon as i have
> some extra time
>
>
> rgds
>
> On 15.05.2007 13:51, Jaan Tark wrote:
>> Hello,
>>
>> i have a class
>>
>> public class Person {
>> private String name;
>> // gettter, setter
>> }
>>
>> contained in
>>
>> public class Master extends ActionSupport {
>> private Vector<Person> persons;
>>
>> //getters, setters
>> publis String execute() {
>> return SUCCESS;
>> }
>>
>> }
>>
>> i can retrieve persons in jsp like this:
>> <s:iterator value="persons">
>> <s:property value="name">
>> </s:iterator>
>>
>>
>> how to i fill the vector via URL (GET)?
>> (e.g. "....?persons.name=test)
>>
>> if the vector contains primitive types - int, string ... , i''m able
>> to fill it ... but having trouble with vector (collections) that
>> contain smth like shown
>>
>> rgds
>>
>
>
> ---------------------------------------------------------------------
> 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: url, fill collection
Posted by Jaan Tark <ja...@mail.ee>.
problem solved, ignore
gonna write the problem description and solution as soon as i have some
extra time
rgds
On 15.05.2007 13:51, Jaan Tark wrote:
> Hello,
>
> i have a class
>
> public class Person {
> private String name;
> // gettter, setter
> }
>
> contained in
>
> public class Master extends ActionSupport {
> private Vector<Person> persons;
>
> //getters, setters
> publis String execute() {
> return SUCCESS;
> }
>
> }
>
> i can retrieve persons in jsp like this:
> <s:iterator value="persons">
> <s:property value="name">
> </s:iterator>
>
>
> how to i fill the vector via URL (GET)?
> (e.g. "....?persons.name=test)
>
> if the vector contains primitive types - int, string ... , i''m able
> to fill it ... but having trouble with vector (collections) that
> contain smth like shown
>
> rgds
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org