Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

to get value of disabled check box value in action class

 
jakeer ahmed
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Disabled HTML form fields don't get submitted with the form.
 
Anna Francis
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Srinivas Mallela
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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
 
Amit Kumar Kaushik
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic