struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gabriel Belingueres <belingue...@gmail.com>
Subject Re: validation in struts2
Date Wed, 20 Jan 2010 15:12:37 GMT
the form tag is wrong?

try:

<s:form action="doLogin" namespace="/tricky">

2010/1/19 Shasha <sarada.info@yahoo.com>:
>
> Hi All,
>
> I am not able to get the validation errors from Login-validation.xml when i
> am using Modeldriven .
>
> Login-validation.xml
>   1. <!DOCTYPE validators PUBLIC
>   2.         "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
>   3.         "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
>   4.
>   5. <validators>
>   6.     <field name="username">
>   7.         <field-validator type="requiredstring">
>   8.             <message key="requiredstring"/>
>   9.         </field-validator>
>  10.     </field>
>  11.     <field name="password">
>  12.         <field-validator type="requiredstring">
>  13.             <message key="requiredstring"/>
>  14.         </field-validator>
>  15.     </field>
>  16. </validators>
>
> LoginAction.java
>
>   1. public class LoginAction extends ActionSupport implements
> ModelDriven,SessionAware{
>   2.
>   3.     private User user = new User();
>   4.     private Map session;
>   5.     private UserDAO userDAO = new UserDAOImpl();
>   6.
>   7.     public String execute() throws Exception {
>   8.
>   9.         boolean success=userDAO.verifyUser(user);
>  10.         if (success)
>  11.         return SUCCESS;
>  12.         else
>  13.         return ERROR;
>  14.     }
>  15.
>  16.     public Object getModel() {
>  17.         return user;
>  18.     }
>  19.
>  20.     public void setSession(Map session) {
>  21.         this.session=session;
>  22.     }
>  23.
>  24.     public Map getSession() {
>  25.         return session;
>  26.     }
>  27.
>  28. }
>
> login.jsp
>
>   1. <%@ taglib prefix="s" uri="/struts-tags" %>
>   2. <html>
>   3. <head>
>   4. <title>Struts 2 Login Application!</title>
>   5.
>   6. <link href="<s:url value="/css/main.css"/>" rel="stylesheet"
> type="text/css"/>
>   7.
>   8. </head>
>   9. <body>
>  10. <s:form action="doLogin.action" method="POST">
>  11. <tr>
>  12.     <td colspan="2">Login</td>
>  13. </tr>
>  14. <tr>
>  15.    <td colspan="2">
>  16.         <s:actionerror />
>  17.          <s:fielderror />
>  18.    </td>
>  19. </tr>
>  20.
>  21.     <s:textfield name="username" label="Login name"/>
>  22.     <s:password name="password" label="Password"/>
>  23.     <s:submit value="Login" align="center"/>
>  24.
>  25. </s:form>
>  26.
>  27. </body>
>  28.
>  29. </html>
>
> http://old.nabble.com/file/p27236040/error.jpg
>
>
> --
> View this message in context: http://old.nabble.com/validation-in-struts2-tp27236040p27236040.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message