Author: dvinnichek
Date: 2010-07-30 04:45:26 -0400 (Fri, 30 Jul 2010)
New Revision: 23824
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
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/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
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java
Log:
add tests for form:errors tag
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
08:33:03 UTC (rev 23823)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.spring/templates/vpe-templates-spring.xml 2010-07-30
08:45:26 UTC (rev 23824)
@@ -93,8 +93,18 @@
</vpe:tag>
<vpe:tag name="form:errors" case-sensitive="yes">
+ <vpe:if test="@path='*'">
+ <vpe:template children="no" modify="no">
+ <span id="{@id}" style="{@cssStyle}"
class="{@cssClass}">
+ Errors for all validated fields.
+ </span>
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:if>
<vpe:template children="no" modify="no">
- <span id="{@id}" style="{@cssStyle}"
class="{@cssClass}">
+ <span id="{@id}" style="{@cssStyle}"
class="{@cssClass}">
<vpe:value expr="Errors for {@path} field." />
</span>
<vpe:dnd>
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
08:33:03 UTC (rev 23823)
+++
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
08:45:26 UTC (rev 23824)
@@ -8,6 +8,7 @@
import java.util.Set;
import org.jboss.tools.vpe.spring.test.springtest.data.CategoryType;
+import org.jboss.tools.vpe.spring.test.springtest.data.User;
public class FormBean {
@@ -19,7 +20,7 @@
private Set<Integer> selectedCategories = new HashSet<Integer>();
private List<CategoryType> favoriteCategories = new
ArrayList<CategoryType>();
- private String newName;
+ private User user;
public FormBean() {
for (CategoryType categoryType : CategoryType.values()) {
@@ -78,11 +79,11 @@
this.favoriteCategories = favoriteCategories;
}
- public String getNewName() {
- return newName;
+ public User getUser() {
+ return user;
}
- public void setNewName(String newName) {
- this.newName = newName;
+ public void setUser(User user) {
+ this.user = user;
}
}
Modified:
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 2010-07-30
08:33:03 UTC (rev 23823)
+++
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
08:45:26 UTC (rev 23824)
@@ -11,6 +11,7 @@
}
public void validate(Object target, Errors errors) {
- ValidationUtils.rejectIfEmptyOrWhitespace(errors, "newName",
"required","Name is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "user.firstName",
"required", "First Name is required.");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, "user.lastName",
"required", "Last Name is required.");
}
}
Modified:
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 2010-07-30
08:33:03 UTC (rev 23823)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp 2010-07-30
08:45:26 UTC (rev 23824)
@@ -12,31 +12,29 @@
<h1>Test of form:errors</h1>
<form:form commandName="formBean" method="POST">
+ <form:errors id="allFieldsErrors" path="*" />
<table>
<tr>
- <td />
- <%-- Show errors for newName field --%>
+ <td>First Name:</td>
+ <td><form:input path="user.firstName" /></td>
<td>
- <form:errors id="nameErrors1" path="newName" />
- </td>
+ <form:errors id="firstNameErrors"
+ path="user.firstName"
+ cssClass="red-bordered-text" />
+ </td>
</tr>
<tr>
- <td />
- <%-- Show errors for newName field --%>
+ <td>Last Name:</td>
+ <td><form:input path="user.lastName" /></td>
<td>
- <form:errors id="nameErrors2" path="newName"
- cssClass="red-bordered-text"
- cssStyle="color: green;" />
- </td>
+ <form:errors id="lastNameErrors"
+ path="user.lastName"
+ cssStyle="color: red;" />
+ </td>
</tr>
<tr>
- <td>New Name:</td>
- <td><form:input path="newName" /></td>
+ <td colspan="2" align="right"><input
type="submit" value="Test" /></td>
</tr>
- <tr>
- <td/>
- <td align="right"><input type="submit"
value="Test" /></td>
- </tr>
</table>
</form:form>
</body>
Added:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
(rev 0)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml 2010-07-30
08:45:26 UTC (rev 23824)
@@ -0,0 +1,17 @@
+<tests>
+ <test id="allFieldsErrors">
+ <span id="allFieldsErrors">
+ Errors for all validated fields.
+ </span>
+ </test>
+ <test id="firstNameErrors">
+ <span id="firstNameErrors" class="red-bordered-text">
+ Errors for user.firstName field.
+ </span>
+ </test>
+ <test id="nameErrors2">
+ <span id="lastNameErrors" style="color: red;">
+ Errors for user.lastName field.
+ </span>
+ </test>
+</tests>
\ No newline at end of file
Property changes on:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/resources/SpringTest/src/main/webapp/WEB-INF/jsp/errors.jsp.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified:
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java
===================================================================
---
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java 2010-07-30
08:33:03 UTC (rev 23823)
+++
trunk/vpe/tests/org.jboss.tools.vpe.spring.test/src/org/jboss/tools/vpe/spring/test/SpringFormComponentTest.java 2010-07-30
08:45:26 UTC (rev 23824)
@@ -42,4 +42,9 @@
performTestForVpeComponent((IFile)TestUtil.getResource(
"src/main/webapp/WEB-INF/jsp/form.jsp", IMPORT_PROJECT_NAME));
//$NON-NLS-1$
}
+
+ public void testErrors() throws Throwable {
+ performTestForVpeComponent((IFile)TestUtil.getResource(
+ "src/main/webapp/WEB-INF/jsp/errors.jsp", IMPORT_PROJECT_NAME));
//$NON-NLS-1$
+ }
}
Show replies by date