Author: tmjee Date: Sat Sep 30 10:19:37 2006 New Revision: 451619 URL: http://svn.apache.org/viewvc?view=rev&rev=451619 Log: WW-1453 - added example into show case demonstrating :- - populating a List of Pojos in action class - populating a Set of Pojos in action class - populating a List of Tiger 5 Enum in action class
Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction-conversion.properties struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction-conversion.properties struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/Address.java.txt struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/AddressAction.java.txt struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/EnumTypeConverter.java.txt struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnum.java.txt struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumAction.java.txt struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumActionConversion.txt struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterOperations.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showOperations.jsp Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-conversion.xml struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/Address.java Sat Sep 30 10:19:37 2006 @@ -0,0 +1,35 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + + +/** + * @version $Date$ $Id$ + */ +public class Address { + + private String id; + private String address; + + public String getId() { return id; } + public void setId(String id) { this.id = id; } + + public String getAddress() { return address; } + public void setAddress(String address) { this.address = address; } + +} Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction-conversion.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction-conversion.properties?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction-conversion.properties (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction-conversion.properties Sat Sep 30 10:19:37 2006 @@ -0,0 +1,6 @@ + +KeyProperty_addresses=id +Element_addresses=org.apache.struts2.showcase.conversion.Address +CreateIfNull_addresses=true + + Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/AddressAction.java Sat Sep 30 10:19:37 2006 @@ -0,0 +1,44 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +import java.util.LinkedHashSet; +import java.util.Set; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * @version $Date$ $Id$ + */ +public class AddressAction extends ActionSupport { + + private Set addresses = new LinkedHashSet(); + + public Set getAddresses() { return addresses; } + public void setAddresses(Set addresses) { this.addresses = addresses; } + + + public String input() throws Exception { + return SUCCESS; + } + + public String submit() throws Exception { + System.out.println(addresses); + return SUCCESS; + } +} Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/EnumTypeConverter.java Sat Sep 30 10:19:37 2006 @@ -0,0 +1,55 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.struts2.util.StrutsTypeConverter; + +/** + * @version $Date$ $Id$ + */ +public class EnumTypeConverter extends StrutsTypeConverter { + + @Override + public Object convertFromString(Map context, String[] values, Class toClass) { + List<Enum> result = new ArrayList<Enum>(); + for (int a=0; a< values.length; a++) { + Enum e = Enum.valueOf(OperationsEnum.class, values[a]); + if (e != null) + result.add(e); + } + return result; + } + + @Override + public String convertToString(Map context, Object o) { + List l = (List) o; + String result ="<"; + for (Iterator i = l.iterator(); i.hasNext(); ) { + result = result + "["+ i.next() +"]"; + } + result = result+">"; + return result; + } + + +} Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnum.java Sat Sep 30 10:19:37 2006 @@ -0,0 +1,30 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +/** + * + * @version $Date$ $Id$ + */ +public enum OperationsEnum { + ADD, + MINUS, + DIVIDE, + MULTIPLY, + REMAINDER; +} Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction-conversion.properties URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction-conversion.properties?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction-conversion.properties (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction-conversion.properties Sat Sep 30 10:19:37 2006 @@ -0,0 +1,4 @@ + +selectedOperations=org.apache.struts2.showcase.conversion.EnumTypeConverter +Element_selectedOperations=org.apache.struts2.showcase.conversion.OperationsEnum + Added: struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java (added) +++ struts/struts2/trunk/apps/showcase/src/main/java/org/apache/struts2/showcase/conversion/OperationsEnumAction.java Sat Sep 30 10:19:37 2006 @@ -0,0 +1,53 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * + * @version $Date$ $Id$ + */ +public class OperationsEnumAction extends ActionSupport { + + private static final long serialVersionUID = -2229489704988870318L; + + private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>(); + + public List<OperationsEnum> getSelectedOperations() { return this.selectedOperations; } + public void setSelectedOperations(List<OperationsEnum> selectedOperations) { + this.selectedOperations = selectedOperations; + } + + + public List<OperationsEnum> getAvailableOperations() { + return Arrays.asList(OperationsEnum.values()); + } + + public String input() throws Exception { + return SUCCESS; + } + public String submit() throws Exception { + return SUCCESS; + } +} + Modified: struts/struts2/trunk/apps/showcase/src/main/resources/struts-conversion.xml URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/resources/struts-conversion.xml?view=diff&rev=451619&r1=451618&r2=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/resources/struts-conversion.xml (original) +++ struts/struts2/trunk/apps/showcase/src/main/resources/struts-conversion.xml Sat Sep 30 10:19:37 2006 @@ -8,6 +8,8 @@ <include file="struts-default.xml" /> <package name="conversion" namespace="/conversion" extends="struts-default"> + + <!-- Example populating a List inside an Action --> <action name="enterPersonsInfo" method="input" class="org.apache.struts2.showcase.conversion.PersonAction"> <result>enterPersonInfo.jsp</result> @@ -17,7 +19,7 @@ <result>showPersonInfo.jsp</result> <result name="input">enterPersonInfo.jsp</result> </action> - <action name="showJspCode"> + <action name="showPersonJspCode"> <result type="plaintext">/conversion/enterPersonInfo.jsp</result> </action> <action name="showPersonActionJavaCode"> @@ -26,5 +28,50 @@ <action name="showPersonJavaCode"> <result type="plaintext">/conversion/Person.java.txt</result> </action> + + + <!-- Example populating a Set inside an Action --> + <action name="enterAddressesInfo" class="org.apache.struts2.showcase.conversion.AddressAction" method="input"> + <result>enterAddressInfo.jsp</result> + </action> + <action name="submitAddressesInfo" class="org.apache.struts2.showcase.conversion.AddressAction" method="submit"> + <result>showAddressInfo.jsp</result> + <result name="input">enterAddressInfo.jsp</result> + </action> + <action name="showAddressJspCode"> + <result type="plaintext">/conversion/enterAddressInfo.jsp</result> + </action> + <action name="showAddressActionJavaCode"> + <result type="plaintext">/conversion/AddressAction.java.txt</result> + </action> + <action name="showAddressJavaCode"> + <result type="plaintext">/conversion/Address.java.txt</result> + </action> + + + <!-- Example populating a List with Tiger 5 Enum --> + <action name="enterOperationEnumInfo" class="org.apache.struts2.showcase.conversion.OperationsEnumAction" method="input"> + <result>enterOperations.jsp</result> + </action> + <action name="submitOperationEnumInfo" class="org.apache.struts2.showcase.conversion.OperationsEnumAction" method="submit"> + <result>showOperations.jsp</result> + <result name="input">enterOperations.jsp</result> + </action> + <action name="showEnumJspCode"> + <result type="plaintext">/conversion/enterOperations.jsp</result> + </action> + <action name="showOperationsEnumJavaCode"> + <result type="plaintext">/conversion/OperationsEnum.java.txt</result> + </action> + <action name="showOperationEnumActionJavaCode"> + <result type="plaintext">/conversion/OperationsEnumAction.java.txt</result> + </action> + <action name="showEnumTypeConverterJavaCode"> + <result type="plaintext">/conversion/EnumTypeConverter.java.txt</result> + </action> + <action name="showOperationsEnumActionConversionProperties"> + <result type="plaintext">/conversion/OperationsEnumActionConversion.txt</result> + </action> + </package> </struts> Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/Address.java.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/Address.java.txt?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/Address.java.txt (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/Address.java.txt Sat Sep 30 10:19:37 2006 @@ -0,0 +1,35 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + + +/** + * @version $Date$ $Id$ + */ +public class Address { + + private String id; + private String address; + + public String getId() { return id; } + public void setId(String id) { this.id = id; } + + public String getAddress() { return address; } + public void setAddress(String address) { this.address = address; } + +} Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/AddressAction.java.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/AddressAction.java.txt?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/AddressAction.java.txt (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/AddressAction.java.txt Sat Sep 30 10:19:37 2006 @@ -0,0 +1,44 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +import java.util.LinkedHashSet; +import java.util.Set; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * @version $Date$ $Id$ + */ +public class AddressAction extends ActionSupport { + + private Set addresses = new LinkedHashSet(); + + public Set getAddresses() { return addresses; } + public void setAddresses(Set addresses) { this.addresses = addresses; } + + + public String input() throws Exception { + return SUCCESS; + } + + public String submit() throws Exception { + System.out.println(addresses); + return SUCCESS; + } +} Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/EnumTypeConverter.java.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/EnumTypeConverter.java.txt?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/EnumTypeConverter.java.txt (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/EnumTypeConverter.java.txt Sat Sep 30 10:19:37 2006 @@ -0,0 +1,55 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.struts2.util.StrutsTypeConverter; + +/** + * @version $Date$ $Id$ + */ +public class EnumTypeConverter extends StrutsTypeConverter { + + @Override + public Object convertFromString(Map context, String[] values, Class toClass) { + List<Enum> result = new ArrayList<Enum>(); + for (int a=0; a< values.length; a++) { + Enum e = Enum.valueOf(OperationsEnum.class, values[a]); + if (e != null) + result.add(e); + } + return result; + } + + @Override + public String convertToString(Map context, Object o) { + List l = (List) o; + String result ="<"; + for (Iterator i = l.iterator(); i.hasNext(); ) { + result = result + "["+ i.next() +"]"; + } + result = result+">"; + return result; + } + + +} Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnum.java.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnum.java.txt?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnum.java.txt (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnum.java.txt Sat Sep 30 10:19:37 2006 @@ -0,0 +1,30 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +/** + * + * @version $Date$ $Id$ + */ +public enum OperationsEnum { + ADD, + MINUS, + DIVIDE, + MULTIPLY, + REMAINDER; +} Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumAction.java.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumAction.java.txt?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumAction.java.txt (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumAction.java.txt Sat Sep 30 10:19:37 2006 @@ -0,0 +1,53 @@ +/* + * $Id: Person.java 440597 2006-09-06 03:34:39Z 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.struts2.showcase.conversion; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import com.opensymphony.xwork2.ActionSupport; + +/** + * + * @version $Date$ $Id$ + */ +public class OperationsEnumAction extends ActionSupport { + + private static final long serialVersionUID = -2229489704988870318L; + + private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>(); + + public List<OperationsEnum> getSelectedOperations() { return this.selectedOperations; } + public void setSelectedOperations(List<OperationsEnum> selectedOperations) { + this.selectedOperations = selectedOperations; + } + + + public List<OperationsEnum> getAvailableOperations() { + return Arrays.asList(OperationsEnum.values()); + } + + public String input() throws Exception { + return SUCCESS; + } + public String submit() throws Exception { + return SUCCESS; + } +} + Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumActionConversion.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumActionConversion.txt?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumActionConversion.txt (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/OperationsEnumActionConversion.txt Sat Sep 30 10:19:37 2006 @@ -0,0 +1,4 @@ + +selectedOperations=org.apache.struts2.showcase.conversion.EnumTypeConverter +Element_selectedOperations=org.apache.struts2.showcase.conversion.OperationsEnum + Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterAddressInfo.jsp Sat Sep 30 10:19:37 2006 @@ -0,0 +1,48 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion - Set</title> +</head> +<body> + +<p/> +An example populating a Set of object (Address.java) into Struts' action (AddressAction.java) + +<p/> + +See the jsp code <s:url id="url" action="showAddressJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the code for PersonAction.java <s:url id="url" action="showAddressActionJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the code for Person.java <s:url id="url" action="showAddressJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> + +<p/> + + <s:form action="submitAddressesInfo" namespace="/conversion"> + <s:iterator value="%{new int[3]}" status="stat"> + <s:textfield label="%{'Address '+#stat.index}" + name="%{'addresses(\\'id'+#stat.index+'\\').address'}" /> + </s:iterator> + <s:submit /> + </s:form> + + <%-- + The following is how its done statically + --%> + <%-- + <s:form action="submitAddressInfo" namespace="/conversion"> + <s:textfield label="Address 0" + name="addresses('id0')" /> + <s:textfield label="Address 1" + name="addresses('id1')" /> + <s:textfield label="Address 2" + name="addresses('id2')" /> + <s:submit /> + </s:form> + --%> + + +</body> +</html> \ No newline at end of file Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterOperations.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterOperations.jsp?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterOperations.jsp (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterOperations.jsp Sat Sep 30 10:19:37 2006 @@ -0,0 +1,31 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion - Tiger 5 Enum </title> +</head> +<body> + +See the jsp code <s:url id="url" action="showEnumJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the code for OperationsEnum.java <s:url id="url" action="showOperationsEnumJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the code for OperationsEnumAction.java <s:url id="url" action="showOperationEnumActionJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the code for EnumTypeConverter.java <s:url id="url" action="showEnumTypeConverterJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the properties for OperationsEnumAction-conversion.properties <s:url id="url" action="showOperationsEnumActionConversionProperties" namespace="/conversion" /><s:a href="%{#url}">here.</s:a> +<br/> +<br/> + + <s:form action="submitOperationEnumInfo" namespace="/conversion"> + <s:checkboxlist label="Operations" + name="selectedOperations" + list="%{availableOperations}" + listKey="name()" + listValue="name()" + /> + <s:submit /> + </s:form> + +</body> +</html> \ No newline at end of file Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp?view=diff&rev=451619&r1=451618&r2=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/enterPersonInfo.jsp Sat Sep 30 10:19:37 2006 @@ -11,7 +11,7 @@ <p/> -See the jsp code <s:url id="url" action="showJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> +See the jsp code <s:url id="url" action="showPersonJspCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> See the code for PersonAction.java <s:url id="url" action="showPersonActionJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> See the code for Person.java <s:url id="url" action="showPersonJavaCode" namespace="/conversion" /><s:a href="%{#url}">here.</s:a><br/> Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp?view=diff&rev=451619&r1=451618&r2=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp (original) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/index.jsp Sat Sep 30 10:19:37 2006 @@ -8,7 +8,18 @@ <body> <ul> - <li><s:url id="url" action="enterPersonsInfo" namespace="/conversion" /><s:a href="%{#url}">Populate into the Struts action class a List of Person.java Object</s:a></li> + <li> + <s:url id="url" action="enterPersonsInfo" namespace="/conversion" /> + <s:a href="%{#url}">Populate into the Struts action class a List of Person.java Object</s:a> + </li> + <li> + <s:url id="url" action="enterAddressesInfo" namespace="/conversion" /> + <s:a href="%{#url}">Populate into Struts action class a Set of Address.java Object</s:a> + </li> + <li> + <s:url id="url" action="enterOperationEnumInfo" namespace="/conversion" /> + <s:a href="%{#url}">Populate into Struts action class a List of OperationEnum.java (Java5 Enum)</s:a> + </li> </ul> </body> Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showAddressInfo.jsp Sat Sep 30 10:19:37 2006 @@ -0,0 +1,15 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion - Set </title> +</head> +<body> + <s:iterator value="%{addresses}"> + <s:property value="%{top.id}" /> -> <s:property value="%{top.address}" /><br/> + </s:iterator> +</body> +</html> \ No newline at end of file Added: struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showOperations.jsp URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showOperations.jsp?view=auto&rev=451619 ============================================================================== --- struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showOperations.jsp (added) +++ struts/struts2/trunk/apps/showcase/src/main/webapp/conversion/showOperations.jsp Sat Sep 30 10:19:37 2006 @@ -0,0 +1,17 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> +<[EMAIL PROTECTED] prefix="s" uri="/struts-tags" %> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Showcase - Conversion - Tiger 5 Enum</title> +</head> +<body> + + <s:iterator value="%{selectedOperations}" status="stat"> + <s:property value="%{top.name()}" /><br/> + </s:iterator> + +</body> +</html> \ No newline at end of file