You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon D Cruz <jo...@wachovia.com> on 2007/10/17 19:56:42 UTC

[Struts2] CheckBoxList returns XWorkList instead of ArrayList

I've been wracking my brains on this issue for the last day and wonder if
someone out there can help.

*** I'm using an ArrayList<Parent> to populate a CheckBoxList on my JSP.
*** The Parent object has an "id" and "name" field.
*** I'm using an ArrayList<String> to retrieve the values that have been
selected.
*** I'm expecting to see an ArrayList<String> coming back, but instead a
XWorkList is being returned.

I've worked with Struts1 and WebWork before, and I don't remember
using/seeing the XWorkList object before.

I've tried using the ######-conversion.properties process, but this will
only help convert the elements of the Collection.

*** Is there a way to have an ArrayList returned instead of the XWorkList?

I have a feeling I'm missing something basic...

The code that's in the Action:

	// Populate the checkboxlist with these...
	public List<Parent> testList = new ArrayList<Parent>();
	public ArrayList<Parent> testArrayList = new ArrayList<Parent>();

	// Retrieve the values selected from the form
	public ArrayList<String> valuesList = new ArrayList<String>();
	public ArrayList<String> valuesArrayList = new ArrayList<String>();

	//... Getters and Setters for the "values###" ...
	...
	...

        // Create the Parent objects to place in the Lists
	public void validate() {

        	Parent parent1ForList = new Parent("Check 1");
        	Parent parent2ForList = new Parent("Check 2");
        	Parent parent3ForList = new Parent("Check 3");
        
        	Parent parent1ForArrayList = new Parent("Check 1");
        	Parent parent2ForArrayList = new Parent("Check 2");
        	Parent parent3ForArrayList = new Parent("Check 3");

        	testList.add(parent1ForList);
        	testList.add(parent2ForList);
        	testList.add(parent3ForList);
        
        	testArrayList.add(parent1ForArrayList);
        	testArrayList.add(parent2ForArrayList);
        	testArrayList.add(parent3ForArrayList);

	}


The code that's in the JSP:

	CheckBoxList created from a "List":
	<BR><BR>
	<s:checkboxlist name="valuesList" list="testList" listKey="id"
listValue="name"/>

	<BR><BR>

	CheckBoxList created from a "ArrayList":
	<BR><BR>
	<s:checkboxlist name="valuesArrayList" list="testArrayList" listKey="id"
listValue="name"/>


What I'm getting back from "valueslist" and "valuesArrayList" via
"getClass()":

	class com.opensymphony.xwork2.util.XWorkList


Thanks
-- 
View this message in context: http://www.nabble.com/-Struts2--CheckBoxList-returns-XWorkList-instead-of-ArrayList-tf4642221.html#a13259251
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: [Struts2] CheckBoxList returns XWorkList instead of ArrayList

Posted by Jon D Cruz <jo...@wachovia.com>.

Yeah, you can chalk this one up as a "duh" moment for me.   I'm using the
Db4o object database to save my objects, and it was erroring out when I was
trying to save an ArrayList<String> retrieved from the form, (but Struts2
was returning an XWorkList instead).  Struts is just doing what it should
be, and I think my Db4o code is in error.

Thanks for the replies...



newton.dave wrote:
> 
> Isn't XWorkList a sub-class of ArrayList?
> 
> --- Jon D Cruz <jo...@wachovia.com> wrote:
> 
>> 
>> I've been wracking my brains on this issue for the
>> last day and wonder if
>> someone out there can help.
>> 
>> *** I'm using an ArrayList<Parent> to populate a
>> CheckBoxList on my JSP.
>> *** The Parent object has an "id" and "name" field.
>> *** I'm using an ArrayList<String> to retrieve the
>> values that have been
>> selected.
>> *** I'm expecting to see an ArrayList<String> coming
>> back, but instead a
>> XWorkList is being returned.
>> 
>> I've worked with Struts1 and WebWork before, and I
>> don't remember
>> using/seeing the XWorkList object before.
>> 
>> I've tried using the ######-conversion.properties
>> process, but this will
>> only help convert the elements of the Collection.
>> 
>> *** Is there a way to have an ArrayList returned
>> instead of the XWorkList?
>> 
>> I have a feeling I'm missing something basic...
>> 
>> The code that's in the Action:
>> 
>> 	// Populate the checkboxlist with these...
>> 	public List<Parent> testList = new
>> ArrayList<Parent>();
>> 	public ArrayList<Parent> testArrayList = new
>> ArrayList<Parent>();
>> 
>> 	// Retrieve the values selected from the form
>> 	public ArrayList<String> valuesList = new
>> ArrayList<String>();
>> 	public ArrayList<String> valuesArrayList = new
>> ArrayList<String>();
>> 
>> 	//... Getters and Setters for the "values###" ...
>> 	...
>> 	...
>> 
>>         // Create the Parent objects to place in the
>> Lists
>> 	public void validate() {
>> 
>>         	Parent parent1ForList = new Parent("Check
>> 1");
>>         	Parent parent2ForList = new Parent("Check
>> 2");
>>         	Parent parent3ForList = new Parent("Check
>> 3");
>>         
>>         	Parent parent1ForArrayList = new
>> Parent("Check 1");
>>         	Parent parent2ForArrayList = new
>> Parent("Check 2");
>>         	Parent parent3ForArrayList = new
>> Parent("Check 3");
>> 
>>         	testList.add(parent1ForList);
>>         	testList.add(parent2ForList);
>>         	testList.add(parent3ForList);
>>         
>>         	testArrayList.add(parent1ForArrayList);
>>         	testArrayList.add(parent2ForArrayList);
>>         	testArrayList.add(parent3ForArrayList);
>> 
>> 	}
>> 
>> 
>> The code that's in the JSP:
>> 
>> 	CheckBoxList created from a "List":
>> 	<BR><BR>
>> 	<s:checkboxlist name="valuesList" list="testList"
>> listKey="id"
>> listValue="name"/>
>> 
>> 	<BR><BR>
>> 
>> 	CheckBoxList created from a "ArrayList":
>> 	<BR><BR>
>> 	<s:checkboxlist name="valuesArrayList"
>> list="testArrayList" listKey="id"
>> listValue="name"/>
>> 
>> 
>> What I'm getting back from "valueslist" and
>> "valuesArrayList" via
>> "getClass()":
>> 
>> 	class com.opensymphony.xwork2.util.XWorkList
>> 
>> 
>> Thanks
>> -- 
>> View this message in context:
>>
> http://www.nabble.com/-Struts2--CheckBoxList-returns-XWorkList-instead-of-ArrayList-tf4642221.html#a13259251
>> 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
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-Struts2--CheckBoxList-returns-XWorkList-instead-of-ArrayList-tf4642221.html#a13267284
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: [Struts2] CheckBoxList returns XWorkList instead of ArrayList

Posted by Dave Newton <ne...@yahoo.com>.
Isn't XWorkList a sub-class of ArrayList?

--- Jon D Cruz <jo...@wachovia.com> wrote:

> 
> I've been wracking my brains on this issue for the
> last day and wonder if
> someone out there can help.
> 
> *** I'm using an ArrayList<Parent> to populate a
> CheckBoxList on my JSP.
> *** The Parent object has an "id" and "name" field.
> *** I'm using an ArrayList<String> to retrieve the
> values that have been
> selected.
> *** I'm expecting to see an ArrayList<String> coming
> back, but instead a
> XWorkList is being returned.
> 
> I've worked with Struts1 and WebWork before, and I
> don't remember
> using/seeing the XWorkList object before.
> 
> I've tried using the ######-conversion.properties
> process, but this will
> only help convert the elements of the Collection.
> 
> *** Is there a way to have an ArrayList returned
> instead of the XWorkList?
> 
> I have a feeling I'm missing something basic...
> 
> The code that's in the Action:
> 
> 	// Populate the checkboxlist with these...
> 	public List<Parent> testList = new
> ArrayList<Parent>();
> 	public ArrayList<Parent> testArrayList = new
> ArrayList<Parent>();
> 
> 	// Retrieve the values selected from the form
> 	public ArrayList<String> valuesList = new
> ArrayList<String>();
> 	public ArrayList<String> valuesArrayList = new
> ArrayList<String>();
> 
> 	//... Getters and Setters for the "values###" ...
> 	...
> 	...
> 
>         // Create the Parent objects to place in the
> Lists
> 	public void validate() {
> 
>         	Parent parent1ForList = new Parent("Check
> 1");
>         	Parent parent2ForList = new Parent("Check
> 2");
>         	Parent parent3ForList = new Parent("Check
> 3");
>         
>         	Parent parent1ForArrayList = new
> Parent("Check 1");
>         	Parent parent2ForArrayList = new
> Parent("Check 2");
>         	Parent parent3ForArrayList = new
> Parent("Check 3");
> 
>         	testList.add(parent1ForList);
>         	testList.add(parent2ForList);
>         	testList.add(parent3ForList);
>         
>         	testArrayList.add(parent1ForArrayList);
>         	testArrayList.add(parent2ForArrayList);
>         	testArrayList.add(parent3ForArrayList);
> 
> 	}
> 
> 
> The code that's in the JSP:
> 
> 	CheckBoxList created from a "List":
> 	<BR><BR>
> 	<s:checkboxlist name="valuesList" list="testList"
> listKey="id"
> listValue="name"/>
> 
> 	<BR><BR>
> 
> 	CheckBoxList created from a "ArrayList":
> 	<BR><BR>
> 	<s:checkboxlist name="valuesArrayList"
> list="testArrayList" listKey="id"
> listValue="name"/>
> 
> 
> What I'm getting back from "valueslist" and
> "valuesArrayList" via
> "getClass()":
> 
> 	class com.opensymphony.xwork2.util.XWorkList
> 
> 
> Thanks
> -- 
> View this message in context:
>
http://www.nabble.com/-Struts2--CheckBoxList-returns-XWorkList-instead-of-ArrayList-tf4642221.html#a13259251
> 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
> 
> 


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