You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Torsten Römer <to...@luniks.net> on 2007/06/05 00:53:41 UTC

Re: Struts2 Dynamic Checkboxes

Ah, I am such a dingbat... the beans in my list contained a property
with the same name as I used for the Collection property in the backing
bean. So when the tag was checking if the option was there or not it was
looking at some boolean property of that bean instead into the Collection.

Not before I downloaded the Struts2 source and debugged the
ListUIBean.compare() method I realized that ;-)

So this answers my question, and I am happy to say that my dynamic
checkboxes now work perfectly!

The Dingbat

Torsten Römer schrieb:
> I think I found an OK solution but one thing does not work and I don't
> understand why.
> 
> So what I am doing is creating single checkboxes in an iterator,
> disabling the automatically generated label through a modified "simple"
> theme and creating my custom labels:
> 										<s:iterator value="cars">
>   <s:label>
>     <s:checkboxlist templateDir="template"
>                     template="checkboxlist.ftl"
>                     theme="nolabel"
>                     name="car"
>                     list="%{''+name}"/>						    <s:text
> name="format.moneyround"><s:param value="price"/></s:text>
>     <s:property value="name"/>							  </s:label>									</s:iterator>
> 
> "cars" is a List of simple beans with, among other, a "name" property.
> The "car" property is a Collection. When I check a checkbox and submit
> the form, I can see that an XWorkList containing the value is passed to
> setCar().
> BUT: When the form is redisplayed, as because of a validation error, the
> getCar() method is not called and the checkbox is not checked.
> 
> Can anyone tell me why?
> 
> If I move the <s:checkboxlist> tag outside the <s:iterator>, it works,
> but like this I can't create my custom labels, which is what this is all
> about...
> 
> Torsten
> 
> Torsten Römer schrieb:
>> Well, why not try both ways... it will be a good exercise no matter what.
>>
>> I'll get back when I have some interesting experiences to share with.
>>
>> Thanks again!
>>
>> Torsten
>>
>> Dave Newton schrieb:
>>> --- Torsten Römer <to...@luniks.net> wrote:
>>>> I see there is no point in what I am trying to do.
>>> Oh, I don't know about that.
>>>
>>> You could use a map (or list) for the checkbox values
>>> and gather up the result values that way, couldn't
>>> you? 
>>>
>>> You just need to pre-populate the map (or list) in the
>>> action before hitting the view.
>>>
>>> d.
>>>
>>>
>>>
>>>        
>>> ____________________________________________________________________________________Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
>>> http://answers.yahoo.com/dir/?link=list&sid=396545469
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
> 
> ---------------------------------------------------------------------
> 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