Author: dvinnichek
Date: 2010-07-30 03:53:09 -0400 (Fri, 30 Jul 2010)
New Revision: 23820
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp
Log:
add template for <form:errors> according to
https://jira.jboss.org/browse/JBIDE-6711
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30
00:37:15 UTC (rev 23819)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30
07:53:09 UTC (rev 23820)
@@ -91,6 +91,17 @@
</vpe:dnd>
</vpe:template>
</vpe:tag>
+
+ <vpe:tag name="form:errors" case-sensitive="yes">
+ <vpe:template children="no" modify="no">
+ <span id="{@id}" style="{@cssStyle}"
class="{@cssClass}">
+ Errors will be here.
+ </span>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
<vpe:tag name="form:form" case-sensitive="yes">
<vpe:template children="yes" modify="yes">
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java 2010-07-30
00:37:15 UTC (rev 23819)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/FormBean.java 2010-07-30
07:53:09 UTC (rev 23820)
@@ -18,6 +18,8 @@
private Map<Integer, String> availableCategories = new HashMap<Integer,
String>();
private Set<Integer> selectedCategories = new HashSet<Integer>();
private List<CategoryType> favoriteCategories = new
ArrayList<CategoryType>();
+
+ private String newName;
public FormBean() {
for (CategoryType categoryType : CategoryType.values()) {
@@ -75,4 +77,12 @@
public void setFavoriteCategories(List<CategoryType> favoriteCategories) {
this.favoriteCategories = favoriteCategories;
}
+
+ public String getNewName() {
+ return newName;
+ }
+
+ public void setNewName(String newName) {
+ this.newName = newName;
+ }
}
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java 2010-07-30
07:53:09 UTC (rev 23820)
@@ -0,0 +1,19 @@
+package org.jboss.tools.vpe.spring.test.springtest.controller;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.tools.vpe.spring.test.springtest.FormBean;
+import org.springframework.web.servlet.mvc.SimpleFormController;
+
+/**
+ *
+ * @author Denis Vinnichek (dvinnichek)
+ */
+public class ErrorsController extends SimpleFormController {
+
+ protected final Log logger = LogFactory.getLog(getClass());
+ public ErrorsController() {
+ setCommandClass(FormBean.class);
+ setCommandName("formBean");
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/controller/ErrorsController.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java 2010-07-30
07:53:09 UTC (rev 23820)
@@ -0,0 +1,16 @@
+package org.jboss.tools.vpe.spring.test.springtest.validator;
+
+import org.springframework.validation.Errors;
+import org.springframework.validation.ValidationUtils;
+import org.springframework.validation.Validator;
+
+public class FieldValidator implements Validator{
+
+ public boolean supports(Class<?> clazz) {
+ return true;
+ }
+
+ public void validate(Object target, Errors errors) {
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newName",
"required","Name is required.");
+ }
+}
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/java/org/jboss/tools/vpe/spring/test/springtest/validator/FieldValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp 2010-07-30
07:53:09 UTC (rev 23820)
@@ -0,0 +1,43 @@
+<%@ taglib prefix="form"
uri="http://www.springframework.org/tags/form"%>
+<%@ taglib prefix="c"
uri="http://java.sun.com/jstl/core"%>
+<html>
+<head>
+<style>
+.red-bordered-text {
+ border: 1px solid red;
+}
+</style>
+</head>
+<body>
+<h1>Test of form:errors</h1>
+
+<form:form commandName="formBean" method="POST">
+ <table>
+ <tr>
+ <td />
+ <%-- Show errors for newName field --%>
+ <td>
+ <form:errors id="nameErrors1" path="newName" />
+ </td>
+ </tr>
+ <tr>
+ <td />
+ <%-- Show errors for newName field --%>
+ <td>
+ <form:errors id="nameErrors2" path="newName"
+ cssClass="red-bordered-text"
+ cssStyle="color: green;" />
+ </td>
+ </tr>
+ <tr>
+ <td>New Name:</td>
+ <td><form:input path="newName" /></td>
+ </tr>
+ <tr>
+ <td/>
+ <td align="right"><input type="submit"
value="Test" /></td>
+ </tr>
+ </table>
+</form:form>
+</body>
+</html>
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml 2010-07-30
00:37:15 UTC (rev 23819)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/springapp-servlet.xml 2010-07-30
07:53:09 UTC (rev 23820)
@@ -10,10 +10,13 @@
<bean name="/form.htm"
class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/checkbox.htm"
class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
<bean name="/checkboxes.htm"
class="org.jboss.tools.vpe.spring.test.springtest.FormController"/>
+ <bean name="/errors.htm"
class="org.jboss.tools.vpe.spring.test.springtest.controller.ErrorsController">
+ <property name="validator" ref="fieldValidator"/>
+ </bean>
+ <bean id="fieldValidator"
class="org.jboss.tools.vpe.spring.test.springtest.validator.FieldValidator"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="viewClass"
value="org.springframework.web.servlet.view.JstlView"></property>
- <property name="prefix"
value="/WEB-INF/jsp"></property>
+ <property name="prefix"
value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp 2010-07-30
00:37:15 UTC (rev 23819)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/index.jsp 2010-07-30
07:53:09 UTC (rev 23820)
@@ -4,4 +4,6 @@
<br/>
<a href="form.htm">form.htm</a>
<br/>
+<a href="errors.htm">errors.htm</a>
+<br/>