Hello Everyone:
I am a neophyte JSP programmer. I create a small web application
inorder to enhance my programming skills. Although, this web application
is running but I encounter a problem in the html:select tags.
There are only two options in my html:select tag(admin and ordinary) but
during the browser display the options will double.
Pls. help.
CESAR V.
Below is my jsp code.
Code:
<%@ 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>
<head>
<title>SPC WF System</title>
<style type="text/css">
<!--
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
}
.style2 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; }
-->
</style>
</head>
<html:form action="/dispatchfromMaintConfirm">
<body>
<table border="0" width="600">
<%-- Error Display --%>
<tr><td><font color="red"><html:errors/></font></td></tr>
<tr>
<td align="center"><h2><bean:message key="prompt.maint.title"/></td>
</tr>
<tr>
<td align="center">
<bean:message key="prompt.maint.input"/>
<br>
</td>
</tr>
<tr>
<td align="center">
<table border="1">
<tr>
<th>EMP ID</th>
<td><html:text name="loginForm" property="emp_id" maxlength="10"/></td>
</tr>
<tr>
<th>LastName</th>
<td><html:text name="loginForm" property="lname" maxlength="30"/></td>
</tr>
<tr>
<th>FirstName</th>
<td><html:text name="loginForm" property="fname" maxlength="30"/></td>
</tr>
<tr>
<th>MI</th>
<td><html:text name="loginForm" property="mi" maxlength="30"/></td>
</tr>
<tr>
<th>Username</th>
<td><html:text name="loginForm" property="username" maxlength="20"/></td>
</tr>
<tr>
<th>Permission</th>
<%--<td><html:text name="loginForm" property="permission"
size="10"/></td>--%>
<bean:define id="list" name="loginForm" property="comboList"
type="java.util.ArrayList"/>
<td><html:select property="permission" name="loginForm">
<html:options collection="list" property="label" labelProperty="label"/>
</html:select>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<html:submit property="action"><bean:message key="button.submit"/></html:submit>
<html:submit property="action"><bean:message key="button.back"/></html:submit>
</td>
</tr>
</table>
</body>
</html:form>
</html:html>
A portion of my action form class:
Code:
public ArrayList getComboList() {
return comboList;
}
/**
* @param comboList the comboList to set
*/
public void setComboList(ArrayList comboList) {
this.comboList = comboList;
}
/* (non-Javadoc)
* @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
*/
@Override
public void reset(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
//super.reset(arg0, arg1);
comboList.add(new LabelValueBean("admin","admin"));
comboList.add(new LabelValueBean("ordinary","ordinary"));
}