aspose file tools*
The moose likes Struts and the fly likes Retriving values from  html:checkbox  in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Retriving values from  html:checkbox  in a jsp" Watch "Retriving values from  html:checkbox  in a jsp" New topic
Author

Retriving values from html:checkbox in a jsp

skumar mk
Greenhorn

Joined: Jul 02, 2008
Posts: 12
Hai All,

Am facing a problem to retrive the values from the <html:chechbox>
Am using code like this:

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html>
<body>
<html:form action="/log" method ="post">
<table width="500" border="0">
<tr>
<td>username :</td>
<td><html:text property="username" /></td>
</tr>
<tr>
<td>password : <br><br></td>
<td><html assword property="password" /><br><br></td>
</tr>
<tr>
<td><html:submit property="login" value="ADD"></td>
</tr>
</table>
<logic resent name="LIST_ELEMENTS" scope="request">

<logic:iterate id="myvalues" name="LIST_ELEMENTS">

<html:checkbox property="ck_values" >

<bean:write name="myvalues" />

</html:checkbox>

</logic:iterate>
</logic resent>

</html:form>

</body>
</html:html>


In the action class am setting the values ArrayList and storing it in the request scope

java.util.ArrayList list = new java.util.ArrayList();
list.add(vmarks);
list.add(vid);
request.setAttribute("LIST_ELEMENTS",list);

I need the values selected from the checkbox (vmarks,vid). when am using request.getString("ck_values") am getting ON then how can i retrive the slected values in my action class.


Please help me out.


Thanks in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Use html:multibox instead of html:checkbox. It still produces checkboxes, but is designed to be used with a group of related checkboxes all with the same property name. Below is the link to do documentation.

http://struts.apache.org/1.3.8/struts-taglib/tlddoc/html/multibox.html


Merrill
Consultant, Sima Solutions
 
Don't get me started about those stupid light bulbs.
 
subject: Retriving values from html:checkbox in a jsp