You can set the "value" property to "true" to make this check box checked. Understood?
For example, you can write the code like this: < s:checkbox name="authority" fieldValue="ORIGINATOR" value="%{var}" > while the "var" is in the server side.
Well, this is an example:
the a.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="Handler" method="post">
<s:checkbox name="authority" fieldValue="ORIGINATOR" label="ORIGINATOR"/>
<s:checkbox name="authority" fieldValue="EVALUATOR" label="EVALUATOR"/>
<s:checkbox name="authority" fieldValue="EXECUTOR" label="EXECUTOR"/>
<s:submit label="Submit"></s:submit>
</s:form>
</body>
</html>
b.jsp
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form>
<s:checkbox name="authority" fieldValue="ORIGINATOR" value="%{isORIGINATORSet}" label="ORIGINATOR"/>
<s:checkbox name="authority" fieldValue="EVALUATOR" value="%{isEVALUATORSet}" label="EVALUATOR"/>
<s:checkbox name="authority" fieldValue="EXECUTOR" value="%{isEXECUTORSet}" label="EXECUTOR"/>
</s:form>
</body>
</html>
The handler is:
package com.sesoft.test;
import com.opensymphony.xwork2.Action;
public class Handler implements Action{
private String isORIGINATORSet = "false";
private String isEVALUATORSet = "false";
private String isEXECUTORSet = "false";
private String[] authority;
@Override
public String execute() throws Exception {
for(String s : authority){
if(s.equals("ORIGINATOR"))
isORIGINATORSet = "true";
if(s.equals("EVALUATOR"))
isEVALUATORSet = "true";
if(s.equals("EXECUTOR"))
isEXECUTORSet = "true";
}
return Action.SUCCESS;
}
public void setAuthority(String[] authority){
this.authority = authority;
}
public String getIsORIGINATORSet(){
return this.isORIGINATORSet;
}
public String getIsEVALUATORSet(){
return this.isEVALUATORSet;
}
public String getIsEXECUTORSet(){
return this.isEXECUTORSet;
}
}