<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>
<head>
<html:base />
<title>example.jsp</title>
<script type="text/javascript" language="javascript">
var temp = new Array();
function checkForm( id ) {
var form = document.getElementById( id );
if ( form ) {
var result = '', comma = '';
for ( var i = 0; i < form.length; ++i ) {
var here = form.elements[ i ];
if ( ( here.type == 'checkbox' ) && here.checked ) {
result += comma + here.value;
comma = ', ';
}
}
alert( 'Selected: ' + result );
} else {
alert( 'Form not found: id = "' + id + '"' );
}
document.getElementById("checkboxvalues").value=result;
}
function onPage()
{
alert(document.getElementById("checkboxvalues").value)
document.forms[0].action="/example.do?checkboxval="+document.getElementById("checkboxvalues").value;
document.forms[0].submit();
}
</script>
</head>
<body>
<html:form action="example.do">
<h3>
Simple paging with struts tags.
</h3>
<table border="1">
<tr>
<td>
<b> </b>
</td>
<td>
<b>ID</b>
</td>
<td>
<b>Name</b>
</td>
<td>
<b>City</b>
</td>
<td>
<b>Phone</b>
</td>
</tr>
<%-- Iteration over the list --%>
<logic:iterate name="testList" property="listByOffsetAndLength"
id="var">
<tr>
<td>
<html:multibox property="control"
value='<bean:write name="var" property="id"/>' onclick="checkForm('Form')" />
</td>
<td>
<bean:write name="var" property="id" />
</td>
<td>
<bean:write name="var" property="name" />
</td>
<td>
<bean:write name="var" property="city" />
</td>
<td>
<bean:write name="var" property="phone" />
</td>
</tr>
</logic:iterate>
<tr>
<td colspan="5">
<logic:iterate name="testList" property="pages" id="varpage">
<html:link action="/example" paramName="varpage" paramId="page" >
<bean:write name="varpage" />
<input type="hidden" name="checkboxval" value="1"/>
</html:link>
</logic:iterate>
</td>
</tr>
</table>
</html:form>
</body>
</html:html> |