my dog learned polymorphism*
The moose likes Servlets and the fly likes to get value of disabled check box value in action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "to get value of disabled check box value in action class" Watch "to get value of disabled check box value in action class" New topic
Author

to get value of disabled check box value in action class

jakeer ahmed
Greenhorn

Joined: Jan 17, 2006
Posts: 15
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

Joined: Dec 11, 2004
Posts: 13410

Disabled HTML form fields don't get submitted with the form.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Anna Francis
Greenhorn

Joined: Jan 17, 2006
Posts: 1
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

Joined: Dec 11, 2004
Posts: 13410

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

Joined: Dec 16, 2004
Posts: 13
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

Joined: Jan 12, 2006
Posts: 11
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.
 
 
subject: to get value of disabled check box value in action class
 
Similar Threads
pass a variable in the URl
multi select boxes
enable/disable textbox
On htm:multibox
How to check multibox value is null?