• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with CheckBox and MultiBox

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks,
Inspite of using all the advices about using Checkbox and MultiBoxes in my form, it still doesn't work. It doesn't remember the box(es) being checked. Here is the code snippet of my JSP, ActionForm and DispatchAction. I'm using <html:multibox> for a single checkbox. (I used boolean property also, but it didn't work):

ActionForm (say its name is "myForm"):
private String[] signature = {};
private String signChk;

Reset method():
signature = new String[] {};
signChk = new String("false");

My JSP:
<bean efine id="checkme" name="myForm" property="signChk" type="java.lang.String" />
<html:multibox property="signature">
<bean:write name="checkme" />
</html:multibox>


I also tries using <html:checkbox> but in vain. Here is the code snippet for that:

ActionForm (say its name is "myForm"):
private boolean newChk;

Reset method():
newChk = false;

My JSP:
<html:checkbox property="newChk" />


I'm using Websphere 5.1. I've already spent too much time on this.
Please help as I'm nearing a deadline. I nver thought it would be so difficult using checkboxes.
Would really appreciate your help.

Thanks
Upen
 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this example
Put following code in your form bean page
public LabelValueBean[] getEquipment() {
LabelValueBean[] lvBeans = new LabelValueBean[12];

lvBeans[0] = new LabelValueBean("Laptop Computer", "LC");
lvBeans[1] =new LabelValueBean("External Storage Device(Zip Drive)", "ES");
lvBeans[2] = new LabelValueBean("Desktop Computer", "DC");
lvBeans[3] = new LabelValueBean("Color Printer", "CP");
lvBeans[4] = new LabelValueBean("Recordable CD Drive", "RD");
lvBeans[5] =
new LabelValueBean("Personal Digital Assistant(Pocket PC)", "PD");
lvBeans[6] = new LabelValueBean("Scanner", "SR");
lvBeans[7] = new LabelValueBean("Copier", "CR");
lvBeans[8] = new LabelValueBean("DVD Drive", "DD");
lvBeans[9] = new LabelValueBean("Fax Machine", "FM");
lvBeans[10] =
new LabelValueBean(
"Multi-Function Product(Fax/Copier/Pinter/Scanner in one)",
"MF");

lvBeans[11] = new LabelValueBean("None of Above", "NA");

this.equipment = lvBeans;
return equipment;
}
------------------------------------------------------------
put correpond code in jsp

<logic:iterate id="equip" name="interestsForm" property="equipment" >
<TD vAlign=top align=left width=401 height="35"><FONT face=Helvetica,Arial
size=2>
<html:multibox property="selectedEquipment">
<bean:write name="equip" property="value"/>
</html:multibox>
<bean:write name="equip" property="label"/>
</TD>
<%n++;if(n%2 ==0){%>
</TR>
<TR>
<%}%>
</logic:iterate>


Hope now u will not invest more hours.
 
Jignesh Patel
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this example
Put following code in your form bean page
public LabelValueBean[] getEquipment() {
LabelValueBean[] lvBeans = new LabelValueBean[12];

lvBeans[0] = new LabelValueBean("Laptop Computer", "LC");
lvBeans[1] =new LabelValueBean("External Storage Device(Zip Drive)", "ES");
lvBeans[2] = new LabelValueBean("Desktop Computer", "DC");
lvBeans[3] = new Labe
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vicky kumar:
I also tries using <html:checkbox> but in vain. Here is the code snippet for that:

ActionForm (say its name is "myForm"):
private boolean newChk;

Reset method():
newChk = false;

My JSP:
<html:checkbox property="newChk" />



In your reset method, try doing setNewChk(false) rather than newChk = false;
 
vicky kumar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Charles,
I tried using setter to set value to false inside RESET. It still doesn't work. Wondering if this is a bug in websphere. Does any one have the similar experience using checkbox/multiox in websphere 5.1.

Vicky
 
vicky kumar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jignesh,
Is this the only solution. Is it not too much of a work to display even a single checkbox.

Vicky
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic