Hi All;
Please help me.This is my issue: I amnew struts2.Its going inside the validate() , but not display in browser.
Action class is:
public class UserAction extends ActionSupport {
private CountryDAO countryDAO = new CountryDAO();
private List<User> lstUser;
private User user;
private UserDAO userDAO = new UserDAO();
public UserAction(){
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public
String execute(){
try {
userDAO.persisteUserCountry(getUser().getCountry().getName(), user);
}catch(Exception e) {
System.out.println("----" + e.getMessage());
e.printStackTrace();
}
return SUCCESS;
}
public void validate(){
if(getUser().getUsername().length() == 0){
addActionMessage("User Name is required");
}
if(getUser().getPassword().length() == 0){
addActionMessage("Password is required");
}
if(getUser().getPassword().length() > 6){
addActionMessage( "Minimum passsword length is 6");
}
System.out.println("###########" + this.hasActionMessages());
}
My Jsp is like this:
<s:fielderror/>
<s:actionerror/>
<s:actionmessage/>
<s:actionmessage/>
<div id="result">Submit form bellow.</div>
<s:form action="accountTypeAction" >
<s:textfield name="user.username" label="Email" required="true" />
<!-- <s:textfield name="confirmEmail" key="label.confirmmail" size="20" /> -->
<s:password name="user.password" label="Password" required="true"/>
<s:select name="user.accountType" label="Account Type" list="#{'peronal':'peronal','company':'company'}" />
<s:select label="Country of residence" name="user.country.name" headerKey="- - -"
headerValue="Select Country"
list="#session.countries"
listKey="id"
listValue="name" />
and struts.xml is :
<
struts>
<include file="struts-default.xml"/>
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="accountType" class="com.providence.pgw.action.CountryAction">
<result name="success">userAccountType.jsp</result>
</action>
<action name="accountTypeAction" class="com.providence.pgw.action.UserAction">
<result name="input" type="redirect-action">accountType</result>
<result name="error" type="redirect-action">accountType</result>
<result name="success" >emailVarification.jsp</result>
</action>
<action name="emailVerify" class="com.providence.pgw.action.UserAction" method="displayPersonalInfo">
<interceptor-ref name="params" />
<interceptor-ref name="validation">
<param name="excludeMethods">displayPersonalInfo</param>
</interceptor-ref>
<result name="input" >activationKeyExit.jsp</result>
<result name="error" >errorActivationKey.jsp</result>
<result name="success">personalDetails.jsp</result>
</action>
</package>
</struts>
When I submit the form its going inside the validate method and redirect to input. But not display error message in browser.
Please anybody help me soon.
Thanks for advancce.
S.Piraba