Hello all,
following is my jsp file names register.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!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>Registration Process Form</title>
</head>
<body>
<s:form action="registeraction" method="post">
<s:label name="formName" value="Employee Registration Form........"/>
<s:textfield name="username" label="First Name"></s:textfield>
<s:textfield name="Lastname" label="Last Name"></s:textfield>
<s:textfield name="surName" label="Sur Name"></s:textfield>
<s:textarea name="address" label="Physical Address" cols="20" rows="5"></s:textarea>
<s:radio name="gender" label="Gender" list="{'Male','Female'}" />
<s:select name="country" list="countryList" listKey="countryId" listValue="countryName" headerKey="0" label="Select a country" />
<s:checkboxlist list="zList" name="community" label="Branch" />
<s:submit method="execute" value="Register Employee" align="center" />
<p><a href="<s:url action='Backaction'/>">Back To Main Page</a></p>
</s:form>
</body>
</html>
when i submit the form with out entering the first name...i have put the validation in UIaction.java file..like..
but i will get the following error and my page is not showing me county combobox and as well as submit button..
tag 'select', field 'list', name 'country': The requested list key 'countryList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:231)
at org.apache.struts2.components.Component.findValue(Component.java:293)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:79)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:99)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:780)
at org.apache.struts2.components.UIBean.end(UIBean.java:481)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
at org.apache.jsp.Register_jsp._jspx_meth_s_005fselect_005f0(Register_jsp.java:337)
at org.apache.jsp.Register_jsp._jspx_meth_s_005fform_005f0(Register_jsp.java:153)
at org.apache.jsp.Register_jsp._jspService(Register_jsp.java:90)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:139)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:150)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:48)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(Con
pls help me to solve the above problem
following is my coding detail..
method code for this is:-
public String execute() {
if(this.username.length()==0){
addFieldError("username", "Please enter the First name User");
}
return "success";
}
public String populate(){
countryList = new ArrayList<Country>();
countryList.add(new Country(1, "India"));
countryList.add(new Country(1, "Shri Lanka"));
countryList.add(new Country(1, "USA"));
countryList.add(new Country(1, "Pakistan"));
countryList.add(new Country(1, "NewsLnad"));
zList =new ArrayList<String>();
zList.add("Information Tech.");
zList.add("Computer Eng.");
zList.add("Mechnical.");
zList.add("Civil");
zList.add("Electrical");
community = new String[]{"Information Tech.","Computer Eng."};
return "populate";
}
and my struts.xml part is following for the above action..
<action name="formdataaction"
class="UiAction" method="populate">
<result name="populate">/Register.jsp</result>
</action>
<action name="registeraction"
class="UiAction" method="execute">
<result name="error">/Register.jsp</result>
<result name="success">/sucess.jsp</result>
</action>
</package>
</struts>
thanks
yatin