You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Hoying, Ken" <Ke...@PremierInc.com> on 2008/05/20 14:36:33 UTC

Struts[2] : Checkboxlist Problems

I have a list of search filters that I am displaying on the page where
each is a checkboxlist.  I am implementing this as such:

<s:iterator value="searchCriteria.filters" status="filterStatus">
	<s:checkboxlist 
	
name="searchCriteria.filterMap['%{fieldName}'].selectedFilters" 
		value="%{selectedFilters}"

		list="filterItems" listKey="value" listValue="label"/>
</s:iterator>

Everything works great except for one small problem.  I do not seem to
be able to deselect all of the values for a filter.  For example, if one
of my filters is Status and the check box values are Active and Inactive
then:

- I can select both Active and Inactive.
- I can leave both Active and Inactive deselected.
- I can default to have Active selected and then deslect it and then
select Inactive.
- I CANNOT default to have Active selected and then deselect it. 

It appears that if a checkbox was originally set you can change the
value as long as you change it to some other value.  However if I do not
set the field to any value at all, then it keeps the previous or default
value.

I am not sure what is occurring here.  Does anyone have any ideas on how
I can overcome this?

Thank you!
Ken

RE: Struts[2] : Checkboxlist Problems

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,

i solved this problem the following way:

1. created a custom reset interceptor to set the action class field of
checkbox.
2. placed the interceptor just after the scope interceptor (in ur
struts.xml) 

when u deselect all the checkboxes then the HTML doesnt submit any values to
the action class and hence the class doesnt update the field value. So, here
we always reset the respective field so  the field is updated only iff some
checkbox values are sent by the HTML.

hope this helps.
cheers,
ravi  


Hoying, Ken-2 wrote:
> 
> I did not have any errors.  I am not sure exactly what I was doing that
> caused this not to work, but I reorganized my code in the action class
> and was able to make things work.   
> 
> -----Original Message-----
> From: Greg Lindholm [mailto:glindholm@yahoo.com] 
> Sent: Tuesday, May 20, 2008 2:37 PM
> To: user@struts.apache.org
> Subject: Re: Struts[2] : Checkboxlist Problems
> 
> 
> Are you getting any errors?
> 
> There is a bug in the CheckboxInterceptor where it does not properly
> handling arrays of checkboxes when none are selected.  It might be
> related, but this issue did causes error messages.
> 
> I submitted a patch for this issue WW-2339.  
> https://issues.apache.org/struts/browse/WW-2339
> 
> 
> 
> Hoying, Ken-2 wrote:
>> 
>> I have a list of search filters that I am displaying on the page where
> 
>> each is a checkboxlist.  I am implementing this as such:
>> 
>> <s:iterator value="searchCriteria.filters" status="filterStatus">
>> 	<s:checkboxlist
>> 	
>> name="searchCriteria.filterMap['%{fieldName}'].selectedFilters" 
>> 		value="%{selectedFilters}"
>> 
>> 		list="filterItems" listKey="value" listValue="label"/>
> </s:iterator>
>> 
>> Everything works great except for one small problem.  I do not seem to
> 
>> be able to deselect all of the values for a filter.  For example, if 
>> one of my filters is Status and the check box values are Active and 
>> Inactive
>> then:
>> 
>> - I can select both Active and Inactive.
>> - I can leave both Active and Inactive deselected.
>> - I can default to have Active selected and then deslect it and then 
>> select Inactive.
>> - I CANNOT default to have Active selected and then deselect it. 
>> 
>> It appears that if a checkbox was originally set you can change the 
>> value as long as you change it to some other value.  However if I do 
>> not set the field to any value at all, then it keeps the previous or 
>> default value.
>> 
>> I am not sure what is occurring here.  Does anyone have any ideas on 
>> how I can overcome this?
>> 
>> Thank you!
>> Ken
>> 
>> 
> 
> --
> View this message in context:
> http://www.nabble.com/Struts-2--%3A--Checkboxlist-Problems-tp17339322p17
> 347543.html
> 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/Struts-2--%3A--Checkboxlist-Problems-tp17339322p17355805.html
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: Struts[2] : Checkboxlist Problems

Posted by "Hoying, Ken" <Ke...@PremierInc.com>.
I did not have any errors.  I am not sure exactly what I was doing that
caused this not to work, but I reorganized my code in the action class
and was able to make things work.   

-----Original Message-----
From: Greg Lindholm [mailto:glindholm@yahoo.com] 
Sent: Tuesday, May 20, 2008 2:37 PM
To: user@struts.apache.org
Subject: Re: Struts[2] : Checkboxlist Problems


Are you getting any errors?

There is a bug in the CheckboxInterceptor where it does not properly
handling arrays of checkboxes when none are selected.  It might be
related, but this issue did causes error messages.

I submitted a patch for this issue WW-2339.  
https://issues.apache.org/struts/browse/WW-2339



Hoying, Ken-2 wrote:
> 
> I have a list of search filters that I am displaying on the page where

> each is a checkboxlist.  I am implementing this as such:
> 
> <s:iterator value="searchCriteria.filters" status="filterStatus">
> 	<s:checkboxlist
> 	
> name="searchCriteria.filterMap['%{fieldName}'].selectedFilters" 
> 		value="%{selectedFilters}"
> 
> 		list="filterItems" listKey="value" listValue="label"/>
</s:iterator>
> 
> Everything works great except for one small problem.  I do not seem to

> be able to deselect all of the values for a filter.  For example, if 
> one of my filters is Status and the check box values are Active and 
> Inactive
> then:
> 
> - I can select both Active and Inactive.
> - I can leave both Active and Inactive deselected.
> - I can default to have Active selected and then deslect it and then 
> select Inactive.
> - I CANNOT default to have Active selected and then deselect it. 
> 
> It appears that if a checkbox was originally set you can change the 
> value as long as you change it to some other value.  However if I do 
> not set the field to any value at all, then it keeps the previous or 
> default value.
> 
> I am not sure what is occurring here.  Does anyone have any ideas on 
> how I can overcome this?
> 
> Thank you!
> Ken
> 
> 

--
View this message in context:
http://www.nabble.com/Struts-2--%3A--Checkboxlist-Problems-tp17339322p17
347543.html
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


Re: Struts[2] : Checkboxlist Problems

Posted by Greg Lindholm <gl...@yahoo.com>.
Are you getting any errors?

There is a bug in the CheckboxInterceptor where it does not properly
handling arrays of checkboxes when none are selected.  It might be related,
but this issue did causes error messages.

I submitted a patch for this issue WW-2339.  
https://issues.apache.org/struts/browse/WW-2339



Hoying, Ken-2 wrote:
> 
> I have a list of search filters that I am displaying on the page where
> each is a checkboxlist.  I am implementing this as such:
> 
> <s:iterator value="searchCriteria.filters" status="filterStatus">
> 	<s:checkboxlist 
> 	
> name="searchCriteria.filterMap['%{fieldName}'].selectedFilters" 
> 		value="%{selectedFilters}"
> 
> 		list="filterItems" listKey="value" listValue="label"/>
> </s:iterator>
> 
> Everything works great except for one small problem.  I do not seem to
> be able to deselect all of the values for a filter.  For example, if one
> of my filters is Status and the check box values are Active and Inactive
> then:
> 
> - I can select both Active and Inactive.
> - I can leave both Active and Inactive deselected.
> - I can default to have Active selected and then deslect it and then
> select Inactive.
> - I CANNOT default to have Active selected and then deselect it. 
> 
> It appears that if a checkbox was originally set you can change the
> value as long as you change it to some other value.  However if I do not
> set the field to any value at all, then it keeps the previous or default
> value.
> 
> I am not sure what is occurring here.  Does anyone have any ideas on how
> I can overcome this?
> 
> Thank you!
> Ken
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2--%3A--Checkboxlist-Problems-tp17339322p17347543.html
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