You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fea jabi <zy...@hotmail.com> on 2005/12/27 18:45:42 UTC

html:multibox reset?

I am using html:multibox in my jsp.

I am not sure when the reset method is needed. Not sure if I have to use it. 
I have declared my formbeans in config file itself. If I have to use how to 
use that?

I am having the below code now to display a group of checkboxes in a column 
of a table.

<form-bean>
     <form-property name="Items" type="java.util.ArrayList"/>
        <form-property name="SelectedItems" type="java.util.ArrayList"/>
</form-bean>



In prepare Action
...............
...............

LabelValueBean lblValueBean1 = new LabelValueBean("Visa1", "V1");
LabelValueBean lblValueBean2 = new LabelValueBean("MasterCard1", "M1");


ArrayList misList = new ArrayList();
misList.add(lblValueBean1);
misList.add(lblValueBean2);

ArrayList selectedList = new ArrayList();
selectedList.add(lblValueBean1);

form.set("Items", misList);
form.set("SelectedItems", selectedList);
.....................
.


In JSP
............
..........
<logic:iterate id="item" property="Items">
   <html:multibox property="selectedItems">
         <bean:write name="item" property="value"/>
   </html:multibox>
         <bean:write name="item" property="label"/>
</logic:iterate>


Thanks.

_________________________________________________________________
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: html:multibox reset?

Posted by Laurie Harper <la...@holoweb.net>.
fea jabi wrote:
> I am using html:multibox in my jsp.
> 
> I am not sure when the reset method is needed. Not sure if I have to use 
> it. I have declared my formbeans in config file itself. If I have to use 
> how to use that?

Multibox is just another way of managing checkboxes, so the same caveats 
apply as with any other checkbox backing property: if you want to be 
able to recognize when a checkbox is de-selected, you must arrange for 
the backing property to be set to false before it's populated from the 
request.

> I am having the below code now to display a group of checkboxes in a 
> column of a table.
> 
> <form-bean>
>     <form-property name="Items" type="java.util.ArrayList"/>
>        <form-property name="SelectedItems" type="java.util.ArrayList"/>
> </form-bean>

Your from bean doesn't have a type declared. That's not going to work, 
since Struts can't know what class to instantiate if you don't tell it.

L.

> In prepare Action
> ...............
> ...............
> 
> LabelValueBean lblValueBean1 = new LabelValueBean("Visa1", "V1");
> LabelValueBean lblValueBean2 = new LabelValueBean("MasterCard1", "M1");
> 
> 
> ArrayList misList = new ArrayList();
> misList.add(lblValueBean1);
> misList.add(lblValueBean2);
> 
> ArrayList selectedList = new ArrayList();
> selectedList.add(lblValueBean1);
> 
> form.set("Items", misList);
> form.set("SelectedItems", selectedList);
> .....................
> .
> 
> 
> In JSP
> ............
> ..........
> <logic:iterate id="item" property="Items">
>   <html:multibox property="selectedItems">
>         <bean:write name="item" property="value"/>
>   </html:multibox>
>         <bean:write name="item" property="label"/>
> </logic:iterate>
> 
> 
> Thanks.
> 
> _________________________________________________________________
> 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