From 0aaf550ab89b4b7767e97f83a6a84f57445def9e Mon Sep 17 00:00:00 2001 From: Toby Jee Date: Mon, 29 May 2006 17:51:39 +0000 Subject: [PATCH] - 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. git-svn-id: https://svn.apache.org/repos/asf/struts/action2/trunk@410132 13f79535-47bb-0310-9956-ffa450edef68 --- .../action2/showcase/conversion/Person.java | 34 ++++++++++++++ .../PersonAction-conversion.properties | 1 + .../showcase/conversion/PersonAction.java | 43 ++++++++++++++++++ .../src/main/webapp/WEB-INF/classes/xwork.xml | 10 ++++- .../main/webapp/WEB-INF/decorators/main.jsp | 1 + .../main/webapp/conversion/Person.java.txt | 34 ++++++++++++++ .../webapp/conversion/PersonAction.java.txt | 43 ++++++++++++++++++ .../webapp/conversion/enterPersonInfo.jsp | 44 +++++++++++++++++++ .../src/main/webapp/conversion/index.jsp | 15 +++++++ .../main/webapp/conversion/showPersonInfo.jsp | 17 +++++++ 10 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java create mode 100644 apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties create mode 100644 apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java create mode 100644 apps/showcase/src/main/webapp/conversion/Person.java.txt create mode 100644 apps/showcase/src/main/webapp/conversion/PersonAction.java.txt create mode 100644 apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp create mode 100644 apps/showcase/src/main/webapp/conversion/index.jsp create mode 100644 apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp diff --git a/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java b/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java new file mode 100644 index 000000000..bcaf94497 --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/Person.java @@ -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; } +} diff --git a/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties b/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties new file mode 100644 index 000000000..10ba2dd73 --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction-conversion.properties @@ -0,0 +1 @@ +Element_persons=org.apache.struts.action2.showcase.conversion.Person diff --git a/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java b/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java new file mode 100644 index 000000000..63966d3cb --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts/action2/showcase/conversion/PersonAction.java @@ -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; + } +} diff --git a/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml b/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml index 5539901fb..9b4387eeb 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml +++ b/apps/showcase/src/main/webapp/WEB-INF/classes/xwork.xml @@ -1,4 +1,8 @@ - + + + @@ -7,7 +11,7 @@ - + @@ -31,6 +35,8 @@ + + diff --git a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp index 5dfd70262..04b317ad6 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp +++ b/apps/showcase/src/main/webapp/WEB-INF/decorators/main.jsp @@ -75,6 +75,7 @@
  • ">Execute & Wait
  • ">Token
  • ">File Download
  • +
  • "/>Conversion
  • ">JSF
  • ">Help
  • diff --git a/apps/showcase/src/main/webapp/conversion/Person.java.txt b/apps/showcase/src/main/webapp/conversion/Person.java.txt new file mode 100644 index 000000000..bcaf94497 --- /dev/null +++ b/apps/showcase/src/main/webapp/conversion/Person.java.txt @@ -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; } +} diff --git a/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt b/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt new file mode 100644 index 000000000..63966d3cb --- /dev/null +++ b/apps/showcase/src/main/webapp/conversion/PersonAction.java.txt @@ -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; + } +} diff --git a/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp b/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp new file mode 100644 index 000000000..94c482571 --- /dev/null +++ b/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp @@ -0,0 +1,44 @@ +<%@taglib prefix="saf" uri="/struts-action" %> + + + +Showcase - Conversion - Populate Object into SAF Action List + + + +

    +An example populating a list of object (Person.java) into SAF's action (PersonAction.java) + +

    + +See the jsp code here.
    +See the code for PersonAction.java here.
    +See the code for Person.java here.
    + +

    + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/index.jsp b/apps/showcase/src/main/webapp/conversion/index.jsp new file mode 100644 index 000000000..6d6826c9e --- /dev/null +++ b/apps/showcase/src/main/webapp/conversion/index.jsp @@ -0,0 +1,15 @@ +<%@taglib prefix="saf" uri="/struts-action" %> + + + + +Showcase - Conversion + + + +

      +
    • Populate into SAF action class a List of Person.java Object
    • +
    + + + \ No newline at end of file diff --git a/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp b/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp new file mode 100644 index 000000000..39a2c33e8 --- /dev/null +++ b/apps/showcase/src/main/webapp/conversion/showPersonInfo.jsp @@ -0,0 +1,17 @@ +<%@taglib prefix="saf" uri="/struts-action" %> + + + + +Showcase - Conversion - Populate Object into SAF Action List + + + + +
    +
    +
    + + + +