- Revision
- 293
- Author
- fabio.kung
- Date
- 2007-07-27 15:19:10 -0500 (Fri, 27 Jul 2007)
Log Message
added default view suffix and (new) users validation
Modified Paths
- trunk/examples/mydvds-example/resources/fielderrors.jspx
- trunk/examples/mydvds-example/resources/user-added.jspx
- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/MyDvdsRegistrar.java
- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersController.java
- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersControllerValidator.java
- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/interceptor/AuthorizationInterceptor.java
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties
- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties
Added Paths
- trunk/examples/mydvds-example/resources/index.jspx
- trunk/examples/mydvds-example/resources/users.jspx
Removed Paths
Diff
Modified: trunk/examples/mydvds-example/resources/fielderrors.jspx (292 => 293)
--- trunk/examples/mydvds-example/resources/fielderrors.jspx 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/resources/fielderrors.jspx 2007-07-27 20:19:10 UTC (rev 293) @@ -1,7 +1,7 @@ -<c:forEach items="${errors.allErrorMessages}" var="error" - xmlns:c="http://java.sun.com/jsp/jstl/core"> - <script type="text/_javascript_"> - $('${error.name}').value = '${error.value}'; - $('${error.name}').style.border = 'solid red 2px'; - </script> -</c:forEach> +<ul> + <c:forEach xmlns:c="http://java.sun.com/jsp/jstl/core" + xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" + items="${errors.allErrorMessages}" var="error"> + <li><fmt:message key="${error.message}"/></li> + </c:forEach> +</ul>
Deleted: trunk/examples/mydvds-example/resources/index.jspx (292 => 293)
--- trunk/examples/mydvds-example/resources/index.jspx 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/resources/index.jspx 2007-07-27 20:19:10 UTC (rev 293) @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<jsp:root xmlns="http://www.w3.org/1999/xhtml" - xmlns:jsp="http://java.sun.com/JSP/Page" - xmlns:c="http://java.sun.com/jsp/jstl/core" - xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" - xmlns:w="http://waffle.codehaus.org" - version="2.0"> - <jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/> - <jsp:output doctype-public="-//W3C//DTD XHTML 1.1//EN" - doctype-root-element="html" - doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" - omit-xml-declaration="false"/> - <html> - <head> - <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> - <link href="" type="text/css" rel="stylesheet"/> - <script type="text/_javascript_" src="" - <script type="text/_javascript_" src="" - <script type="text/_javascript_" src="" - <script type="text/_javascript_" src="" - </head> - <body> - <div id="site"> - <h1 id="h1-marca"> - <a href="" src="" alt="waffle logo"/></a> - </h1> - - <c:if test="${not empty param.language}"> - <fmt:setLocale value="${param.language}" scope="session"/> - </c:if> - - <c:if test="${errors.errorMessageCount > 0}"> - <div id="error-box"> - <h1><fmt:message key="errors"/></h1> - <hr/> - - <c:import url="" - - </div> - </c:if> - - <div class="box"> - <h1><fmt:message key="change_language"/></h1> - <hr/> - <a href="" src="" border="0" alt="DE"/></a> | - <a href="" src="" border="0" alt="GB"/></a> | - <a href="" src="" border="0" alt="US"/></a> | - <a href="" src="" border="0" alt="BR"/></a> | - <a href="" src="" border="0" alt="IT"/></a> | - <a href="" src="" border="0" alt="ES"/></a> - </div> - - <br/><br/> - - <div class="box"> - <h1><fmt:message key="welcome"/></h1> - <hr/> - - <w:form action="" method="post" border="0" id="loginForm" type="table"> - <w:hidden name="method" value="login"/> - <w:text name="login" value="${login}"/> - <w:password name="password" value="${password}"/> - <w:submit/> - </w:form> - - </div> - - <br/><br/> - - <div class="box"> - - <h1><fmt:message key="new_user"/></h1> - <hr/> - - <w:form action="" method="post" id="addUserForm" type="table"> - <w:hidden name="method" value="add"/> - <w:text name="name" value="${user.name}"/> - <w:text name="login" value="${user.login}"/> - <w:password name="password" value="${user.password}"/> - <w:submit/> - </w:form> - - </div> - </div> - </body> - </html> -</jsp:root>
Added: trunk/examples/mydvds-example/resources/index.jspx (0 => 293)
--- trunk/examples/mydvds-example/resources/index.jspx (rev 0) +++ trunk/examples/mydvds-example/resources/index.jspx 2007-07-27 20:19:10 UTC (rev 293) @@ -0,0 +1,6 @@ +<jsp:root xmlns="http://www.w3.org/1999/xhtml" + xmlns:jsp="http://java.sun.com/JSP/Page" + xmlns:c="http://java.sun.com/jsp/jstl/core" + version="2.0"> + <c:redirect url="" +</jsp:root> \ No newline at end of file
Modified: trunk/examples/mydvds-example/resources/user-added.jspx (292 => 293)
--- trunk/examples/mydvds-example/resources/user-added.jspx 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/resources/user-added.jspx 2007-07-27 20:19:10 UTC (rev 293) @@ -26,7 +26,7 @@ <div class="box"> <h2>User added successfully.</h2> - <c:url value="/index.jspx" var="loginPage"/> + <c:url value="/users.waffle" var="loginPage"/> <p><a href="" key="login_page"/></a></p> </div>
Copied: trunk/examples/mydvds-example/resources/users.jspx (from rev 291, trunk/examples/mydvds-example/resources/index.jspx) (0 => 293)
--- trunk/examples/mydvds-example/resources/users.jspx (rev 0) +++ trunk/examples/mydvds-example/resources/users.jspx 2007-07-27 20:19:10 UTC (rev 293) @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<jsp:root xmlns="http://www.w3.org/1999/xhtml" + xmlns:jsp="http://java.sun.com/JSP/Page" + xmlns:c="http://java.sun.com/jsp/jstl/core" + xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" + xmlns:w="http://waffle.codehaus.org" + version="2.0"> + <jsp:directive.page contentType="text/html" pageEncoding="UTF-8"/> + <jsp:output doctype-public="-//W3C//DTD XHTML 1.1//EN" + doctype-root-element="html" + doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" + omit-xml-declaration="false"/> + <html> + <head> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> + <link href="" type="text/css" rel="stylesheet"/> + <script type="text/_javascript_" src="" + <script type="text/_javascript_" src="" + <script type="text/_javascript_" src="" + <script type="text/_javascript_" src="" + </head> + <body> + <div id="site"> + <h1 id="h1-marca"> + <a href="" src="" alt="waffle logo"/></a> + </h1> + + <c:if test="${not empty param.language}"> + <fmt:setLocale value="${param.language}" scope="session"/> + </c:if> + + <c:if test="${errors.errorMessageCount > 0}"> + <div id="error-box"> + <h1><fmt:message key="errors"/></h1> + <hr/> + <c:import url="" + </div> + </c:if> + + <div class="box"> + <h1><fmt:message key="change_language"/></h1> + <hr/> + <a href="" src="" border="0" alt="DE"/></a> | + <a href="" src="" border="0" alt="GB"/></a> | + <a href="" src="" border="0" alt="US"/></a> | + <a href="" src="" border="0" alt="BR"/></a> | + <a href="" src="" border="0" alt="IT"/></a> | + <a href="" src="" border="0" alt="ES"/></a> + </div> + + <br/><br/> + + <div class="box"> + <h1><fmt:message key="welcome"/></h1> + <hr/> + + <w:form action="" method="post" border="0" id="loginForm" type="table"> + <w:hidden name="method" value="login"/> + <w:text name="login" value="${login}"/> + <w:password name="password" value="${password}"/> + <w:submit/> + </w:form> + + </div> + + <br/><br/> + + <div class="box"> + + <h1><fmt:message key="new_user"/></h1> + <hr/> + + <w:form action="" method="post" id="addUserForm" type="table"> + <w:hidden name="method" value="add"/> + <w:text name="name" value="${user.name}"/> + <w:text name="login" value="${user.login}"/> + <w:password name="password" value="${user.password}"/> + <w:submit/> + </w:form> + + </div> + </div> + </body> + </html> +</jsp:root>
Modified: trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/MyDvdsRegistrar.java (292 => 293)
--- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/MyDvdsRegistrar.java 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/MyDvdsRegistrar.java 2007-07-27 20:19:10 UTC (rev 293) @@ -2,10 +2,11 @@ import org.codehaus.waffle.example.mydvds.action.DvdsController; import org.codehaus.waffle.example.mydvds.action.UsersController; -import org.codehaus.waffle.example.mydvds.persistence.PersistenceManager; -import org.codehaus.waffle.example.mydvds.persistence.HibernateSessionFactory; +import org.codehaus.waffle.example.mydvds.action.UsersControllerValidator; import org.codehaus.waffle.example.mydvds.interceptor.AuthorizationInterceptor; import org.codehaus.waffle.example.mydvds.model.Passport; +import org.codehaus.waffle.example.mydvds.persistence.HibernateSessionFactory; +import org.codehaus.waffle.example.mydvds.persistence.PersistenceManager; import org.codehaus.waffle.registrar.AbstractRegistrar; import org.codehaus.waffle.registrar.Registrar; @@ -31,6 +32,6 @@ register(AuthorizationInterceptor.class); register("dvds", DvdsController.class); register("users", UsersController.class); -// register("userValidator", UsersControllerValidator.class); + register("usersValidator", UsersControllerValidator.class); } }
Modified: trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersController.java (292 => 293)
--- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersController.java 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersController.java 2007-07-27 20:19:10 UTC (rev 293) @@ -11,18 +11,17 @@ public class UsersController { - private final PersistenceManager factory; + private final PersistenceManager persistenceManager; private final Passport passport; - public UsersController(PersistenceManager factory, Passport passport) { - this.factory = factory; + public UsersController(PersistenceManager persistenceManager, Passport passport) { + this.persistenceManager = persistenceManager; this.passport = passport; } @ActionMethod(parameters = {"login", "password"}) public View login(String login, String password) { - - User user = this.factory.getUserDao().search(login, password); + User user = this.persistenceManager.getUserDao().search(login, password); this.passport.setUser(user); return new RedirectView("dvds.waffle", this, new HashMap()); @@ -30,15 +29,15 @@ @ActionMethod(parameters = {"name", "login", "password"}) public View add(String name, String login, String password) { - this.factory.beginTransaction(); - this.factory.getUserDao().add(new User(name, login, password)); - this.factory.commit(); + this.persistenceManager.beginTransaction(); + this.persistenceManager.getUserDao().add(new User(name, login, password)); + this.persistenceManager.commit(); - return new View("user-added.jspx", this); + return new View("user-added", this); } public View logout() { this.passport.invalidate(); - return new View("index.jspx", this); + return new RedirectView("users.waffle", this, new HashMap()); } }
Modified: trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersControllerValidator.java (292 => 293)
--- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersControllerValidator.java 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/action/UsersControllerValidator.java 2007-07-27 20:19:10 UTC (rev 293) @@ -2,11 +2,21 @@ import org.codehaus.waffle.validation.ErrorsContext; import org.codehaus.waffle.validation.FieldErrorMessage; -import org.codehaus.waffle.view.View; public class UsersControllerValidator { - public View add(ErrorsContext errors, String name, String login, String password) { - errors.addErrorMessage(new FieldErrorMessage("user.login", login, "invalid")); - return new View("index.jspx",this); + public void add(ErrorsContext errors, String name, String login, String password) { + if (isEmpty(name)) { + errors.addErrorMessage(new FieldErrorMessage("name", name, "invalid_name")); + } + if (isEmpty(login)) { + errors.addErrorMessage(new FieldErrorMessage("login", login, "invalid_login")); + } + if (isEmpty(password)) { + errors.addErrorMessage(new FieldErrorMessage("password", password, "invalid_password")); + } } + + private boolean isEmpty(String text) { + return text == null || text.trim().length() == 0; + } }
Modified: trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/interceptor/AuthorizationInterceptor.java (292 => 293)
--- trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/interceptor/AuthorizationInterceptor.java 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/java/org/codehaus/waffle/example/mydvds/interceptor/AuthorizationInterceptor.java 2007-07-27 20:19:10 UTC (rev 293) @@ -46,7 +46,7 @@ return chain.proceed(controllerDefinition, method, arguments); } else { System.out.println("Not Authenticated"); - return new RedirectView("index.jspx", controllerDefinition.getController(), new HashMap()); + return new RedirectView("users.waffle", controllerDefinition.getController(), new HashMap()); } }
Modified: trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties (292 => 293)
--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources.properties 2007-07-27 20:19:10 UTC (rev 293) @@ -4,6 +4,9 @@ date.bind.error=The value "{1}" entered in field <i>{0}</i> is not a valid date ({2}). # Other Error messages +invalid_name = Invalid Name +invalid_login = Invalid Login +invalid_password = Invalid Password # Field Descriptions welcome=Welcome @@ -20,3 +23,4 @@ name=name login=login password=password +errors=Errors
Modified: trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties (292 => 293)
--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources_de.properties 2007-07-27 20:19:10 UTC (rev 293) @@ -2,6 +2,10 @@ number.bind.error=''{1}'' in <i>{0}</i> ist ein Ungültige Nummer. date.bind.error="{1}" in <i>{0}</i> ist ein ungültiges Datum. ({2}). +invalid_name = Ungültige Name +invalid_login = Ungültige Benutzername +invalid_password = Ungültige Passwort + welcome=Herzlich Willkommen change_language=Wählen Sie Ihre Sprache new_user=Noch nicht registriert? @@ -16,3 +20,4 @@ name=Name login=Benutzername password=Passwort +errors=Fehler \ No newline at end of file
Modified: trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties (292 => 293)
--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources_it.properties 2007-07-27 20:19:10 UTC (rev 293) @@ -13,3 +13,4 @@ name=nome login=login password=password +errors=??Errors?? \ No newline at end of file
Modified: trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties (292 => 293)
--- trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties 2007-07-27 20:17:05 UTC (rev 292) +++ trunk/examples/mydvds-example/src/main/resources/ApplicationResources_pt_BR.properties 2007-07-27 20:19:10 UTC (rev 293) @@ -2,6 +2,10 @@ number.bind.error=O valor ''{1}'' passado no campo <i>{0}</i> não é um número válido. date.bind.error=O valor "{1}" passado no campo <i>{0}</i> não é uma data válida ({2}). +invalid_name = Nome inválido +invalid_login = Login inválido +invalid_password = Senha inválida + welcome=Bem vindo change_language=Mudar a língua new_user=Novo usuário @@ -16,3 +20,4 @@ name=nome login=login password=senha +errors=Erros \ No newline at end of file
To unsubscribe from this list please visit:
