Author: tmjee Date: Mon May 29 10:51:39 2006 New Revision: 410132 URL: http://svn.apache.org/viewvc?rev=410132&view=rev Log: - added a simple conversion example into showcase - it is basically just populating a List in SAF2 Action with Person.java Object. Using *-conversion.properties as well - since this is asked constantly in the forum, we should just put a simple example in showcase.
Added: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java (with props) struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties (with props) struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java (with props) struts/action2/trunk/apps/showcase/src/main/webapp/conversion/Person.java.txt (with props) struts/action2/trunk/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt (with props) struts/action2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp (with props) struts/action2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp (with props) struts/action2/trunk/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp (with props) Modified: struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp Added: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java (added) +++ struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java Mon May 29 10:51:39 2006 @@ -0,0 +1,34 @@ +/* + * $Id: AbstractDao.java 394498 2006-04-16 15:28:06Z tmjee $ + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.struts.action2.showcase.conversion; + +import java.io.Serializable; + +/** + * + */ +public class Person implements Serializable { + private String name; + private Integer age; + + public void setName(String name) { this.name = name; } + public String getName() { return this.name; } + + public void setAge(Integer age) { this.age = age; } + public Integer getAge() { return this.age; } +} Propchange: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java ------------------------------------------------------------------------------ svn:eol-style = native Added: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties (added) +++ struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties Mon May 29 10:51:39 2006 @@ -0,0 +1 @@ +Element_persons=org.apache.struts.action2.showcase.conversion.Person Propchange: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties ------------------------------------------------------------------------------ svn:eol-style = native Added: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java (added) +++ struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java Mon May 29 10:51:39 2006 @@ -0,0 +1,43 @@ +/* + * $Id: AbstractDao.java 394498 2006-04-16 15:28:06Z tmjee $ + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.struts.action2.showcase.conversion; + +import java.util.List; + +import com.opensymphony.xwork.ActionSupport; + +/** + * + */ +public class PersonAction extends ActionSupport { + + private List persons; + + public List getPersons() { return persons; } + public void setPersons(List persons) { this.persons = persons; } + + + + public String input() throws Exception { + return SUCCESS; + } + + public String submit() throws Exception { + return SUCCESS; + } +} Propchange: struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml?rev=410132&r1=410131&r2=410132&view=diff ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml (original) +++ struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml Mon May 29 10:51:39 2006 @@ -1,4 +1,8 @@ -<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.1.1//EN" "http://www.opensymphony.com/xwork/xwork-1.1.1.dtd"> +<?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"> <!-- START SNIPPET: xworkSample --> @@ -7,7 +11,7 @@ <include file="struts-default.xml"/> <include file="config-browser.xml"/> - + <include file="xwork-continuations.xml"/> <include file="xwork-tags.xml"/> @@ -31,6 +35,8 @@ <include file="xwork-model-driven.xml" /> <include file="xwork-filedownload.xml" /> + + <include file="xwork-conversion.xml" /> <package name="default" extends="struts-default"> <interceptors> Modified: struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp?rev=410132&r1=410131&r2=410132&view=diff ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp (original) +++ struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp Mon May 29 10:51:39 2006 @@ -75,6 +75,7 @@ <li><a href="<saf:url value="/wait/index.jsp"/>">Execute & Wait</a></li> <li><a href="<saf:url value="/token/index.jsp"/>">Token</a></li> <li><a href="<saf:url value="/filedownload/index.jsp"/>">File Download</a></li> + <li><a href="<saf:url value="/conversion/index.jsp"/>"/>Conversion</a></li> <li><a href="<saf:url action="index" namespace="/jsf"/>">JSF</a></li> <li class="last"><a href="<saf:url value="/help.jsp"/>">Help</a></li> </ul> Added: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/Person.java.txt URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/conversion/Person.java.txt?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/conversion/Person.java.txt (added) +++ struts/action2/trunk/apps/showcase/src/main/webapp/conversion/Person.java.txt Mon May 29 10:51:39 2006 @@ -0,0 +1,34 @@ +/* + * $Id: AbstractDao.java 394498 2006-04-16 15:28:06Z tmjee $ + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.struts.action2.showcase.conversion; + +import java.io.Serializable; + +/** + * + */ +public class Person implements Serializable { + private String name; + private Integer age; + + public void setName(String name) { this.name = name; } + public String getName() { return this.name; } + + public void setAge(Integer age) { this.age = age; } + public Integer getAge() { return this.age; } +} Propchange: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/Person.java.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt (added) +++ struts/action2/trunk/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt Mon May 29 10:51:39 2006 @@ -0,0 +1,43 @@ +/* + * $Id: AbstractDao.java 394498 2006-04-16 15:28:06Z tmjee $ + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.struts.action2.showcase.conversion; + +import java.util.List; + +import com.opensymphony.xwork.ActionSupport; + +/** + * + */ +public class PersonAction extends ActionSupport { + + private List persons; + + public List getPersons() { return persons; } + public void setPersons(List persons) { this.persons = persons; } + + + + public String input() throws Exception { + return SUCCESS; + } + + public String submit() throws Exception { + return SUCCESS; + } +} Propchange: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt ------------------------------------------------------------------------------ svn:eol-style = native Added: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp (added) +++ struts/action2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp Mon May 29 10:51:39 2006 @@ -0,0 +1,44 @@ +<[EMAIL PROTECTED] prefix="saf" uri="/struts-action" %> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion - Populate Object into SAF Action List</title> +</head> +<body> + +<p/> +An example populating a list of object (Person.java) into SAF's action (PersonAction.java) + +<p/> + +See the jsp code <saf:url id="url" action="showJspCode" namespace="/conversion" /><saf:a href="%{#url}">here.</saf:a><br/> +See the code for PersonAction.java <saf:url id="url" action="showPersonActionJavaCode" namespace="/conversion" /><saf:a href="%{#url}">here.</saf:a><br/> +See the code for Person.java <saf:url id="url" action="showPersonJavaCode" namespace="/conversion" /><saf:a href="%{#url}">here.</saf:a><br/> + +<p/> + +<saf:actionerror /> +<saf:fielderror /> + +<saf:form action="submitPersonInfo" namespace="/conversion" method="post"> + + <saf:textfield label="Person 1 Name" + name="persons[0].name" /> + <saf:textfield label="Person 1 Age" + name="persons[0].age" /> + <saf:textfield label="Person 2 Name" + name="persons[1].name" /> + <saf:textfield label="Person 2 Age" + name="persons[1].age" /> + <saf:textfield label="Person 3 Name" + name="persons[2].name" /> + <saf:textfield label="Person 3 Age" + name="persons[2].age" /> + + + + <saf:submit /> +</saf:form> + +</body> +</html> \ No newline at end of file Propchange: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp ------------------------------------------------------------------------------ svn:eol-style = native Added: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp (added) +++ struts/action2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp Mon May 29 10:51:39 2006 @@ -0,0 +1,15 @@ +<[EMAIL PROTECTED] prefix="saf" uri="/struts-action" %> + +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion</title> +</head> +<body> + +<ul> + <li><saf:url id="url" action="enterPersonsInfo" namespace="/conversion" /><saf:a href="%{#url}">Populate into SAF action class a List of Person.java Object</saf:a></li> +</ul> + +</body> +</html> \ No newline at end of file Propchange: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp ------------------------------------------------------------------------------ svn:eol-style = native Added: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp URL: http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp?rev=410132&view=auto ============================================================================== --- struts/action2/trunk/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp (added) +++ struts/action2/trunk/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp Mon May 29 10:51:39 2006 @@ -0,0 +1,17 @@ +<[EMAIL PROTECTED] prefix="saf" uri="/struts-action" %> + +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion - Populate Object into SAF Action List</title> +</head> +<body> + +<saf:iterator value="persons" status="status"> + <saf:label label="%{#status.index+' Name'}" value="%{name}" /><br/> + <saf:label label="%{#status.index+' Age'}" value="%{age}" /><br/> +</saf:iterator> + +</body> +</html> + Propchange: struts/action2/trunk/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp ------------------------------------------------------------------------------ svn:eol-style = native