Commits

Anonymous committed e6e5b94

added an example of using MessageStoreInterceptor in showcase

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2918573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits b0e971b

Comments (0)

Files changed (6)

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/messageStore/ShowFormAction-submitForm-validation.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE validators PUBLIC 
+	"-//OpenSymphony Group//XWork Validator 1.0.2//EN" 
+	"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+
+<validators>
+	<field name="name">
+		<field-validator type="requiredstring">
+			<message>Name is required</message>
+		</field-validator>
+	</field>
+	<field name="age">
+		<field-validator type="required">
+			<message>Age is required</message>
+		</field-validator>
+	</field>
+</validators>	
+	
+	
+	

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/messageStore/ShowFormAction.java

+/**
+ * 
+ */
+package com.opensymphony.webwork.showcase.messageStore;
+
+import com.opensymphony.xwork.ActionSupport;
+
+/**
+ * @author tmjee
+ *
+ */
+public class ShowFormAction extends ActionSupport {
+	
+	private static final long serialVersionUID = -7795475629528823265L;
+	
+	private String name;
+	private Integer age;
+	
+	public String getName() { return name; }
+	public void setName(String name) { this.name = name; }
+	
+	public Integer getAge() { return age; }
+	public void setAge(Integer age) { this.age = age; }
+	
+	public String execute() throws Exception {
+		return SUCCESS;
+	}
+}

File webapps/showcase/src/java/com/opensymphony/webwork/showcase/validation/CollectionValidatorExample-validation.xml

 	"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
 	
 <validators>
+	<validator type="expression">
+		<param name="expression"><![CDATA[persons.{#this.name.length() > 4}.{? #this == false }.size() <= 0 ]]></param>
+		<message>name needs to be 4 chars long</message>
+	</validator>
 	<field name="persons">
+		<field-validator type="fieldexpression">
+			<param name="expression"><![CDATA[persons.{#this.name.length() > 4}.{? #this == false }.size() <= 0 ]]></param>
+			<message>name needs to be 4 chars long</message>
+		</field-validator>
 		<field-validator type="collection">
 			<param name="property">persons.name</param>
 			<param name="validatorRef">requiredstring</param>

File webapps/showcase/src/webapp/WEB-INF/classes/xwork-messageStore.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xwork PUBLIC 
+	"-//OpenSymphony Group//XWork 1.1.1//EN" 
+	"http://www.opensymphony.com/xwork/xwork-1.1.1.dtd">
+<xwork>
+	
+	<package name="messageStore" extends="webwork-default" namespace="/messageStore">
+		<action name="showForm" class="com.opensymphony.webwork.showcase.messageStore.ShowFormAction">
+			<interceptor-ref name="store">
+				<param name="operationMode">RETRIEVE</param>
+			</interceptor-ref>
+			<interceptor-ref name="defaultStack" />
+			<result>/messageStore/showForm.jsp</result>
+			<result name="input">/messageStore/showForm.jsp</result>
+		</action>
+		<action name="submitForm" class="com.opensymphony.webwork.showcase.messageStore.ShowFormAction">
+			<interceptor-ref name="store">
+				<param name="operationMode">STORE</param>
+			</interceptor-ref>
+			<interceptor-ref name="defaultStack" />
+			<result type="redirect">/messageStore/showForm.action</result>
+			<result name="input" type="redirect">/messageStore/showForm.action</result>
+		</action>
+	</package>
+</xwork>	
+	
+	

File webapps/showcase/src/webapp/WEB-INF/classes/xwork.xml

     
     <include file="config-browser.xml"/>
 
+	<include file="xwork-messageStore.xml" />
+
     <include file="xwork-continuations.xml"/>
 
     <include file="xwork-tags.xml"/>

File webapps/showcase/src/webapp/messageStore/showForm.jsp

+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<%@taglib prefix="ww" uri="/webwork" %>    
+    
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>Showcase - Example of message store using 'store' interceptor</title>
+<ww:head />
+</head>
+<body>
+
+	<ww:fielderror />
+	<ww:actionerror/>
+	<ww:actionmessage /> 
+
+	<ww:form action="submitForm" namespace="/messageStore">
+		<ww:textfield name="name" label="Name" />
+		<ww:textfield name="age" label="Age" />
+		<ww:submit />
+	</ww:form>
+
+</body>
+</html>
+