• 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

to get value of disabled check box value in action class

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am having a set of check boxes in my jsp. all those r represented by one string array property ( "hqcs" is of String array type )of my action form.




and part my jsp is:
-------------------

<logic:iterate id="row" name="paForm" property="hqcs" indexId="ctr">
<%
int i=ctr.intValue();
String str =Integer.toString(i);

%>
<tr>
<td nowrap>
<html:multibox styleClass="selbox" name="paForm" property="hqccheck" value='<%=str%>'

</logic:iterate>


part MY ACTION class code is:
------------------------
hqcchk = paForm.getHqccheck();
if(hqcchk !=null ){
for (int i = 0; i < hqcchk.length; i++) {
System.out.println("hqcchk[i] :"+hqcchk[i]);
if(hqcchk[i]!="")
selhqc.add(hqc.get(Integer.parseInt(hqcchk[i])));
}
}//if
----------------------

upto now i hav no problem with this code. it is working fine.

But now those check boxes should be in disabled mode. for that i hav put disabled="true" in <html:multibox > tag. Then in action class i m getting null with
hqcchk = paForm.getHqccheck();
this statement.

wat is the problem if i put disabled=true;
How to get disabled checkbox values in action class.
anyone can help me in this regard.
thank you a lot.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Disabled HTML form fields don't get submitted with the form.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
Disabled HTML form fields don't get submitted with the form.



hi Ben,

Disabled form fields will get submitted with the form.
I am getting the value in action class with this code,

<bsk:checkbox property="ischk" value="Y" disabled="true" styleClass="selbox"/>
everytime my JSP is submitting .

I am getting the value as on/off in action class.


But here, Jakeer's problem is, he is having a string array property in action form, which represents a group of checkboxes in disabled state.
How to get the state of all the check boxes in the action class?
Im also interested to know this.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Anna Francis:


hi Ben,

Disabled form fields will get submitted with the form.
I am getting the value in action class with this code,

<bsk:checkbox property="ischk" value="Y" disabled="true" styleClass="selbox"/>
everytime my JSP is submitting .

I am getting the value as on/off in action class.


But here, Jakeer's problem is, he is having a string array property in action form, which represents a group of checkboxes in disabled state.
How to get the state of all the check boxes in the action class?
Im also interested to know this.



If your using a tag library that does something other than just create a standard HTML checkbox, then you will have to check with the makers of that tag library. Look at the HMTL source to see what's being generated.

If you create a plain old HTML form and add the "disabled" keyword to one of it's input fields, the name/value pair for that field will not be included in the request's post.

Furthermore, a checkbox (or radio button) that is not checked sends nothing.
This means that the only value you will be able to read is the one for the checked item.

Again, the taglib you're using may be generating addtional hidden form fields to provide extra functionality.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I perfectly agree with ben


Only the successfull control objects(i.e which are checked) are posted. And all the unchecked controls are not submitted
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At the time of iteration on jsp, define a hidden field and put your value in that.

In Action, you can retrieve the value of hidden field.
 
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic