mirror of
https://github.com/apache/struts.git
synced 2026-08-08 16:16:58 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c80cb84589 | |||
| c1c61e044e | |||
| dc630ab223 |
+4
-4
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-blank</artifactId>
|
||||
@@ -34,9 +34,9 @@
|
||||
<name>Blank Webapp</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/blank</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/blank</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_7/apps/blank</url>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/blank</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/blank</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_3/apps/blank</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!DOCTYPE validators PUBLIC
|
||||
"-//Apache Struts//XWork Validator 1.0.2//EN"
|
||||
"http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
|
||||
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
<field name="username">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
|
||||
|
||||
@@ -26,10 +26,11 @@ import com.opensymphony.xwork2.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import org.apache.struts2.StrutsTestCase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.struts2.StrutsTestCase;
|
||||
|
||||
public class ConfigTest extends StrutsTestCase {
|
||||
|
||||
@@ -61,7 +62,7 @@ public class ConfigTest extends StrutsTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
XmlConfigurationProvider c = new XmlConfigurationProvider("struts.xml");
|
||||
configurationManager.addContainerProvider(c);
|
||||
configurationManager.addConfigurationProvider(c);
|
||||
configurationManager.reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-jboss-blank</artifactId>
|
||||
@@ -34,9 +34,9 @@
|
||||
<name>JBoss Blank Webapp</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/jboss-blank</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/jboss-blank</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_7/apps/jboss-blank</url>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/jboss-blank</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/jboss-blank</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_3/apps/jboss-blank</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!DOCTYPE validators PUBLIC
|
||||
"-//Apache Struts//XWork Validator 1.0.2//EN"
|
||||
"http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
|
||||
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
<field name="username">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
|
||||
|
||||
@@ -26,10 +26,11 @@ import com.opensymphony.xwork2.config.RuntimeConfiguration;
|
||||
import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
import com.opensymphony.xwork2.config.entities.ResultConfig;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import org.apache.struts2.StrutsTestCase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.struts2.StrutsTestCase;
|
||||
|
||||
public class ConfigTest extends StrutsTestCase {
|
||||
|
||||
@@ -61,7 +62,7 @@ public class ConfigTest extends StrutsTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
XmlConfigurationProvider c = new XmlConfigurationProvider("struts.xml");
|
||||
configurationManager.addContainerProvider(c);
|
||||
configurationManager.addConfigurationProvider(c);
|
||||
configurationManager.reload();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,17 +26,17 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-mailreader</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>Mail Reader Webapp</name>
|
||||
<name>Starter Webapp</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/mailreader</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/mailreader</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_7/apps/mailreader</url>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/mailreader</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/mailreader</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_3/apps/mailreader</url>
|
||||
</scm>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!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="username">
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN" "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
|
||||
|
||||
<validators>
|
||||
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
@@ -42,9 +42,9 @@
|
||||
</modules>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_7/apps</url>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_3/apps</url>
|
||||
</scm>
|
||||
|
||||
<profiles>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-portlet</artifactId>
|
||||
@@ -34,9 +34,9 @@
|
||||
<name>Portlet Webapp</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/portlet</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/portlet</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_7/apps/portlet</url>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/portlet</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/portlet</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_3/apps/portlet</url>
|
||||
</scm>
|
||||
|
||||
<profiles>
|
||||
@@ -93,8 +93,8 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<groupId>portlet-api</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -190,8 +190,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
-61
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.portlet.example.eventing;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.portlet.interceptor.PortletRequestAware;
|
||||
import org.apache.struts2.portlet.interceptor.PortletResponseAware;
|
||||
|
||||
import javax.portlet.EventRequest;
|
||||
import javax.portlet.EventResponse;
|
||||
import javax.portlet.PortletRequest;
|
||||
import javax.portlet.PortletResponse;
|
||||
|
||||
public class ProcessAction extends ActionSupport implements PortletRequestAware, PortletResponseAware {
|
||||
|
||||
private PortletRequest request;
|
||||
private PortletResponse response;
|
||||
private String name;
|
||||
|
||||
public String execute() throws Exception {
|
||||
|
||||
if (request instanceof EventRequest) {
|
||||
EventRequest req = (EventRequest) request;
|
||||
EventResponse res = (EventResponse) response;
|
||||
res.setRenderParameter("eventName", (String) req.getEvent().getValue());
|
||||
return "forward";
|
||||
} else {
|
||||
name = request.getParameter("eventName");
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public void setPortletRequest(PortletRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public void setPortletResponse(PortletResponse response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.portlet.example.eventing;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.portlet.interceptor.PortletResponseAware;
|
||||
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.PortletResponse;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
public class PublishAction extends ActionSupport implements PortletResponseAware {
|
||||
|
||||
private PortletResponse response;
|
||||
private String name;
|
||||
|
||||
public String execute() throws Exception {
|
||||
|
||||
if (name != null) {
|
||||
((ActionResponse) response).setEvent(new QName("http://org.apache.struts2.portlets/events", "name"), name);
|
||||
|
||||
addActionMessage("Publishing Event with Parameter name : " + name);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public void setPortletResponse(PortletResponse response) {
|
||||
this.response = response;
|
||||
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -22,7 +22,7 @@ package org.apache.struts2.portlet.example.spring;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!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="firstName">
|
||||
<field-validator type="requiredstring">
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE validators PUBLIC "-//Apache Struts//XWork Validator 1.0.2//EN" "http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
|
||||
<!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="firstName">
|
||||
<field-validator type="requiredstring">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
<package name="edit" extends="struts-portlet-default"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
|
||||
<struts>
|
||||
<package name="eventing" extends="struts-portlet-default" namespace="/eventing">
|
||||
|
||||
<action name="publish" class="org.apache.struts2.portlet.example.eventing.PublishAction">
|
||||
<result name="success">/WEB-INF/eventing/index.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="process" class="org.apache.struts2.portlet.example.eventing.ProcessAction">
|
||||
<result name="success">/WEB-INF/eventing/process.jsp</result>
|
||||
<result name="forward" type="redirectAction">
|
||||
<param name="actionName">process</param>
|
||||
<param name="namespace">/eventing</param>
|
||||
</result>
|
||||
</action>
|
||||
</package>
|
||||
</struts>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
<package name="help" extends="struts-portlet-default"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
<package name="view" extends="struts-portlet-default"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
<include file="struts-view.xml"/>
|
||||
<include file="struts-edit.xml"/>
|
||||
<include file="struts-help.xml"/>
|
||||
<include file="struts-eventing.xml"/>
|
||||
<include file="struts-view.xml"/>
|
||||
<include file="struts-edit.xml"/>
|
||||
<include file="struts-help.xml"/>
|
||||
</struts>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE validators PUBLIC
|
||||
"-//Apache Struts//XWork Validator Config 1.0//EN"
|
||||
"http://struts.apache.org/dtds/xwork-validator-config-1.0.dtd">
|
||||
"-//OpenSymphony Group//XWork Validator Config 1.0//EN"
|
||||
"http://www.opensymphony.com/xwork/xwork-validator-config-1.0.dtd">
|
||||
<validators>
|
||||
<validator name="required" class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/>
|
||||
<validator name="requiredstring" class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<h2>Input your name</h2>
|
||||
|
||||
<s:actionmessage/>
|
||||
|
||||
<s:form action="publish" method="POST">
|
||||
<s:textfield label="Please enter your name" name="name" value="%{name}"/>
|
||||
<s:submit value="Submit the form"/>
|
||||
</s:form>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<s:if test="%{name != null}">
|
||||
<h2>Welcome <s:property value="name"/></h2>
|
||||
</s:if>
|
||||
<s:else>
|
||||
<h2>Please insert a Name in the Publish Portlet Form</h2>
|
||||
</s:else>
|
||||
|
||||
<s:actionmessage/>
|
||||
|
||||
|
||||
@@ -1,18 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<portlet-app
|
||||
id="struts-portlet"
|
||||
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="2.0"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
>
|
||||
version="1.0"
|
||||
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
|
||||
id="struts-portlet">
|
||||
|
||||
<portlet id="StrutsPortlet">
|
||||
<description xml:lang="EN">Struts Test Portlet</description>
|
||||
<portlet-name>StrutsPortlet</portlet-name>
|
||||
<display-name xml:lang="EN">Struts Test Portlet</display-name>
|
||||
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
|
||||
|
||||
<!-- The view mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>viewNamespace</name>
|
||||
<value>/view</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in view mode. -->
|
||||
<init-param>
|
||||
<name>defaultViewAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The edit mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>editNamespace</name>
|
||||
<value>/edit</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in edit mode. -->
|
||||
<init-param>
|
||||
<name>defaultEditAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The help mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>helpNamespace</name>
|
||||
<value>/help</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in help mode. -->
|
||||
<init-param>
|
||||
<name>defaultHelpAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<expiration-cache>0</expiration-cache>
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>view</portlet-mode>
|
||||
<portlet-mode>edit</portlet-mode>
|
||||
<portlet-mode>help</portlet-mode>
|
||||
</supports>
|
||||
|
||||
<supported-locale>en</supported-locale>
|
||||
|
||||
<portlet-info>
|
||||
<title>My StrutsPortlet portlet</title>
|
||||
<short-title>SP</short-title>
|
||||
<keywords>struts,portlet</keywords>
|
||||
</portlet-info>
|
||||
</portlet>
|
||||
|
||||
<portlet id="StrutsPortlet2">
|
||||
<description xml:lang="EN">Struts Test Portlet2</description>
|
||||
<portlet-name>StrutsPortlet2</portlet-name>
|
||||
<display-name xml:lang="EN">Struts Test Portlet2</display-name>
|
||||
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
|
||||
|
||||
<!-- The view mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
@@ -55,7 +115,6 @@
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>view</portlet-mode>
|
||||
<portlet-mode>edit</portlet-mode>
|
||||
<portlet-mode>help</portlet-mode>
|
||||
</supports>
|
||||
@@ -63,152 +122,10 @@
|
||||
<supported-locale>en</supported-locale>
|
||||
|
||||
<portlet-info>
|
||||
<title>My Struts2 Portlet</title>
|
||||
<title>My StrutsPortlet portlet2</title>
|
||||
<short-title>SP2</short-title>
|
||||
<keywords>struts,portlet</keywords>
|
||||
</portlet-info>
|
||||
</portlet>
|
||||
|
||||
<portlet id="StrutsPortlet2">
|
||||
<description xml:lang="EN">Struts Test Portlet with JSR 286 Dispatcher</description>
|
||||
<portlet-name>StrutsPortlet2</portlet-name>
|
||||
<display-name xml:lang="EN">Struts Test Portlet with JSR 286 Dispatcher</display-name>
|
||||
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
|
||||
|
||||
<!-- The view mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>viewNamespace</name>
|
||||
<value>/view</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in view mode. -->
|
||||
<init-param>
|
||||
<name>defaultViewAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The edit mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>editNamespace</name>
|
||||
<value>/edit</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in edit mode. -->
|
||||
<init-param>
|
||||
<name>defaultEditAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The help mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>helpNamespace</name>
|
||||
<value>/help</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in help mode. -->
|
||||
<init-param>
|
||||
<name>defaultHelpAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<expiration-cache>0</expiration-cache>
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>edit</portlet-mode>
|
||||
<portlet-mode>help</portlet-mode>
|
||||
</supports>
|
||||
|
||||
<supported-locale>en</supported-locale>
|
||||
|
||||
<portlet-info>
|
||||
<title>My Struts2 Portlet with JSR 286 Dispatcher</title>
|
||||
<short-title>SP2JSR286</short-title>
|
||||
<keywords>struts,portlet</keywords>
|
||||
</portlet-info>
|
||||
</portlet>
|
||||
|
||||
|
||||
<portlet id="Struts2PublishPortlet">
|
||||
<description xml:lang="EN">Struts2 Publish Portlet</description>
|
||||
<portlet-name>Struts2PublishPortlet</portlet-name>
|
||||
<display-name xml:lang="EN">Struts2 Publish Portlet</display-name>
|
||||
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
|
||||
|
||||
<!-- The view mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>viewNamespace</name>
|
||||
<value>/eventing</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in view mode. -->
|
||||
<init-param>
|
||||
<name>defaultViewAction</name>
|
||||
<value>publish</value>
|
||||
</init-param>
|
||||
|
||||
<expiration-cache>0</expiration-cache>
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
</supports>
|
||||
|
||||
<supported-locale>en</supported-locale>
|
||||
|
||||
<portlet-info>
|
||||
<title>Struts2 Publish Portlet</title>
|
||||
<short-title>S2PUB</short-title>
|
||||
<keywords>struts,publish,portlet</keywords>
|
||||
</portlet-info>
|
||||
|
||||
<supported-publishing-event xmlns:x="http://org.apache.struts2.portlets/events">
|
||||
<qname>x:name</qname>
|
||||
</supported-publishing-event>
|
||||
</portlet>
|
||||
|
||||
<portlet id="Struts2ProcessPortlet">
|
||||
<description xml:lang="EN">Struts2 Process Portlet</description>
|
||||
<portlet-name>Struts2ProcessPortlet</portlet-name>
|
||||
<display-name xml:lang="EN">Struts2 Process Portlet</display-name>
|
||||
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr286Dispatcher</portlet-class>
|
||||
|
||||
<!-- The view mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>viewNamespace</name>
|
||||
<value>/eventing</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The default action to invoke in view mode. -->
|
||||
<init-param>
|
||||
<name>defaultViewAction</name>
|
||||
<value>process</value>
|
||||
</init-param>
|
||||
|
||||
<expiration-cache>0</expiration-cache>
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
</supports>
|
||||
|
||||
<supported-locale>en</supported-locale>
|
||||
|
||||
<portlet-info>
|
||||
<title>Struts2 Process Portlet</title>
|
||||
<short-title>S2PRO</short-title>
|
||||
<keywords>struts,process,portlet</keywords>
|
||||
</portlet-info>
|
||||
|
||||
<supported-processing-event xmlns:x="http://org.apache.struts2.portlets/events">
|
||||
<qname>x:name</qname>
|
||||
</supported-processing-event>
|
||||
</portlet>
|
||||
|
||||
<event-definition>
|
||||
<qname xmlns:x="http://org.apache.struts2.portlets/events">x:name</qname>
|
||||
<value-type>java.lang.String</value-type>
|
||||
</event-definition>
|
||||
|
||||
</portlet-app>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<b>Hello from FreeMarker, ${firstName?html} ${lastName?html}!</b>
|
||||
<b>Hello from FreeMarker, ${firstName} ${lastName}!</b>
|
||||
<p/>
|
||||
<a href="<@s.url action="index"/>">Back to front page</a>
|
||||
|
||||
@@ -8,8 +8,11 @@
|
||||
/WEB-INF/applicationContext*.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Uncomment to use the dispatcher servlet -->
|
||||
<!--<servlet id="Struts2PortletDispatcherServlet">
|
||||
<servlet-name>Struts2PortletDispatcherServlet</servlet-name>
|
||||
<servlet-class>org.apache.struts2.portlet.dispatcher.DispatcherServlet</servlet-class>
|
||||
</servlet>-->
|
||||
|
||||
</web-app>
|
||||
|
||||
+55
-52
@@ -22,21 +22,21 @@
|
||||
*/
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-rest-showcase</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.3.7</version>
|
||||
<name>Struts 2 Rest Showcase Example</name>
|
||||
<description>Struts 2 Rest Showcase Example</description>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-rest-showcase</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.2.3</version>
|
||||
<name>Struts 2 Rest Showcase Example</name>
|
||||
<description>Struts 2 Rest Showcase Example</description>
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-rest-plugin</artifactId>
|
||||
@@ -59,12 +59,12 @@
|
||||
<version>1.4.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
@@ -83,48 +83,41 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>struts2-rest-showcase</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<finalName>struts2-rest-showcase</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<version>6.0.1</version>
|
||||
<configuration>
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>8.0.0.M2</version>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>log4j.configuration</name>
|
||||
<value>file:${basedir}/src/main/resources/log4j.properties</value>
|
||||
</systemProperty>
|
||||
<systemProperty>
|
||||
<name>slf4j</name>
|
||||
<value>false</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
|
||||
<webAppConfig>
|
||||
<contextPath>/struts2-rest-showcase</contextPath>
|
||||
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
|
||||
</webAppConfig>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<groupId>org.twdata.maven</groupId>
|
||||
<artifactId>maven-itblast-plugin</artifactId>
|
||||
<version>0.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<containers>tomcat5x</containers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
-->
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
@@ -134,6 +127,16 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!--
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>twdata-m2-repository</id>
|
||||
<name>twdata.org Maven Repository</name>
|
||||
<url>http://twdata-m2-repository.googlecode.com/svn/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
-->
|
||||
</project>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.demo.rest.example;
|
||||
package org.apache.struts2.rest.example;
|
||||
|
||||
public class Order {
|
||||
String id;
|
||||
+6
-1
@@ -1,11 +1,16 @@
|
||||
package org.demo.rest.example;
|
||||
package org.apache.struts2.rest.example;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.struts2.dispatcher.ServletActionRedirectResult;
|
||||
import org.apache.struts2.rest.DefaultHttpHeaders;
|
||||
import org.apache.struts2.rest.HttpHeaders;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.ParentPackage;
|
||||
import org.apache.struts2.convention.annotation.Namespaces;
|
||||
import org.apache.struts2.convention.annotation.Namespace;
|
||||
import org.apache.struts2.convention.annotation.InterceptorRef;
|
||||
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.demo.rest.example;
|
||||
package org.apache.struts2.rest.example;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#
|
||||
# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)
|
||||
#
|
||||
# The five logging levels used by Log are (in order):
|
||||
#
|
||||
# 1. DEBUG (the least serious)
|
||||
# 2. INFO
|
||||
# 3. WARN
|
||||
# 4. ERROR
|
||||
# 5. FATAL (the most serious)
|
||||
|
||||
|
||||
# Set root logger level to WARN and append to stdout
|
||||
log4j.rootLogger=WARN, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
|
||||
# Pattern to output the caller's file name and line number.
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n
|
||||
|
||||
# Print only messages of level ERROR or above in the package noModule.
|
||||
log4j.logger.noModule=ERROR
|
||||
|
||||
# OpenSymphony Stuff
|
||||
log4j.logger.com.opensymphony=INFO
|
||||
|
||||
# Struts2 Stuff
|
||||
log4j.logger.org.apache.struts2=INFO
|
||||
@@ -23,8 +23,8 @@
|
||||
-->
|
||||
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.3.dtd">
|
||||
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
<!-- Overwrite Convention -->
|
||||
|
||||
@@ -1,38 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<%@taglib prefix="s" uri="/struts-tags" %>
|
||||
<!DOCTYPE html PUBLIC
|
||||
"-//W3C//DTD XHTML 1.1 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html lang="en">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Order ${id}</title>
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<title>Order ${id}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Delete Order ${id}</h1>
|
||||
</div>
|
||||
|
||||
<form action="../${id}?_method=DELETE" method="post">
|
||||
<p>
|
||||
Are you sure you want to delete order ${id}?
|
||||
</p>
|
||||
<div class="btn-group">
|
||||
<input type="submit" value="Delete" class="btn btn-danger" />
|
||||
<input type="button" value="Cancel" class="btn btn-success" onclick="window.location.href = '../../orders'" />
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
<a href="${pageContext.request.contextPath}/orders" class="btn btn-info">
|
||||
<i class="icon icon-arrow-left"></i> Back to Orders
|
||||
</a>
|
||||
</div><!--/row-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
<form action="../${id}?_method=DELETE" method="post">
|
||||
<p>
|
||||
Are you sure you want to delete order ${id}?
|
||||
</p>
|
||||
<div>
|
||||
<input type="submit" value="Delete" />
|
||||
<input type="button" value="Cancel" onclick="window.location.href = '../../orders'" />
|
||||
</div>
|
||||
</form>
|
||||
<br />
|
||||
<a href="../../orders">Back to Orders</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,55 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html PUBLIC
|
||||
"-//W3C//DTD XHTML 1.1 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<%@taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<html lang="en">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Order <s:property value="id" /></title>
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<title>Order <s:property value="id" /></title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Order <s:property value="id" /></h1>
|
||||
</div>
|
||||
|
||||
<s:fielderror cssClass="alert alert-error"/>
|
||||
|
||||
<s:form method="post" action="%{#request.contextPath}/orders/%{id}" cssClass="form-horizontal" theme="simple">
|
||||
<s:hidden name="_method" value="put" />
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="id">ID</label>
|
||||
<div class="controls">
|
||||
<s:textfield id="id" name="id" disabled="true"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="clientName">Client</label>
|
||||
<div class="controls">
|
||||
<s:textfield id="clientName" name="clientName"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="amount">Amount</label>
|
||||
<div class="controls">
|
||||
<s:textfield id="amount" name="amount" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<s:submit cssClass="btn btn-primary"/>
|
||||
</div>
|
||||
<table>
|
||||
</s:form>
|
||||
<a href="${pageContext.request.contextPath}/orders" class="btn btn-info">
|
||||
<i class="icon icon-arrow-left"></i> Back to Orders
|
||||
</a>
|
||||
</div><!--/row-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
<s:form method="post" action="%{#request.contextPath}/orders/%{id}">
|
||||
<s:hidden name="_method" value="put" />
|
||||
<table>
|
||||
<s:textfield name="id" label="ID" disabled="true"/>
|
||||
<s:textfield name="clientName" label="Client"/>
|
||||
<s:textfield name="amount" label="Amount" />
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<s:submit />
|
||||
</td>
|
||||
</table>
|
||||
</s:form>
|
||||
<a href="<%=request.getContextPath() %>/orders">Back to Orders</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,47 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html PUBLIC
|
||||
"-//W3C//DTD XHTML 1.1 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<%@taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<html lang="en">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>New Order</title>
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<title>New Order</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>New Order</h1>
|
||||
</div>
|
||||
|
||||
<s:fielderror cssClass="alert alert-error"/>
|
||||
|
||||
<s:form method="post" action="%{#request.contextPath}/orders" cssClass="form-horizontal" theme="simple">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="clientName">Client</label>
|
||||
<div class="controls">
|
||||
<s:textfield id="clientName" name="clientName"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="amount">Amount</label>
|
||||
<div class="controls">
|
||||
<s:textfield id="amount" name="amount" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<s:submit cssClass="btn btn-primary"/>
|
||||
</div>
|
||||
</s:form>
|
||||
<a href="${pageContext.request.contextPath}/orders" class="btn btn-info">
|
||||
<i class="icon icon-arrow-left"></i> Back to Orders
|
||||
</a>
|
||||
</div><!--/row-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
<s:form method="post" action="%{#request.contextPath}/orders">
|
||||
<table>
|
||||
<s:textfield name="clientName" label="Client"/>
|
||||
<s:textfield name="amount" label="Amount" />
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<s:submit />
|
||||
</td>
|
||||
</table>
|
||||
</s:form>
|
||||
<a href="<%=request.getContextPath() %>/orders">Back to Orders</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,48 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html PUBLIC
|
||||
"-//W3C//DTD XHTML 1.1 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<%@taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<html lang="en">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Orders</title>
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<title>Orders</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
|
||||
<div class="page-header">
|
||||
<h1>Orders</h1>
|
||||
</div>
|
||||
<s:actionmessage cssClass="alert alert-error"/>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Client</th>
|
||||
<th>Amount</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<s:iterator value="model">
|
||||
<tr>
|
||||
<td>${id}</td>
|
||||
<td><s:property value="clientName"/></td>
|
||||
<td><s:property value="amount"/></td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a href="orders/${id}" class="btn"><i class="icon icon-eye-open"></i> View</a>
|
||||
<a href="orders/${id}/edit" class="btn"><i class="icon icon-edit"></i> Edit</a>
|
||||
<a href="orders/${id}/deleteConfirm" class="btn btn-danger"><i class="icon icon-trash"></i> Delete</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</s:iterator>
|
||||
</table>
|
||||
<a href="orders/new" class="btn btn-primary"><i class="icon icon-file"></i> Create a new order</a>
|
||||
</div><!--/row-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
<s:actionmessage />
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Client</th>
|
||||
<th>Amount</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
<s:iterator value="model">
|
||||
<tr>
|
||||
<td>${id}</td>
|
||||
<td>${clientName}</td>
|
||||
<td>${amount}</td>
|
||||
<td><a href="orders/${id}">View</a> |
|
||||
<a href="orders/${id}/edit">Edit</a> |
|
||||
<a href="orders/${id}/deleteConfirm">Delete</a></td>
|
||||
</tr>
|
||||
</s:iterator>
|
||||
</table>
|
||||
<a href="orders/new">Create a new order</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,40 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<%@taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<html lang="en">
|
||||
<!DOCTYPE html PUBLIC
|
||||
"-//W3C//DTD XHTML 1.1 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Order ${id}</title>
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap.css" rel="stylesheet">
|
||||
<link href="${pageContext.request.contextPath}/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<title>Order ${id}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<h1>Order ${id}</h1>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<td class="span3">ID</td>
|
||||
<td class="span9"><s:property value="id"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="span3">Client</td>
|
||||
<td class="span9"><s:property value="clientName"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="span3">Amount</td>
|
||||
<td class="span9"><s:property value="amount"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a href="${pageContext.request.contextPath}/orders" class="btn btn-info">
|
||||
<i class="icon icon-arrow-left"></i> Back to Orders
|
||||
</a>
|
||||
</div><!--/row-->
|
||||
</div><!--/span-->
|
||||
</div><!--/row-->
|
||||
<table>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<td>${id}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Client</th>
|
||||
<td>${clientName}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Amount</th>
|
||||
<td>${amount}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a href="../orders">Back to Orders</a>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
-5774
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
+46
-32
@@ -26,7 +26,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>2.3.7</version>
|
||||
<version>2.2.3</version>
|
||||
</parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-showcase</artifactId>
|
||||
@@ -34,9 +34,9 @@
|
||||
<name>Showcase Webapp</name>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/showcase</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_7/apps/showcase</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_7/apps/showcase</url>
|
||||
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/showcase</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_2_3/apps/showcase</developerConnection>
|
||||
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_2_3/apps/showcase</url>
|
||||
</scm>
|
||||
|
||||
|
||||
@@ -95,12 +95,6 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-json-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.tiles</groupId>
|
||||
<artifactId>tiles-jsp</artifactId>
|
||||
@@ -109,7 +103,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-convention-plugin</artifactId>
|
||||
<artifactId>struts2-codebehind-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -164,11 +158,10 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.myfaces.core</groupId>
|
||||
@@ -218,35 +211,47 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>8.0.0.M2</version>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<version>6.0.1</version>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>log4j.configuration</name>
|
||||
<value>file:${basedir}/src/main/resources/log4j.properties</value>
|
||||
</systemProperty>
|
||||
<systemProperty>
|
||||
<name>slf4j</name>
|
||||
<value>false</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
|
||||
<webAppConfig>
|
||||
<contextPath>/struts2-showcase</contextPath>
|
||||
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
|
||||
</webAppConfig>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.myfaces.core</groupId>
|
||||
<artifactId>myfaces-impl</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.myfaces.core</groupId>
|
||||
<artifactId>myfaces-api</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<version>1.2.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.twdata.maven</groupId>
|
||||
<artifactId>maven-itblast-plugin</artifactId>
|
||||
<version>0.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<containers>tomcat5x</containers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
@@ -272,4 +277,13 @@
|
||||
</resources>
|
||||
|
||||
</build>
|
||||
<!--
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>twdata-m2-repository</id>
|
||||
<name>twdata.org Maven Repository</name>
|
||||
<url>http://twdata-m2-repository.googlecode.com/svn/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
-->
|
||||
</project>
|
||||
|
||||
@@ -20,84 +20,87 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* <code>DateAction</code>
|
||||
*
|
||||
*/
|
||||
public class DateAction extends ActionSupport {
|
||||
|
||||
private static DateFormat DF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
||||
private static DateFormat DF = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
||||
|
||||
private Date now;
|
||||
private Date past;
|
||||
private Date future;
|
||||
private Date after;
|
||||
private Date before;
|
||||
private Date now;
|
||||
private Date past;
|
||||
private Date future;
|
||||
private Date after;
|
||||
private Date before;
|
||||
|
||||
|
||||
public String getDate() {
|
||||
return DF.format(new Date());
|
||||
}
|
||||
public String getDate() {
|
||||
return DF.format(new Date());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns the future.
|
||||
*/
|
||||
public Date getFuture() {
|
||||
return future;
|
||||
}
|
||||
/**
|
||||
* @return Returns the future.
|
||||
*/
|
||||
public Date getFuture() {
|
||||
return future;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the now.
|
||||
*/
|
||||
public Date getNow() {
|
||||
return now;
|
||||
}
|
||||
/**
|
||||
* @return Returns the now.
|
||||
*/
|
||||
public Date getNow() {
|
||||
return now;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the past.
|
||||
*/
|
||||
public Date getPast() {
|
||||
return past;
|
||||
}
|
||||
/**
|
||||
* @return Returns the past.
|
||||
*/
|
||||
public Date getPast() {
|
||||
return past;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the before date.
|
||||
*/
|
||||
public Date getBefore() {
|
||||
return before;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return Returns the before date.
|
||||
*/
|
||||
public Date getBefore() {
|
||||
return before;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the after date.
|
||||
*/
|
||||
public Date getAfter() {
|
||||
return after;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return Returns the after date.
|
||||
*/
|
||||
public Date getAfter() {
|
||||
return after;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String browse() throws Exception {
|
||||
Calendar cal = GregorianCalendar.getInstance();
|
||||
now = cal.getTime();
|
||||
cal.roll(Calendar.DATE, -1);
|
||||
cal.roll(Calendar.HOUR, -3);
|
||||
past = cal.getTime();
|
||||
cal.roll(Calendar.DATE, 2);
|
||||
future = cal.getTime();
|
||||
/**
|
||||
*/
|
||||
public String browse() throws Exception {
|
||||
Calendar cal = GregorianCalendar.getInstance();
|
||||
now = cal.getTime();
|
||||
cal.roll(Calendar.DATE, -1);
|
||||
cal.roll(Calendar.HOUR, -3);
|
||||
past = cal.getTime();
|
||||
cal.roll(Calendar.DATE, 2);
|
||||
future = cal.getTime();
|
||||
|
||||
cal.roll(Calendar.YEAR, -1);
|
||||
before = cal.getTime();
|
||||
cal.roll(Calendar.YEAR, -1);
|
||||
before = cal.getTime();
|
||||
|
||||
cal.roll(Calendar.YEAR, 2);
|
||||
after = cal.getTime();
|
||||
return SUCCESS;
|
||||
}
|
||||
cal.roll(Calendar.YEAR, 2);
|
||||
after = cal.getTime();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+17
-17
@@ -20,35 +20,35 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
//START SNIPPET: treeExampleDynamicJavaSelected
|
||||
|
||||
public class DynamicTreeSelectAction extends ActionSupport {
|
||||
|
||||
private long nodeId;
|
||||
private Category currentCategory;
|
||||
private long nodeId;
|
||||
private Category currentCategory;
|
||||
|
||||
|
||||
public void setNodeId(long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
public long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
public void setNodeId(long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
public long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
currentCategory = Category.getById(nodeId);
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
currentCategory = Category.getById(nodeId);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public String getNodeName() {
|
||||
return currentCategory != null ? currentCategory.getName() : "Node not found";
|
||||
}
|
||||
public String getNodeName() {
|
||||
return currentCategory != null ? currentCategory.getName() : "Node not found";
|
||||
}
|
||||
}
|
||||
|
||||
//START SNIPPET: treeExampleDynamicJavaSelected
|
||||
|
||||
+209
-203
@@ -20,261 +20,267 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class LotsOfOptiontransferselectAction extends ActionSupport {
|
||||
|
||||
private List _favouriteCartoonCharactersKeys;
|
||||
private List _notFavouriteCartoonCharactersKeys;
|
||||
private List _favouriteCartoonCharactersKeys;
|
||||
private List _notFavouriteCartoonCharactersKeys;
|
||||
|
||||
private List _favouriteCarsKeys;
|
||||
private List _notFavouriteCarsKeys;
|
||||
private List _favouriteCarsKeys;
|
||||
private List _notFavouriteCarsKeys;
|
||||
|
||||
private List _favouriteMotorcyclesKeys;
|
||||
private List _notFavouriteMotorcyclesKeys;
|
||||
private List _favouriteMotorcyclesKeys;
|
||||
private List _notFavouriteMotorcyclesKeys;
|
||||
|
||||
private List _favouriteCountriesKeys;
|
||||
private List _notFavouriteCountriesKeys;
|
||||
private List _favouriteCountriesKeys;
|
||||
private List _notFavouriteCountriesKeys;
|
||||
|
||||
private List _favouriteSportsKeys;
|
||||
private List _nonFavouriteSportsKeys;
|
||||
private List _favouriteSportsKeys;
|
||||
private List _nonFavouriteSportsKeys;
|
||||
|
||||
private List _favouriteCities;
|
||||
private List _favouriteCities;
|
||||
|
||||
private List _prioritisedFavouriteCartoonCharacters;
|
||||
private List _prioritisedFavouriteCars;
|
||||
private List _prioritisedFavouriteCountries;
|
||||
private List _prioritisedFavouriteCartoonCharacters;
|
||||
private List _prioritisedFavouriteCars;
|
||||
private List _prioritisedFavouriteCountries;
|
||||
|
||||
|
||||
// Cartoon Characters
|
||||
public Map getDefaultFavouriteCartoonCharacters() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("heMan", "He-Man");
|
||||
m.put("popeye", "Popeye");
|
||||
m.put("mockeyMouse", "Mickey Mouse");
|
||||
return m;
|
||||
}
|
||||
|
||||
public Map getDefaultNotFavouriteCartoonCharacters() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("donaldDuck", "Donald Duck");
|
||||
m.put("atomicAnt", "Atomic Ant");
|
||||
m.put("pinkPainter", "Pink Painter");
|
||||
return m;
|
||||
}
|
||||
// Cartoon Characters
|
||||
public Map getDefaultFavouriteCartoonCharacters() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("heMan", "He-Man");
|
||||
m.put("popeye", "Popeye");
|
||||
m.put("mockeyMouse", "Mickey Mouse");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getFavouriteCartoonCharacters() {
|
||||
return _favouriteCartoonCharactersKeys;
|
||||
}
|
||||
public Map getDefaultNotFavouriteCartoonCharacters() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("donaldDuck", "Donald Duck");
|
||||
m.put("atomicAnt", "Atomic Ant");
|
||||
m.put("pinkPainter", "Pink Painter");
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
|
||||
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
|
||||
}
|
||||
public List getFavouriteCartoonCharacters() {
|
||||
return _favouriteCartoonCharactersKeys;
|
||||
}
|
||||
|
||||
public List getNotFavouriteCartoonCharacters() {
|
||||
return _notFavouriteCartoonCharactersKeys;
|
||||
}
|
||||
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
|
||||
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
|
||||
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
|
||||
}
|
||||
public List getNotFavouriteCartoonCharacters() {
|
||||
return _notFavouriteCartoonCharactersKeys;
|
||||
}
|
||||
|
||||
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
|
||||
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
|
||||
// Cars
|
||||
public Map getDefaultFavouriteCars() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("alfaRomeo", "Alfa Romeo");
|
||||
m.put("Toyota", "Toyota");
|
||||
m.put("Mitsubitshi", "Mitsubitshi");
|
||||
return m;
|
||||
}
|
||||
|
||||
public Map getDefaultNotFavouriteCars() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("ford", "Ford");
|
||||
m.put("landRover", "Land Rover");
|
||||
m.put("mercedes", "Mercedes");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getFavouriteCars() {
|
||||
return _favouriteCarsKeys;
|
||||
}
|
||||
|
||||
public void setFavouriteCars(List favouriteCars) {
|
||||
_favouriteCarsKeys = favouriteCars;
|
||||
}
|
||||
|
||||
public List getNotFavouriteCars() {
|
||||
return _notFavouriteCarsKeys;
|
||||
}
|
||||
|
||||
public void setNotFavouriteCars(List notFavouriteCars) {
|
||||
_notFavouriteCarsKeys = notFavouriteCars;
|
||||
}
|
||||
|
||||
|
||||
// Motorcycles
|
||||
public Map getDefaultFavouriteMotorcycles() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("honda", "Honda");
|
||||
m.put("yamaha", "Yamaha");
|
||||
m.put("Aprillia", "Aprillia");
|
||||
return m;
|
||||
}
|
||||
|
||||
public Map getDefaultNotFavouriteMotorcycles() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("cagiva", "Cagiva");
|
||||
m.put("harleyDavidson", "Harley Davidson");
|
||||
m.put("suzuki", "Suzuki");
|
||||
return m;
|
||||
}
|
||||
// Cars
|
||||
public Map getDefaultFavouriteCars() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("alfaRomeo", "Alfa Romeo");
|
||||
m.put("Toyota", "Toyota");
|
||||
m.put("Mitsubitshi", "Mitsubitshi");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getFavouriteMotorcycles() {
|
||||
return _favouriteMotorcyclesKeys;
|
||||
}
|
||||
public Map getDefaultNotFavouriteCars() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("ford", "Ford");
|
||||
m.put("landRover", "Land Rover");
|
||||
m.put("mercedes", "Mercedes");
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
|
||||
_favouriteMotorcyclesKeys = favouriteMotorcycles;
|
||||
}
|
||||
public List getFavouriteCars() {
|
||||
return _favouriteCarsKeys;
|
||||
}
|
||||
|
||||
public List getNotFavouriteMotorcycles() {
|
||||
return _notFavouriteMotorcyclesKeys;
|
||||
}
|
||||
public void setFavouriteCars(List favouriteCars) {
|
||||
_favouriteCarsKeys = favouriteCars;
|
||||
}
|
||||
|
||||
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
|
||||
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
|
||||
}
|
||||
public List getNotFavouriteCars() {
|
||||
return _notFavouriteCarsKeys;
|
||||
}
|
||||
|
||||
public void setNotFavouriteCars(List notFavouriteCars) {
|
||||
_notFavouriteCarsKeys = notFavouriteCars;
|
||||
}
|
||||
|
||||
|
||||
// Countries
|
||||
public Map getDefaultFavouriteCountries() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("england", "England");
|
||||
m.put("america", "America");
|
||||
m.put("brazil", "Brazil");
|
||||
return m;
|
||||
}
|
||||
|
||||
public Map getDefaultNotFavouriteCountries() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("germany", "Germany");
|
||||
m.put("china", "China");
|
||||
m.put("russia", "Russia");
|
||||
return m;
|
||||
}
|
||||
// Motorcycles
|
||||
public Map getDefaultFavouriteMotorcycles() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("honda", "Honda");
|
||||
m.put("yamaha", "Yamaha");
|
||||
m.put("Aprillia", "Aprillia");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getFavouriteCountries() {
|
||||
return _favouriteCountriesKeys;
|
||||
}
|
||||
public Map getDefaultNotFavouriteMotorcycles() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("cagiva", "Cagiva");
|
||||
m.put("harleyDavidson", "Harley Davidson");
|
||||
m.put("suzuki", "Suzuki");
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setFavouriteCountries(List favouriteCountries) {
|
||||
_favouriteCountriesKeys = favouriteCountries;
|
||||
}
|
||||
public List getFavouriteMotorcycles() {
|
||||
return _favouriteMotorcyclesKeys;
|
||||
}
|
||||
|
||||
public List getNotFavouriteCountries() {
|
||||
return _notFavouriteCountriesKeys;
|
||||
}
|
||||
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
|
||||
_favouriteMotorcyclesKeys = favouriteMotorcycles;
|
||||
}
|
||||
|
||||
public void setNotFavouriteCountries(List notFavouriteCountries) {
|
||||
_notFavouriteCountriesKeys = notFavouriteCountries;
|
||||
}
|
||||
public List getNotFavouriteMotorcycles() {
|
||||
return _notFavouriteMotorcyclesKeys;
|
||||
}
|
||||
|
||||
// Sports
|
||||
public Map getDefaultNonFavoriteSports() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("basketball", "Basketball");
|
||||
m.put("football", "Football");
|
||||
m.put("baseball", "Baseball");
|
||||
return m;
|
||||
}
|
||||
|
||||
public Map getDefaultFavoriteSports() {
|
||||
return new LinkedHashMap();
|
||||
}
|
||||
|
||||
public List getFavouriteSports() {
|
||||
return _favouriteSportsKeys;
|
||||
}
|
||||
|
||||
public void setFavouriteSports(List favouriteSportsKeys) {
|
||||
this._favouriteSportsKeys = favouriteSportsKeys;
|
||||
}
|
||||
|
||||
public List getNonFavouriteSports() {
|
||||
return _nonFavouriteSportsKeys;
|
||||
}
|
||||
|
||||
public void setNonFavouriteSports(List notFavouriteSportsKeys) {
|
||||
this._nonFavouriteSportsKeys = notFavouriteSportsKeys;
|
||||
}
|
||||
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
|
||||
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
|
||||
}
|
||||
|
||||
|
||||
public List getPrioritisedFavouriteCartoonCharacters() {
|
||||
return _prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
|
||||
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
// Countries
|
||||
public Map getDefaultFavouriteCountries() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("england", "England");
|
||||
m.put("america", "America");
|
||||
m.put("brazil", "Brazil");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getPrioritisedFavouriteCars() {
|
||||
return _prioritisedFavouriteCars;
|
||||
}
|
||||
public Map getDefaultNotFavouriteCountries() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("germany", "Germany");
|
||||
m.put("china", "China");
|
||||
m.put("russia", "Russia");
|
||||
return m;
|
||||
}
|
||||
|
||||
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
|
||||
_prioritisedFavouriteCars = prioritisedFavouriteCars;
|
||||
}
|
||||
public List getFavouriteCountries() {
|
||||
return _favouriteCountriesKeys;
|
||||
}
|
||||
|
||||
public void setFavouriteCountries(List favouriteCountries) {
|
||||
_favouriteCountriesKeys = favouriteCountries;
|
||||
}
|
||||
|
||||
public List getNotFavouriteCountries() {
|
||||
return _notFavouriteCountriesKeys;
|
||||
}
|
||||
|
||||
public void setNotFavouriteCountries(List notFavouriteCountries) {
|
||||
_notFavouriteCountriesKeys = notFavouriteCountries;
|
||||
}
|
||||
|
||||
// Sports
|
||||
public Map getDefaultNonFavoriteSports() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("basketball", "Basketball");
|
||||
m.put("football", "Football");
|
||||
m.put("baseball", "Baseball");
|
||||
return m;
|
||||
}
|
||||
|
||||
public Map getDefaultFavoriteSports() {
|
||||
return new LinkedHashMap();
|
||||
}
|
||||
|
||||
public List getFavouriteSports() {
|
||||
return _favouriteSportsKeys;
|
||||
}
|
||||
|
||||
public void setFavouriteSports(List favouriteSportsKeys) {
|
||||
this._favouriteSportsKeys = favouriteSportsKeys;
|
||||
}
|
||||
|
||||
public List getNonFavouriteSports() {
|
||||
return _nonFavouriteSportsKeys;
|
||||
}
|
||||
|
||||
public void setNonFavouriteSports(List notFavouriteSportsKeys) {
|
||||
this._nonFavouriteSportsKeys = notFavouriteSportsKeys;
|
||||
}
|
||||
|
||||
|
||||
public List getPrioritisedFavouriteCountries() {
|
||||
return _prioritisedFavouriteCountries;
|
||||
}
|
||||
|
||||
|
||||
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
|
||||
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
|
||||
}
|
||||
public List getPrioritisedFavouriteCartoonCharacters() {
|
||||
return _prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
|
||||
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
public List getPrioritisedFavouriteCars() {
|
||||
return _prioritisedFavouriteCars;
|
||||
}
|
||||
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
|
||||
_prioritisedFavouriteCars = prioritisedFavouriteCars;
|
||||
}
|
||||
|
||||
|
||||
public Map getAvailableCities() {
|
||||
Map map = new LinkedHashMap();
|
||||
map.put("boston", "Boston");
|
||||
map.put("new york", "New York");
|
||||
map.put("london", "London");
|
||||
map.put("rome", "Rome");
|
||||
return map;
|
||||
}
|
||||
public List getPrioritisedFavouriteCountries() {
|
||||
return _prioritisedFavouriteCountries;
|
||||
}
|
||||
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
|
||||
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
|
||||
}
|
||||
|
||||
public List getDefaultFavouriteCities() {
|
||||
List list = new ArrayList();
|
||||
list.add("boston");
|
||||
list.add("rome");
|
||||
return list;
|
||||
}
|
||||
|
||||
public List getFavouriteCities() {
|
||||
return _favouriteCities;
|
||||
}
|
||||
|
||||
public void setFavouriteCities(List favouriteCities) {
|
||||
this._favouriteCities = favouriteCities;
|
||||
}
|
||||
public Map getAvailableCities() {
|
||||
Map map = new LinkedHashMap();
|
||||
map.put("boston", "Boston");
|
||||
map.put("new york", "New York");
|
||||
map.put("london", "London");
|
||||
map.put("rome", "Rome");
|
||||
return map;
|
||||
}
|
||||
|
||||
// actions
|
||||
public List getDefaultFavouriteCities() {
|
||||
List list = new ArrayList();
|
||||
list.add("boston");
|
||||
list.add("rome");
|
||||
return list;
|
||||
}
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public List getFavouriteCities() {
|
||||
return _favouriteCities;
|
||||
}
|
||||
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public void setFavouriteCities(List favouriteCities) {
|
||||
this._favouriteCities = favouriteCities;
|
||||
}
|
||||
|
||||
// actions
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+38
-38
@@ -27,52 +27,52 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
*/
|
||||
public class LotsOfRichtexteditorAction extends ActionSupport {
|
||||
|
||||
public String description1;
|
||||
public String description2 = "This is Description 2";
|
||||
public String description3;
|
||||
public String description4 = "This is Description 4";
|
||||
public String description1;
|
||||
public String description2 = "This is Description 2";
|
||||
public String description3;
|
||||
public String description4 = "This is Description 4";
|
||||
|
||||
public String getDescription1() {
|
||||
return this.description1;
|
||||
}
|
||||
|
||||
public void setDescription1(String description1) {
|
||||
this.description1 = description1;
|
||||
}
|
||||
public String getDescription1() {
|
||||
return this.description1;
|
||||
}
|
||||
public void setDescription1(String description1) {
|
||||
this.description1 = description1;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription2() {
|
||||
return this.description2;
|
||||
}
|
||||
|
||||
public void setDescription2(String description2) {
|
||||
this.description2 = description2;
|
||||
}
|
||||
public String getDescription2() {
|
||||
return this.description2;
|
||||
}
|
||||
public void setDescription2(String description2) {
|
||||
this.description2 = description2;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription3() {
|
||||
return this.description3;
|
||||
}
|
||||
|
||||
public void setDescription3(String description3) {
|
||||
this.description3 = description3;
|
||||
}
|
||||
public String getDescription3() {
|
||||
return this.description3;
|
||||
}
|
||||
public void setDescription3(String description3) {
|
||||
this.description3 = description3;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription4() {
|
||||
return this.description4;
|
||||
}
|
||||
|
||||
public void setDescription4(String description4) {
|
||||
this.description4 = description4;
|
||||
}
|
||||
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public String getDescription4() {
|
||||
return this.description4;
|
||||
}
|
||||
public void setDescription4(String description4) {
|
||||
this.description4 = description4;
|
||||
}
|
||||
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,115 +22,114 @@ package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MoreSelectsAction extends ActionSupport {
|
||||
|
||||
|
||||
private List _prioritisedFavouriteCartoonCharacters;
|
||||
private List _prioritisedFavouriteCars;
|
||||
private List _prioritisedFavouriteCountries;
|
||||
private List favouriteNumbers;
|
||||
private List _prioritisedFavouriteCartoonCharacters;
|
||||
private List _prioritisedFavouriteCars;
|
||||
private List _prioritisedFavouriteCountries;
|
||||
private List favouriteNumbers;
|
||||
|
||||
|
||||
// Cartoon Characters
|
||||
public Map getDefaultFavouriteCartoonCharacters() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("heMan", "He-Man");
|
||||
m.put("popeye", "Popeye");
|
||||
m.put("mockeyMouse", "Mickey Mouse");
|
||||
return m;
|
||||
}
|
||||
// Cartoon Characters
|
||||
public Map getDefaultFavouriteCartoonCharacters() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("heMan", "He-Man");
|
||||
m.put("popeye", "Popeye");
|
||||
m.put("mockeyMouse", "Mickey Mouse");
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
// Cars
|
||||
public Map getDefaultFavouriteCars() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("alfaRomeo", "Alfa Romeo");
|
||||
m.put("Toyota", "Toyota");
|
||||
m.put("Mitsubitshi", "Mitsubitshi");
|
||||
return m;
|
||||
}
|
||||
// Cars
|
||||
public Map getDefaultFavouriteCars() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("alfaRomeo", "Alfa Romeo");
|
||||
m.put("Toyota", "Toyota");
|
||||
m.put("Mitsubitshi", "Mitsubitshi");
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
// Countries
|
||||
public Map getDefaultFavouriteCountries() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("england", "England");
|
||||
m.put("america", "America");
|
||||
m.put("brazil", "Brazil");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getDefaultFavouriteNumbers() {
|
||||
List list = new ArrayList();
|
||||
list.add("Three");
|
||||
list.add("Seven");
|
||||
return list;
|
||||
}
|
||||
// Countries
|
||||
public Map getDefaultFavouriteCountries() {
|
||||
Map m = new LinkedHashMap();
|
||||
m.put("england", "England");
|
||||
m.put("america", "America");
|
||||
m.put("brazil", "Brazil");
|
||||
return m;
|
||||
}
|
||||
|
||||
public List getDefaultFavouriteNumbers() {
|
||||
List list = new ArrayList();
|
||||
list.add("Three");
|
||||
list.add("Seven");
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public List getPrioritisedFavouriteCartoonCharacters() {
|
||||
return _prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
|
||||
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
public List getPrioritisedFavouriteCartoonCharacters() {
|
||||
return _prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
|
||||
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
|
||||
}
|
||||
|
||||
public List getPrioritisedFavouriteCars() {
|
||||
return _prioritisedFavouriteCars;
|
||||
}
|
||||
|
||||
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
|
||||
_prioritisedFavouriteCars = prioritisedFavouriteCars;
|
||||
}
|
||||
public List getPrioritisedFavouriteCars() {
|
||||
return _prioritisedFavouriteCars;
|
||||
}
|
||||
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
|
||||
_prioritisedFavouriteCars = prioritisedFavouriteCars;
|
||||
}
|
||||
|
||||
|
||||
public List getPrioritisedFavouriteCountries() {
|
||||
return _prioritisedFavouriteCountries;
|
||||
}
|
||||
public List getPrioritisedFavouriteCountries() {
|
||||
return _prioritisedFavouriteCountries;
|
||||
}
|
||||
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
|
||||
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
|
||||
}
|
||||
|
||||
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
|
||||
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
|
||||
}
|
||||
public List getFavouriteNumbers() {
|
||||
return favouriteNumbers;
|
||||
}
|
||||
|
||||
public List getFavouriteNumbers() {
|
||||
return favouriteNumbers;
|
||||
}
|
||||
public void setFavouriteNumbers(List favouriteNumbers) {
|
||||
this.favouriteNumbers = favouriteNumbers;
|
||||
}
|
||||
|
||||
public void setFavouriteNumbers(List favouriteNumbers) {
|
||||
this.favouriteNumbers = favouriteNumbers;
|
||||
}
|
||||
public Map getAvailableCities() {
|
||||
Map map = new LinkedHashMap();
|
||||
map.put("boston", "Boston");
|
||||
map.put("new york", "New York");
|
||||
map.put("london", "London");
|
||||
map.put("rome", "Rome");
|
||||
return map;
|
||||
}
|
||||
|
||||
public Map getAvailableCities() {
|
||||
Map map = new LinkedHashMap();
|
||||
map.put("boston", "Boston");
|
||||
map.put("new york", "New York");
|
||||
map.put("london", "London");
|
||||
map.put("rome", "Rome");
|
||||
return map;
|
||||
}
|
||||
public List getDefaultFavouriteCities() {
|
||||
List list = new ArrayList();
|
||||
list.add("boston");
|
||||
list.add("rome");
|
||||
return list;
|
||||
}
|
||||
|
||||
public List getDefaultFavouriteCities() {
|
||||
List list = new ArrayList();
|
||||
list.add("boston");
|
||||
list.add("rome");
|
||||
return list;
|
||||
}
|
||||
// actions
|
||||
|
||||
// actions
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public String submit() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-11
@@ -20,21 +20,22 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class ShowAjaxDynamicTreeAction extends ActionSupport {
|
||||
private int nodeId = 1;
|
||||
private int nodeId = 1;
|
||||
|
||||
public Category getCategory() {
|
||||
return Category.getById(nodeId);
|
||||
}
|
||||
public Category getCategory() {
|
||||
return Category.getById(nodeId);
|
||||
}
|
||||
|
||||
public int getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
public int getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setNodeId(int nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
public void setNodeId(int nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,17 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
// START SNIPPET: treeExampleDynamicJavaShow
|
||||
|
||||
public class ShowDynamicTreeAction extends ActionSupport {
|
||||
|
||||
public Category getTreeRootNode() {
|
||||
return Category.getById(1);
|
||||
}
|
||||
public Category getTreeRootNode() {
|
||||
return Category.getById(1);
|
||||
}
|
||||
}
|
||||
|
||||
// END SNIPPET: treeExampleDynamicJavaShow
|
||||
|
||||
@@ -20,330 +20,310 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class UITagExample extends ActionSupport implements Validateable {
|
||||
|
||||
private static final long serialVersionUID = -94044809860988047L;
|
||||
|
||||
|
||||
String name;
|
||||
Date birthday;
|
||||
Date wakeup;
|
||||
String bio;
|
||||
String favouriteColor;
|
||||
List friends;
|
||||
String bestFriend;
|
||||
boolean legalAge;
|
||||
String state;
|
||||
String region;
|
||||
File picture;
|
||||
String pictureContentType;
|
||||
String pictureFileName;
|
||||
String favouriteLanguage;
|
||||
String favouriteVehicalType = "MotorcycleKey";
|
||||
String favouriteVehicalSpecific = "YamahaKey";
|
||||
|
||||
List leftSideCartoonCharacters;
|
||||
List rightSideCartoonCharacters;
|
||||
|
||||
List favouriteLanguages = new ArrayList();
|
||||
List vehicalTypeList = new ArrayList();
|
||||
Map vehicalSpecificMap = new HashMap();
|
||||
|
||||
String thoughts;
|
||||
|
||||
public UITagExample() {
|
||||
favouriteLanguages.add(new Language("EnglishKey", "English Language", "color: blue; font-style: italic;"));
|
||||
favouriteLanguages.add(new Language("FrenchKey", "French Language", "color: grey;"));
|
||||
favouriteLanguages.add(new Language("SpanishKey", "Spanish Language", "color: red; font-wight: bold;"));
|
||||
|
||||
VehicalType car = new VehicalType("CarKey", "Car");
|
||||
VehicalType motorcycle = new VehicalType("MotorcycleKey", "Motorcycle");
|
||||
vehicalTypeList.add(car);
|
||||
vehicalTypeList.add(motorcycle);
|
||||
|
||||
List cars = new ArrayList();
|
||||
cars.add(new VehicalSpecific("MercedesKey", "Mercedes"));
|
||||
cars.add(new VehicalSpecific("HondaKey", "Honda"));
|
||||
cars.add(new VehicalSpecific("FordKey", "Ford"));
|
||||
|
||||
List motorcycles = new ArrayList();
|
||||
motorcycles.add(new VehicalSpecific("SuzukiKey", "Suzuki"));
|
||||
motorcycles.add(new VehicalSpecific("YamahaKey", "Yamaha"));
|
||||
|
||||
vehicalSpecificMap.put(car, cars);
|
||||
vehicalSpecificMap.put(motorcycle, motorcycles);
|
||||
}
|
||||
|
||||
|
||||
public List getLeftSideCartoonCharacters() {
|
||||
return leftSideCartoonCharacters;
|
||||
}
|
||||
|
||||
public void setLeftSideCartoonCharacters(List leftSideCartoonCharacters) {
|
||||
this.leftSideCartoonCharacters = leftSideCartoonCharacters;
|
||||
}
|
||||
|
||||
|
||||
public List getRightSideCartoonCharacters() {
|
||||
return rightSideCartoonCharacters;
|
||||
}
|
||||
|
||||
public void setRightSideCartoonCharacters(List rightSideCartoonCharacters) {
|
||||
this.rightSideCartoonCharacters = rightSideCartoonCharacters;
|
||||
}
|
||||
|
||||
|
||||
public String getFavouriteVehicalType() {
|
||||
return favouriteVehicalType;
|
||||
}
|
||||
|
||||
public void setFavouriteVehicalType(String favouriteVehicalType) {
|
||||
this.favouriteVehicalType = favouriteVehicalType;
|
||||
}
|
||||
|
||||
public String getFavouriteVehicalSpecific() {
|
||||
return favouriteVehicalSpecific;
|
||||
}
|
||||
|
||||
public void setFavouriteVehicalSpecific(String favouriteVehicalSpecific) {
|
||||
this.favouriteVehicalSpecific = favouriteVehicalSpecific;
|
||||
}
|
||||
|
||||
public List getVehicalTypeList() {
|
||||
return vehicalTypeList;
|
||||
}
|
||||
|
||||
public List getVehicalSpecificList() {
|
||||
ValueStack stack = ServletActionContext.getValueStack(ServletActionContext.getRequest());
|
||||
Object vehicalType = stack.findValue("top");
|
||||
if (vehicalType != null && vehicalType instanceof VehicalType) {
|
||||
List l = (List) vehicalSpecificMap.get(vehicalType);
|
||||
return l;
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
public List getFavouriteLanguages() {
|
||||
return favouriteLanguages;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
private static final long serialVersionUID = -94044809860988047L;
|
||||
|
||||
|
||||
String name;
|
||||
Date birthday;
|
||||
Date wakeup;
|
||||
String bio;
|
||||
String favouriteColor;
|
||||
List friends;
|
||||
boolean legalAge;
|
||||
String state;
|
||||
String region;
|
||||
File picture;
|
||||
String pictureContentType;
|
||||
String pictureFileName;
|
||||
String favouriteLanguage;
|
||||
String favouriteVehicalType = "MotorcycleKey";
|
||||
String favouriteVehicalSpecific = "YamahaKey";
|
||||
|
||||
List leftSideCartoonCharacters;
|
||||
List rightSideCartoonCharacters;
|
||||
|
||||
List favouriteLanguages = new ArrayList();
|
||||
List vehicalTypeList = new ArrayList();
|
||||
Map vehicalSpecificMap = new HashMap();
|
||||
|
||||
String thoughts;
|
||||
|
||||
public UITagExample() {
|
||||
favouriteLanguages.add(new Language("EnglishKey", "English Language"));
|
||||
favouriteLanguages.add(new Language("FrenchKey", "French Language"));
|
||||
favouriteLanguages.add(new Language("SpanishKey", "Spanish Language"));
|
||||
|
||||
VehicalType car = new VehicalType("CarKey", "Car");
|
||||
VehicalType motorcycle = new VehicalType("MotorcycleKey", "Motorcycle");
|
||||
vehicalTypeList.add(car);
|
||||
vehicalTypeList.add(motorcycle);
|
||||
|
||||
List cars = new ArrayList();
|
||||
cars.add(new VehicalSpecific("MercedesKey", "Mercedes"));
|
||||
cars.add(new VehicalSpecific("HondaKey", "Honda"));
|
||||
cars.add(new VehicalSpecific("FordKey", "Ford"));
|
||||
|
||||
List motorcycles = new ArrayList();
|
||||
motorcycles.add(new VehicalSpecific("SuzukiKey", "Suzuki"));
|
||||
motorcycles.add(new VehicalSpecific("YamahaKey", "Yamaha"));
|
||||
|
||||
vehicalSpecificMap.put(car, cars);
|
||||
vehicalSpecificMap.put(motorcycle, motorcycles);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List getLeftSideCartoonCharacters() {
|
||||
return leftSideCartoonCharacters;
|
||||
}
|
||||
public void setLeftSideCartoonCharacters(List leftSideCartoonCharacters) {
|
||||
this.leftSideCartoonCharacters = leftSideCartoonCharacters;
|
||||
}
|
||||
|
||||
|
||||
public List getRightSideCartoonCharacters() {
|
||||
return rightSideCartoonCharacters;
|
||||
}
|
||||
public void setRightSideCartoonCharacters(List rightSideCartoonCharacters) {
|
||||
this.rightSideCartoonCharacters = rightSideCartoonCharacters;
|
||||
}
|
||||
|
||||
|
||||
public String getFavouriteVehicalType() {
|
||||
return favouriteVehicalType;
|
||||
}
|
||||
|
||||
public void setFavouriteVehicalType(String favouriteVehicalType) {
|
||||
this.favouriteVehicalType = favouriteVehicalType;
|
||||
}
|
||||
|
||||
public String getFavouriteVehicalSpecific() {
|
||||
return favouriteVehicalSpecific;
|
||||
}
|
||||
|
||||
public void setFavouriteVehicalSpecific(String favouriteVehicalSpecific) {
|
||||
this.favouriteVehicalSpecific = favouriteVehicalSpecific;
|
||||
}
|
||||
|
||||
public List getVehicalTypeList() {
|
||||
return vehicalTypeList;
|
||||
}
|
||||
|
||||
public List getVehicalSpecificList() {
|
||||
ValueStack stack = ServletActionContext.getValueStack(ServletActionContext.getRequest());
|
||||
Object vehicalType = stack.findValue("top");
|
||||
if (vehicalType != null && vehicalType instanceof VehicalType) {
|
||||
List l = (List) vehicalSpecificMap.get(vehicalType);
|
||||
return l;
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
public List getFavouriteLanguages() {
|
||||
return favouriteLanguages;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
|
||||
public Date getBirthday() {
|
||||
return birthday;
|
||||
}
|
||||
public String getBio() {
|
||||
return bio;
|
||||
}
|
||||
|
||||
public void setBirthday(Date birthday) {
|
||||
this.birthday = birthday;
|
||||
}
|
||||
public void setBio(String bio) {
|
||||
this.bio = bio;
|
||||
}
|
||||
|
||||
public String getBio() {
|
||||
return bio;
|
||||
}
|
||||
public String getFavouriteColor() {
|
||||
return favouriteColor;
|
||||
}
|
||||
|
||||
public void setBio(String bio) {
|
||||
this.bio = bio;
|
||||
}
|
||||
public void setFavouriteColor(String favoriteColor) {
|
||||
this.favouriteColor = favoriteColor;
|
||||
}
|
||||
|
||||
public String getFavouriteColor() {
|
||||
return favouriteColor;
|
||||
}
|
||||
public List getFriends() {
|
||||
return friends;
|
||||
}
|
||||
|
||||
public void setFavouriteColor(String favoriteColor) {
|
||||
this.favouriteColor = favoriteColor;
|
||||
}
|
||||
public void setFriends(List friends) {
|
||||
this.friends = friends;
|
||||
}
|
||||
|
||||
public List getFriends() {
|
||||
return friends;
|
||||
}
|
||||
public boolean isLegalAge() {
|
||||
return legalAge;
|
||||
}
|
||||
|
||||
public void setFriends(List friends) {
|
||||
this.friends = friends;
|
||||
}
|
||||
|
||||
public String getBestFriend() {
|
||||
return bestFriend;
|
||||
}
|
||||
|
||||
public void setBestFriend(String bestFriend) {
|
||||
this.bestFriend = bestFriend;
|
||||
}
|
||||
|
||||
public boolean isLegalAge() {
|
||||
return legalAge;
|
||||
}
|
||||
|
||||
public void setLegalAge(boolean legalAge) {
|
||||
this.legalAge = legalAge;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public void setPicture(File picture) {
|
||||
this.picture = picture;
|
||||
}
|
||||
|
||||
public File getPicture() {
|
||||
return this.picture;
|
||||
}
|
||||
|
||||
public void setPictureContentType(String pictureContentType) {
|
||||
this.pictureContentType = pictureContentType;
|
||||
}
|
||||
|
||||
public void setPictureFileName(String pictureFileName) {
|
||||
this.pictureFileName = pictureFileName;
|
||||
}
|
||||
|
||||
public void setFavouriteLanguage(String favouriteLanguage) {
|
||||
this.favouriteLanguage = favouriteLanguage;
|
||||
}
|
||||
|
||||
public String getFavouriteLanguage() {
|
||||
return favouriteLanguage;
|
||||
}
|
||||
|
||||
|
||||
public void setThoughts(String thoughts) {
|
||||
this.thoughts = thoughts;
|
||||
}
|
||||
|
||||
public String getThoughts() {
|
||||
return this.thoughts;
|
||||
}
|
||||
|
||||
public Date getWakeup() {
|
||||
return wakeup;
|
||||
}
|
||||
|
||||
public void setWakeup(Date wakeup) {
|
||||
this.wakeup = wakeup;
|
||||
}
|
||||
|
||||
public String doSubmit() {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// === inner class
|
||||
public static class Language {
|
||||
String description;
|
||||
String key;
|
||||
String style;
|
||||
|
||||
public Language(String key, String description, String style) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class VehicalType {
|
||||
String key;
|
||||
String description;
|
||||
|
||||
public VehicalType(String key, String description) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof VehicalType)) {
|
||||
return false;
|
||||
} else {
|
||||
return key.equals(((VehicalType) obj).getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class VehicalSpecific {
|
||||
String key;
|
||||
String description;
|
||||
|
||||
public VehicalSpecific(String key, String description) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof VehicalSpecific)) {
|
||||
return false;
|
||||
} else {
|
||||
return key.equals(((VehicalSpecific) obj).getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
}
|
||||
public void setLegalAge(boolean legalAge) {
|
||||
this.legalAge = legalAge;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public void setPicture(File picture) {
|
||||
this.picture = picture;
|
||||
}
|
||||
|
||||
public File getPicture() {
|
||||
return this.picture;
|
||||
}
|
||||
|
||||
public void setPictureContentType(String pictureContentType) {
|
||||
this.pictureContentType = pictureContentType;
|
||||
}
|
||||
|
||||
public void setPictureFileName(String pictureFileName) {
|
||||
this.pictureFileName = pictureFileName;
|
||||
}
|
||||
|
||||
public void setFavouriteLanguage(String favouriteLanguage) {
|
||||
this.favouriteLanguage = favouriteLanguage;
|
||||
}
|
||||
|
||||
public String getFavouriteLanguage() {
|
||||
return favouriteLanguage;
|
||||
}
|
||||
|
||||
|
||||
public void setThoughts(String thoughts) {
|
||||
this.thoughts = thoughts;
|
||||
}
|
||||
|
||||
public String getThoughts() {
|
||||
return this.thoughts;
|
||||
}
|
||||
|
||||
public Date getWakeup() {
|
||||
return wakeup;
|
||||
}
|
||||
|
||||
public void setWakeup(Date wakeup) {
|
||||
this.wakeup = wakeup;
|
||||
}
|
||||
|
||||
public String doSubmit() {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// === inner class
|
||||
public static class Language {
|
||||
String description;
|
||||
String key;
|
||||
|
||||
public Language(String key, String description) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class VehicalType {
|
||||
String key;
|
||||
String description;
|
||||
public VehicalType(String key, String description) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getKey() { return this.key; }
|
||||
public String getDescription() { return this.description; }
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof VehicalType)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return key.equals(((VehicalType)obj).getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class VehicalSpecific {
|
||||
String key;
|
||||
String description;
|
||||
public VehicalSpecific(String key, String description) {
|
||||
this.key = key;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getKey() { return this.key; }
|
||||
public String getDescription() { return this.description; }
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (! (obj instanceof VehicalSpecific)) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return key.equals(((VehicalSpecific)obj).getKey());
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return key.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+54
-52
@@ -20,76 +20,78 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.struts2.showcase.dao.Dao;
|
||||
import org.apache.struts2.showcase.model.IdEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* AbstractCRUDAction.
|
||||
*
|
||||
*/
|
||||
|
||||
public abstract class AbstractCRUDAction extends ActionSupport {
|
||||
|
||||
private static final Logger log = Logger.getLogger(AbstractCRUDAction.class);
|
||||
private static final Logger log = Logger.getLogger(AbstractCRUDAction.class);
|
||||
|
||||
private Collection availableItems;
|
||||
private String[] toDelete;
|
||||
private Collection availableItems;
|
||||
private String[] toDelete;
|
||||
|
||||
protected abstract Dao getDao();
|
||||
protected abstract Dao getDao();
|
||||
|
||||
|
||||
public Collection getAvailableItems() {
|
||||
return availableItems;
|
||||
}
|
||||
public Collection getAvailableItems() {
|
||||
return availableItems;
|
||||
}
|
||||
|
||||
public String[] getToDelete() {
|
||||
return toDelete;
|
||||
}
|
||||
public String[] getToDelete() {
|
||||
return toDelete;
|
||||
}
|
||||
|
||||
public void setToDelete(String[] toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
public void setToDelete(String[] toDelete) {
|
||||
this.toDelete = toDelete;
|
||||
}
|
||||
|
||||
public String list() throws Exception {
|
||||
this.availableItems = getDao().findAll();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [list]: " + (availableItems != null ? "" + availableItems.size() : "no") + " items found");
|
||||
}
|
||||
return execute();
|
||||
}
|
||||
public String list() throws Exception {
|
||||
this.availableItems = getDao().findAll();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [list]: " + (availableItems !=null?""+availableItems.size():"no") + " items found");
|
||||
}
|
||||
return execute();
|
||||
}
|
||||
|
||||
public String delete() throws Exception {
|
||||
if (toDelete != null) {
|
||||
int count = 0;
|
||||
for (int i = 0, j = toDelete.length; i < j; i++) {
|
||||
count = count + getDao().delete(toDelete[i]);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String delete() throws Exception {
|
||||
if (toDelete != null) {
|
||||
int count=0;
|
||||
for (int i = 0, j=toDelete.length; i < j; i++) {
|
||||
count = count + getDao().delete(toDelete[i]);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
|
||||
*
|
||||
* @param tryId The id to try to get persistent object for
|
||||
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
|
||||
* object for
|
||||
* @return The persistent object, if found. <tt>null</tt> otherwise.
|
||||
*/
|
||||
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
|
||||
IdEntity result = null;
|
||||
if (tryId != null) {
|
||||
result = getDao().get(tryId);
|
||||
} else if (tryObject != null) {
|
||||
result = getDao().get(tryObject.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.
|
||||
*
|
||||
* @param tryId The id to try to get persistent object for
|
||||
* @param tryObject The object, induced by first params invocation, possibly containing id to try to get persistent
|
||||
* object for
|
||||
* @return The persistent object, if found. <tt>null</tt> otherwise.
|
||||
*/
|
||||
protected IdEntity fetch(Serializable tryId, IdEntity tryObject) {
|
||||
IdEntity result = null;
|
||||
if (tryId != null) {
|
||||
result = getDao().get(tryId);
|
||||
} else if (tryObject != null) {
|
||||
result = getDao().get(tryObject.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+73
-68
@@ -20,19 +20,19 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.struts2.showcase.application.TestDataProvider;
|
||||
import org.apache.struts2.showcase.dao.Dao;
|
||||
import org.apache.struts2.showcase.dao.EmployeeDao;
|
||||
import org.apache.struts2.showcase.model.Employee;
|
||||
import org.apache.struts2.showcase.model.Skill;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
|
||||
/**
|
||||
* JsfEmployeeAction.
|
||||
@@ -40,82 +40,87 @@ import java.util.List;
|
||||
|
||||
public class EmployeeAction extends AbstractCRUDAction implements Preparable {
|
||||
|
||||
private static final long serialVersionUID = 7047317819789938957L;
|
||||
private static final long serialVersionUID = 7047317819789938957L;
|
||||
|
||||
private static final Logger log = Logger.getLogger(EmployeeAction.class);
|
||||
private static final Logger log = Logger.getLogger(EmployeeAction.class);
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
private Long empId;
|
||||
protected EmployeeDao employeeDao;
|
||||
private Employee currentEmployee;
|
||||
private List selectedSkills;
|
||||
|
||||
private Long empId;
|
||||
private Employee currentEmployee;
|
||||
private List<String> selectedSkills;
|
||||
public Long getEmpId() {
|
||||
return empId;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
|
||||
setSelectedSkills(new ArrayList<String>());
|
||||
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
|
||||
while (it.hasNext()) {
|
||||
getSelectedSkills().add(((Skill) it.next()).getName());
|
||||
}
|
||||
}
|
||||
return super.execute();
|
||||
}
|
||||
public void setEmpId(Long empId) {
|
||||
this.empId = empId;
|
||||
}
|
||||
|
||||
public String save() throws Exception {
|
||||
if (getCurrentEmployee() != null) {
|
||||
setEmpId((Long) employeeDao.merge(getCurrentEmployee()));
|
||||
employeeDao.setSkills(getEmpId(), getSelectedSkills());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public Employee getCurrentEmployee() {
|
||||
return currentEmployee;
|
||||
}
|
||||
|
||||
public Long getEmpId() {
|
||||
return empId;
|
||||
}
|
||||
public void setCurrentEmployee(Employee currentEmployee) {
|
||||
this.currentEmployee = currentEmployee;
|
||||
}
|
||||
|
||||
public void setEmpId(Long empId) {
|
||||
this.empId = empId;
|
||||
}
|
||||
public String[] getAvailablePositions() {
|
||||
return TestDataProvider.POSITIONS;
|
||||
}
|
||||
|
||||
public Employee getCurrentEmployee() {
|
||||
return currentEmployee;
|
||||
}
|
||||
public List getAvailableLevels() {
|
||||
return Arrays.asList(TestDataProvider.LEVELS);
|
||||
}
|
||||
|
||||
public void setCurrentEmployee(Employee currentEmployee) {
|
||||
this.currentEmployee = currentEmployee;
|
||||
}
|
||||
public List getSelectedSkills() {
|
||||
return selectedSkills;
|
||||
}
|
||||
|
||||
public String[] getAvailablePositions() {
|
||||
return TestDataProvider.POSITIONS;
|
||||
}
|
||||
public void setSelectedSkills(List selectedSkills) {
|
||||
this.selectedSkills = selectedSkills;
|
||||
}
|
||||
|
||||
public List getAvailableLevels() {
|
||||
return Arrays.asList(TestDataProvider.LEVELS);
|
||||
}
|
||||
protected Dao getDao() {
|
||||
return employeeDao;
|
||||
}
|
||||
|
||||
public List<String> getSelectedSkills() {
|
||||
return selectedSkills;
|
||||
}
|
||||
public void setEmployeeDao(EmployeeDao employeeDao) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("JsfEmployeeAction - [setEmployeeDao]: employeeDao injected.");
|
||||
}
|
||||
this.employeeDao = employeeDao;
|
||||
}
|
||||
|
||||
public void setSelectedSkills(List<String> selectedSkills) {
|
||||
this.selectedSkills = selectedSkills;
|
||||
}
|
||||
/**
|
||||
* This method is called to allow the action to prepare itself.
|
||||
*
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
*/
|
||||
public void prepare() throws Exception {
|
||||
Employee preFetched = (Employee) fetch(getEmpId(), getCurrentEmployee());
|
||||
if (preFetched != null) {
|
||||
setCurrentEmployee(preFetched);
|
||||
}
|
||||
}
|
||||
|
||||
protected Dao getDao() {
|
||||
return employeeDao;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
if (getCurrentEmployee() != null && getCurrentEmployee().getOtherSkills() != null) {
|
||||
setSelectedSkills(new ArrayList());
|
||||
Iterator it = getCurrentEmployee().getOtherSkills().iterator();
|
||||
while (it.hasNext()) {
|
||||
getSelectedSkills().add(((Skill) it.next()).getName());
|
||||
}
|
||||
}
|
||||
return super.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to allow the action to prepare itself.
|
||||
*
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
*/
|
||||
public void prepare() throws Exception {
|
||||
Employee preFetched = (Employee) fetch(getEmpId(), getCurrentEmployee());
|
||||
if (preFetched != null) {
|
||||
setCurrentEmployee(preFetched);
|
||||
}
|
||||
}
|
||||
public String save() throws Exception {
|
||||
if (getCurrentEmployee() != null) {
|
||||
setEmpId((Long) employeeDao.merge(getCurrentEmployee()));
|
||||
employeeDao.setSkills(getEmpId(), getSelectedSkills());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,65 +20,69 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ExampleAction extends ActionSupport {
|
||||
public static final String CONSTANT = "Struts Rocks!";
|
||||
public static final String CONSTANT = "Struts Rocks!";
|
||||
|
||||
public static Date getCurrentDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "John Galt";
|
||||
}
|
||||
|
||||
public static Date getCurrentDate() {
|
||||
return new Date();
|
||||
}
|
||||
public String[] getBands() {
|
||||
return new String[] { "Pink Floyd", "Metallica", "Guns & Roses" };
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "John Galt";
|
||||
}
|
||||
public List<String> getMovies() {
|
||||
return Arrays.asList("Lord of the Rings", "Matrix");
|
||||
}
|
||||
|
||||
public String[] getBands() {
|
||||
return new String[]{"Pink Floyd", "Metallica", "Guns & Roses"};
|
||||
}
|
||||
public Book getBook() {
|
||||
return new Book("Iliad", "Homer");
|
||||
}
|
||||
|
||||
public List<String> getMovies() {
|
||||
return Arrays.asList("Lord of the Rings", "Matrix");
|
||||
}
|
||||
|
||||
public Book getBook() {
|
||||
return new Book("Iliad", "Homer");
|
||||
}
|
||||
|
||||
public Map<String, Book> getBooks() {
|
||||
Map<String, Book> books = new HashMap<String, Book>();
|
||||
books.put("Iliad", new Book("Iliad", "Homer"));
|
||||
books.put("The Republic", new Book("The Replublic", "Plato"));
|
||||
books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra",
|
||||
"Friedrich Nietzsche"));
|
||||
return books;
|
||||
}
|
||||
public Map<String, Book> getBooks() {
|
||||
Map<String, Book> books = new HashMap<String, Book>();
|
||||
books.put("Iliad", new Book("Iliad", "Homer"));
|
||||
books.put("The Republic", new Book("The Replublic", "Plato"));
|
||||
books.put("Thus Spake Zarathustra", new Book("Thus Spake Zarathustra",
|
||||
"Friedrich Nietzsche"));
|
||||
return books;
|
||||
}
|
||||
}
|
||||
|
||||
class Book {
|
||||
private String title;
|
||||
private String author;
|
||||
private String title;
|
||||
private String author;
|
||||
|
||||
public Book(String title, String author) {
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
}
|
||||
public Book(String title, String author) {
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
}
|
||||
@@ -20,52 +20,58 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.interceptor.annotations.After;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.interceptor.annotations.After;
|
||||
|
||||
/**
|
||||
* Will only work on containers that unzip war files
|
||||
*
|
||||
*/
|
||||
public class JSPEvalAction extends ExampleAction {
|
||||
private String jsp;
|
||||
private final static String FILE = "/interactive/demo.jsp";
|
||||
private String jsp;
|
||||
private final static String FILE = "/interactive/demo.jsp";
|
||||
|
||||
public String execute() throws IOException {
|
||||
if (jsp != null) {
|
||||
//write it to file
|
||||
URL url = ServletActionContext.getServletContext().getResource(FILE);
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(url
|
||||
.getFile())));
|
||||
try {
|
||||
//directive
|
||||
writer.write("<%@ taglib prefix=\"s\" uri=\"/struts-tags\" %>");
|
||||
writer.write(jsp);
|
||||
} finally {
|
||||
if (writer != null)
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
public String execute() throws IOException {
|
||||
if (jsp != null) {
|
||||
//write it to file
|
||||
URL url = ServletActionContext.getServletContext().getResource(FILE);
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(url
|
||||
.getFile())));
|
||||
try {
|
||||
//directive
|
||||
writer.write("<%@ taglib prefix=\"s\" uri=\"/struts-tags\" %>");
|
||||
writer.write(jsp);
|
||||
} finally {
|
||||
if (writer != null)
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanUp() throws IOException {
|
||||
URL url = ServletActionContext.getServletContext().getResource(FILE);
|
||||
FileOutputStream out = new FileOutputStream(new File(url.getFile()));
|
||||
try {
|
||||
out.getChannel().truncate(0);
|
||||
} finally {
|
||||
if (out != null)
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
@After
|
||||
public void cleanUp() throws IOException {
|
||||
URL url = ServletActionContext.getServletContext().getResource(FILE);
|
||||
FileOutputStream out = new FileOutputStream(new File(url.getFile()));
|
||||
try {
|
||||
out.getChannel().truncate(0);
|
||||
} finally {
|
||||
if (out != null)
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void setJsp(String jsp) {
|
||||
this.jsp = jsp;
|
||||
}
|
||||
public void setJsp(String jsp) {
|
||||
this.jsp = jsp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,64 +20,70 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.struts2.showcase.dao.Dao;
|
||||
import org.apache.struts2.showcase.dao.SkillDao;
|
||||
import org.apache.struts2.showcase.model.Skill;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
|
||||
/**
|
||||
* SkillAction.
|
||||
*
|
||||
*/
|
||||
|
||||
public class SkillAction extends AbstractCRUDAction implements Preparable {
|
||||
|
||||
private static final Logger log = Logger.getLogger(SkillAction.class);
|
||||
private static final Logger log = Logger.getLogger(SkillAction.class);
|
||||
|
||||
@Autowired
|
||||
private SkillDao skillDao;
|
||||
private String skillName;
|
||||
protected SkillDao skillDao;
|
||||
private Skill currentSkill;
|
||||
|
||||
private String skillName;
|
||||
private Skill currentSkill;
|
||||
public String getSkillName() {
|
||||
return skillName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to allow the action to prepare itself.
|
||||
*
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
*/
|
||||
public void prepare() throws Exception {
|
||||
Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill());
|
||||
if (preFetched != null) {
|
||||
setCurrentSkill(preFetched);
|
||||
}
|
||||
}
|
||||
public void setSkillName(String skillName) {
|
||||
this.skillName = skillName;
|
||||
}
|
||||
|
||||
public String save() throws Exception {
|
||||
if (getCurrentSkill() != null) {
|
||||
setSkillName((String) skillDao.merge(getCurrentSkill()));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
protected Dao getDao() {
|
||||
return skillDao;
|
||||
}
|
||||
|
||||
public String getSkillName() {
|
||||
return skillName;
|
||||
}
|
||||
public void setSkillDao(SkillDao skillDao) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("SkillAction - [setSkillDao]: skillDao injected.");
|
||||
}
|
||||
this.skillDao = skillDao;
|
||||
}
|
||||
|
||||
public void setSkillName(String skillName) {
|
||||
this.skillName = skillName;
|
||||
}
|
||||
public Skill getCurrentSkill() {
|
||||
return currentSkill;
|
||||
}
|
||||
|
||||
protected Dao getDao() {
|
||||
return skillDao;
|
||||
}
|
||||
public void setCurrentSkill(Skill currentSkill) {
|
||||
this.currentSkill = currentSkill;
|
||||
}
|
||||
|
||||
public Skill getCurrentSkill() {
|
||||
return currentSkill;
|
||||
}
|
||||
/**
|
||||
* This method is called to allow the action to prepare itself.
|
||||
*
|
||||
* @throws Exception thrown if a system level exception occurs.
|
||||
*/
|
||||
public void prepare() throws Exception {
|
||||
Skill preFetched = (Skill) fetch(getSkillName(), getCurrentSkill());
|
||||
if (preFetched != null) {
|
||||
setCurrentSkill(preFetched);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentSkill(Skill currentSkill) {
|
||||
this.currentSkill = currentSkill;
|
||||
}
|
||||
public String save() throws Exception {
|
||||
if (getCurrentSkill() != null) {
|
||||
setSkillName((String) skillDao.merge(getCurrentSkill()));
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
-11
@@ -22,21 +22,24 @@ package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ActionChain1 extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = -6811701750042275153L;
|
||||
private static final long serialVersionUID = -6811701750042275153L;
|
||||
|
||||
private String actionChain1Property1 = "Property Set In Action Chain 1";
|
||||
private String actionChain1Property1 = "Property Set In Action Chain 1";
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public String getActionChain1Property1() {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
|
||||
public String getActionChain1Property1() {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+27
-21
@@ -22,31 +22,37 @@ package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ActionChain2 extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 3951745956044674809L;
|
||||
private static final long serialVersionUID = 3951745956044674809L;
|
||||
|
||||
private String actionChain1Property1;
|
||||
private String actionChain2Property1 = "Property Set in Action Chain 2";
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getActionChain1Property1() {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
private String actionChain1Property1;
|
||||
private String actionChain2Property1 = "Property Set in Action Chain 2";
|
||||
|
||||
|
||||
public String getActionChain2Property1() {
|
||||
return actionChain2Property1;
|
||||
}
|
||||
public String getActionChain1Property1() {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
|
||||
public void setActionChain2Property1(String actionChain2Property1) {
|
||||
this.actionChain2Property1 = actionChain2Property1;
|
||||
}
|
||||
|
||||
|
||||
public String getActionChain2Property1() {
|
||||
return actionChain2Property1;
|
||||
}
|
||||
public void setActionChain2Property1(String actionChain2Property1) {
|
||||
this.actionChain2Property1 = actionChain2Property1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+32
-27
@@ -22,42 +22,47 @@ package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ActionChain3 extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = -1456568865075250621L;
|
||||
private static final long serialVersionUID = -1456568865075250621L;
|
||||
|
||||
private String actionChain1Property1;
|
||||
private String actionChain2Property1;
|
||||
private String actionChain3Property1 = "Property set in Action Chain 3";
|
||||
private String actionChain1Property1;
|
||||
private String actionChain2Property1;
|
||||
private String actionChain3Property1 = "Property set in Action Chain 3";
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getActionChain1Property1() {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
public String getActionChain1Property1() {
|
||||
return actionChain1Property1;
|
||||
}
|
||||
public void setActionChain1Property1(String actionChain1Property1) {
|
||||
this.actionChain1Property1 = actionChain1Property1;
|
||||
}
|
||||
|
||||
|
||||
public String getActionChain2Property1() {
|
||||
return actionChain2Property1;
|
||||
}
|
||||
|
||||
public void setActionChain2Property1(String actionChain2Property1) {
|
||||
this.actionChain2Property1 = actionChain2Property1;
|
||||
}
|
||||
public String getActionChain2Property1() {
|
||||
return actionChain2Property1;
|
||||
}
|
||||
public void setActionChain2Property1(String actionChain2Property1) {
|
||||
this.actionChain2Property1 = actionChain2Property1;
|
||||
}
|
||||
|
||||
|
||||
public String getActionChain3Property1() {
|
||||
return actionChain3Property1;
|
||||
}
|
||||
|
||||
public void setActionChain3Property1(String actionChain3Property1) {
|
||||
this.actionChain3Property1 = actionChain3Property1;
|
||||
}
|
||||
public String getActionChain3Property1() {
|
||||
return actionChain3Property1;
|
||||
}
|
||||
public void setActionChain3Property1(String actionChain3Property1) {
|
||||
this.actionChain3Property1 = actionChain3Property1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,28 +25,30 @@ import com.opensymphony.xwork2.Action;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AjaxTestAction implements Action, Serializable {
|
||||
|
||||
private static int counter = 0;
|
||||
private String data;
|
||||
private static int counter = 0;
|
||||
private String data;
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public long getServerTime() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public long getServerTime() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
public int getCount() {
|
||||
return ++counter;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return ++counter;
|
||||
}
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+27
-27
@@ -20,40 +20,40 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class AutocompleterExampleAction extends ActionSupport {
|
||||
private String select;
|
||||
private List<String> options = new ArrayList<String>();
|
||||
private String select;
|
||||
private List<String> options = new ArrayList<String>();
|
||||
|
||||
private static final long serialVersionUID = -8481638176160014396L;
|
||||
private static final long serialVersionUID = -8481638176160014396L;
|
||||
|
||||
public String execute() throws Exception {
|
||||
if ("fruits".equals(select)) {
|
||||
options.add("apple");
|
||||
options.add("banana");
|
||||
options.add("grape");
|
||||
options.add("pear");
|
||||
} else if ("colors".equals(select)) {
|
||||
options.add("red");
|
||||
options.add("green");
|
||||
options.add("blue");
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
if ("fruits".equals(select)) {
|
||||
options.add("apple");
|
||||
options.add("banana");
|
||||
options.add("grape");
|
||||
options.add("pear");
|
||||
} else if ("colors".equals(select)) {
|
||||
options.add("red");
|
||||
options.add("green");
|
||||
options.add("blue");
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getSelect() {
|
||||
return select;
|
||||
}
|
||||
public String getSelect() {
|
||||
return select;
|
||||
}
|
||||
|
||||
public void setSelect(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
public void setSelect(String select) {
|
||||
this.select = select;
|
||||
}
|
||||
|
||||
public List<String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
public List<String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
+34
-34
@@ -20,56 +20,56 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* @version $Date$ $Id$
|
||||
*/
|
||||
public class Example4ShowPanelAction extends ActionSupport {
|
||||
|
||||
private String name;
|
||||
private String gender;
|
||||
private String name;
|
||||
private String gender;
|
||||
|
||||
private static final long serialVersionUID = 7751976335066456596L;
|
||||
private static final long serialVersionUID = 7751976335066456596L;
|
||||
|
||||
public String panel1() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public String panel1() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String panel2() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public String panel2() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String panel3() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public String panel3() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTodayDate() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
public String getTodayDate() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
|
||||
public String getTodayTime() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
public String getTodayTime() {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss");
|
||||
return sdf.format(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,28 +24,20 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class Example5Action extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 2111967621952300611L;
|
||||
private static final long serialVersionUID = 2111967621952300611L;
|
||||
|
||||
private String name;
|
||||
private Integer age;
|
||||
private String name;
|
||||
private Integer age;
|
||||
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public Integer getAge() { return age; }
|
||||
public void setAge(Integer age) { this.age = age; }
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
@Override
|
||||
public String execute() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,77 +28,77 @@ import java.util.Map;
|
||||
/**
|
||||
*/
|
||||
public class Category {
|
||||
private static Map<Long, Category> catMap = new HashMap<Long, Category>();
|
||||
private static Map<Long, Category> catMap = new HashMap<Long, Category>();
|
||||
|
||||
static {
|
||||
new Category(1, "Root",
|
||||
new Category(2, "Java",
|
||||
new Category(3, "Web Frameworks",
|
||||
new Category(4, "Struts"),
|
||||
new Category(7, "Stripes"),
|
||||
new Category(8, "Rife")),
|
||||
new Category(9, "Persistence",
|
||||
new Category(10, "iBatis"),
|
||||
new Category(11, "Hibernate"),
|
||||
new Category(12, "JDO"),
|
||||
new Category(13, "JDBC"))),
|
||||
new Category(14, "JavaScript",
|
||||
new Category(15, "Dojo"),
|
||||
new Category(16, "Prototype"),
|
||||
new Category(17, "Scriptaculous"),
|
||||
new Category(18, "OpenRico"),
|
||||
new Category(19, "DWR")));
|
||||
}
|
||||
static {
|
||||
new Category(1, "Root",
|
||||
new Category(2, "Java",
|
||||
new Category(3, "Web Frameworks",
|
||||
new Category(4, "Struts"),
|
||||
new Category(7, "Stripes"),
|
||||
new Category(8, "Rife")),
|
||||
new Category(9, "Persistence",
|
||||
new Category(10, "iBatis"),
|
||||
new Category(11, "Hibernate"),
|
||||
new Category(12, "JDO"),
|
||||
new Category(13, "JDBC"))),
|
||||
new Category(14, "JavaScript",
|
||||
new Category(15, "Dojo"),
|
||||
new Category(16, "Prototype"),
|
||||
new Category(17, "Scriptaculous"),
|
||||
new Category(18, "OpenRico"),
|
||||
new Category(19, "DWR")));
|
||||
}
|
||||
|
||||
public static Category getById(long id) {
|
||||
return catMap.get(id);
|
||||
}
|
||||
public static Category getById(long id) {
|
||||
return catMap.get(id);
|
||||
}
|
||||
|
||||
private long id;
|
||||
private String name;
|
||||
private List<Category> children;
|
||||
private boolean toggle;
|
||||
private long id;
|
||||
private String name;
|
||||
private List<Category> children;
|
||||
private boolean toggle;
|
||||
|
||||
public Category(long id, String name, Category... children) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.children = new ArrayList<Category>();
|
||||
for (Category child : children) {
|
||||
this.children.add(child);
|
||||
}
|
||||
public Category(long id, String name, Category... children) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.children = new ArrayList<Category>();
|
||||
for (Category child : children) {
|
||||
this.children.add(child);
|
||||
}
|
||||
|
||||
catMap.put(id, this);
|
||||
}
|
||||
catMap.put(id, this);
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Category> getChildren() {
|
||||
return children;
|
||||
}
|
||||
public List<Category> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Category> children) {
|
||||
this.children = children;
|
||||
}
|
||||
public void setChildren(List<Category> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public void toggle() {
|
||||
toggle = !toggle;
|
||||
}
|
||||
public void toggle() {
|
||||
toggle = !toggle;
|
||||
}
|
||||
|
||||
public boolean isToggle() {
|
||||
return toggle;
|
||||
}
|
||||
public boolean isToggle() {
|
||||
return toggle;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -25,25 +25,25 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
/**
|
||||
*/
|
||||
public class GetCategory extends ActionSupport {
|
||||
private long catId;
|
||||
private Category category;
|
||||
private long catId;
|
||||
private Category category;
|
||||
|
||||
public String execute() throws Exception {
|
||||
if (catId < 1) {
|
||||
// force the root
|
||||
catId = 1;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
if (catId < 1) {
|
||||
// force the root
|
||||
catId = 1;
|
||||
}
|
||||
|
||||
category = Category.getById(catId);
|
||||
category = Category.getById(catId);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public void setCatId(long catId) {
|
||||
this.catId = catId;
|
||||
}
|
||||
public void setCatId(long catId) {
|
||||
this.catId = catId;
|
||||
}
|
||||
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ package org.apache.struts2.showcase.ajax.tree;
|
||||
/**
|
||||
*/
|
||||
public class Toggle extends GetCategory {
|
||||
public String execute() throws Exception {
|
||||
super.execute();
|
||||
public String execute() throws Exception {
|
||||
super.execute();
|
||||
|
||||
getCategory().toggle();
|
||||
getCategory().toggle();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+93
-96
@@ -20,126 +20,123 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.application;
|
||||
|
||||
import org.apache.struts2.showcase.exception.CreateException;
|
||||
import org.apache.struts2.showcase.exception.DuplicateKeyException;
|
||||
import org.apache.struts2.showcase.exception.StorageException;
|
||||
import org.apache.struts2.showcase.exception.UpdateException;
|
||||
import org.apache.struts2.showcase.model.IdEntity;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.showcase.exception.CreateException;
|
||||
import org.apache.struts2.showcase.exception.DuplicateKeyException;
|
||||
import org.apache.struts2.showcase.exception.StorageException;
|
||||
import org.apache.struts2.showcase.exception.UpdateException;
|
||||
import org.apache.struts2.showcase.model.IdEntity;
|
||||
|
||||
/**
|
||||
* MemoryStorage.
|
||||
* Very simple in-memory persistence emulation.
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository
|
||||
@Scope("singleton")
|
||||
public class MemoryStorage implements Storage {
|
||||
|
||||
private static final long serialVersionUID = 8611213748834904125L;
|
||||
private static final long serialVersionUID = 8611213748834904125L;
|
||||
|
||||
|
||||
private Map memory = new HashMap();
|
||||
private Map memory = new HashMap();
|
||||
|
||||
private Map getEntityMap(Class entityClass) {
|
||||
if (entityClass != null) {
|
||||
Map tryMap = (Map) memory.get(entityClass);
|
||||
if (tryMap == null) {
|
||||
synchronized (memory) {
|
||||
tryMap = new HashMap();
|
||||
memory.put(entityClass, tryMap);
|
||||
}
|
||||
}
|
||||
return tryMap;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private Map getEntityMap ( Class entityClass ) {
|
||||
if (entityClass != null) {
|
||||
Map tryMap = (Map) memory.get(entityClass);
|
||||
if (tryMap == null) {
|
||||
synchronized(memory) {
|
||||
tryMap = new HashMap();
|
||||
memory.put(entityClass, tryMap);
|
||||
}
|
||||
}
|
||||
return tryMap;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IdEntity intStore(Class entityClass, IdEntity object) {
|
||||
getEntityMap(entityClass).put(object.getId(), object);
|
||||
return object;
|
||||
}
|
||||
private IdEntity intStore( Class entityClass, IdEntity object ) {
|
||||
getEntityMap(entityClass).put(object.getId(), object);
|
||||
return object;
|
||||
}
|
||||
|
||||
public IdEntity get(Class entityClass, Serializable id) {
|
||||
if (entityClass != null && id != null) {
|
||||
return (IdEntity) getEntityMap(entityClass).get(id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public IdEntity get( Class entityClass, Serializable id ) {
|
||||
if (entityClass != null && id != null) {
|
||||
return (IdEntity) getEntityMap(entityClass).get(id);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Serializable create(IdEntity object) throws CreateException {
|
||||
if (object == null) {
|
||||
throw new CreateException("Either given class or object was null");
|
||||
}
|
||||
if (object.getId() == null) {
|
||||
throw new CreateException("Cannot store object with null id");
|
||||
}
|
||||
if (get(object.getClass(), object.getId()) != null) {
|
||||
throw new DuplicateKeyException("Object with this id already exists.");
|
||||
}
|
||||
return intStore(object.getClass(), object).getId();
|
||||
}
|
||||
public Serializable create ( IdEntity object ) throws CreateException {
|
||||
if (object == null) {
|
||||
throw new CreateException("Either given class or object was null");
|
||||
}
|
||||
if (object.getId() == null) {
|
||||
throw new CreateException("Cannot store object with null id");
|
||||
}
|
||||
if (get(object.getClass(), object.getId()) != null) {
|
||||
throw new DuplicateKeyException("Object with this id already exists.");
|
||||
}
|
||||
return intStore(object.getClass(), object).getId();
|
||||
}
|
||||
|
||||
public IdEntity update(IdEntity object) throws UpdateException {
|
||||
if (object == null) {
|
||||
throw new UpdateException("Cannot update null object.");
|
||||
}
|
||||
if (get(object.getClass(), object.getId()) == null) {
|
||||
throw new UpdateException("Object to update not found.");
|
||||
}
|
||||
return intStore(object.getClass(), object);
|
||||
}
|
||||
public IdEntity update ( IdEntity object ) throws UpdateException {
|
||||
if (object == null) {
|
||||
throw new UpdateException("Cannot update null object.");
|
||||
}
|
||||
if ( get(object.getClass(), object.getId())==null ) {
|
||||
throw new UpdateException("Object to update not found.");
|
||||
}
|
||||
return intStore(object.getClass(), object);
|
||||
}
|
||||
|
||||
public Serializable merge(IdEntity object) throws StorageException {
|
||||
if (object == null) {
|
||||
throw new StorageException("Cannot merge null object");
|
||||
}
|
||||
if (object.getId() == null || get(object.getClass(), object.getId()) == null) {
|
||||
return create(object);
|
||||
} else {
|
||||
return update(object).getId();
|
||||
}
|
||||
}
|
||||
public Serializable merge ( IdEntity object ) throws StorageException {
|
||||
if (object == null) {
|
||||
throw new StorageException("Cannot merge null object");
|
||||
}
|
||||
if (object.getId() == null || get(object.getClass(), object.getId())==null) {
|
||||
return create(object);
|
||||
} else {
|
||||
return update(object).getId();
|
||||
}
|
||||
}
|
||||
|
||||
public int delete(Class entityClass, Serializable id) throws CreateException {
|
||||
try {
|
||||
if (get(entityClass, id) != null) {
|
||||
getEntityMap(entityClass).remove(id);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CreateException(e);
|
||||
}
|
||||
}
|
||||
public int delete( Class entityClass, Serializable id ) throws CreateException {
|
||||
try {
|
||||
if (get(entityClass, id) != null) {
|
||||
getEntityMap(entityClass).remove(id);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CreateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public int delete(IdEntity object) throws CreateException {
|
||||
if (object == null) {
|
||||
throw new CreateException("Cannot delete null object");
|
||||
}
|
||||
return delete(object.getClass(), object.getId());
|
||||
}
|
||||
public int delete( IdEntity object ) throws CreateException {
|
||||
if (object == null) {
|
||||
throw new CreateException("Cannot delete null object");
|
||||
}
|
||||
return delete(object.getClass(), object.getId());
|
||||
}
|
||||
|
||||
public Collection findAll(Class entityClass) {
|
||||
if (entityClass != null) {
|
||||
return getEntityMap(entityClass).values();
|
||||
} else {
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
public Collection findAll( Class entityClass ) {
|
||||
if (entityClass != null) {
|
||||
return getEntityMap(entityClass).values();
|
||||
} else {
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.memory = new HashMap();
|
||||
}
|
||||
public void reset() {
|
||||
this.memory = new HashMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,30 +20,31 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.application;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.struts2.showcase.exception.CreateException;
|
||||
import org.apache.struts2.showcase.exception.StorageException;
|
||||
import org.apache.struts2.showcase.exception.UpdateException;
|
||||
import org.apache.struts2.showcase.model.IdEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Storage. Interface.
|
||||
*
|
||||
*/
|
||||
|
||||
public interface Storage extends Serializable {
|
||||
IdEntity get(Class entityClass, Serializable id);
|
||||
IdEntity get( Class entityClass, Serializable id );
|
||||
|
||||
Serializable create(IdEntity object) throws CreateException;
|
||||
Serializable create ( IdEntity object ) throws CreateException;
|
||||
|
||||
IdEntity update(IdEntity object) throws UpdateException;
|
||||
IdEntity update ( IdEntity object ) throws UpdateException;
|
||||
|
||||
Serializable merge(IdEntity object) throws StorageException;
|
||||
Serializable merge ( IdEntity object ) throws StorageException;
|
||||
|
||||
int delete(Class entityClass, Serializable id) throws CreateException;
|
||||
int delete( Class entityClass, Serializable id ) throws CreateException;
|
||||
|
||||
int delete(IdEntity object) throws CreateException;
|
||||
int delete( IdEntity object ) throws CreateException;
|
||||
|
||||
Collection findAll(Class entityClass);
|
||||
Collection findAll( Class entityClass );
|
||||
}
|
||||
|
||||
+71
-66
@@ -20,6 +20,10 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.application;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.struts2.showcase.dao.EmployeeDao;
|
||||
import org.apache.struts2.showcase.dao.SkillDao;
|
||||
@@ -27,87 +31,88 @@ import org.apache.struts2.showcase.exception.StorageException;
|
||||
import org.apache.struts2.showcase.model.Employee;
|
||||
import org.apache.struts2.showcase.model.Skill;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* TestDataProvider.
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
|
||||
public class TestDataProvider implements Serializable, InitializingBean {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger log = Logger.getLogger(TestDataProvider.class);
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String[] POSITIONS = {
|
||||
"Developer",
|
||||
"System Architect",
|
||||
"Sales Manager",
|
||||
"CEO"
|
||||
};
|
||||
private static final Logger log = Logger.getLogger(TestDataProvider.class);
|
||||
|
||||
public static final String[] LEVELS = {
|
||||
"Junior",
|
||||
"Senior",
|
||||
"Master"
|
||||
};
|
||||
public static final String[] POSITIONS = {
|
||||
"Developer",
|
||||
"System Architect",
|
||||
"Sales Manager",
|
||||
"CEO"
|
||||
};
|
||||
|
||||
private static final Skill[] TEST_SKILLS = {
|
||||
new Skill("WW-SEN", "Struts Senior Developer"),
|
||||
new Skill("WW-JUN", "Struts Junior Developer"),
|
||||
new Skill("SPRING-DEV", "Spring Developer")
|
||||
};
|
||||
public static final String[] LEVELS = {
|
||||
"Junior",
|
||||
"Senior",
|
||||
"Master"
|
||||
};
|
||||
|
||||
public static final Employee[] TEST_EMPLOYEES = {
|
||||
new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0],
|
||||
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
|
||||
new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1],
|
||||
TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
|
||||
};
|
||||
private static final Skill[] TEST_SKILLS = {
|
||||
new Skill("WW-SEN", "Struts Senior Developer"),
|
||||
new Skill("WW-JUN", "Struts Junior Developer"),
|
||||
new Skill("SPRING-DEV", "Spring Developer")
|
||||
};
|
||||
|
||||
@Autowired
|
||||
private SkillDao skillDao;
|
||||
public static final Employee[] TEST_EMPLOYEES = {
|
||||
new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0],
|
||||
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
|
||||
new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1],
|
||||
TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1,TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
|
||||
};
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
private SkillDao skillDao;
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
protected void addTestSkills() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_SKILLS.length; i < j; i++) {
|
||||
skillDao.merge(TEST_SKILLS[i]);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
public void setSkillDao(SkillDao skillDao) {
|
||||
this.skillDao = skillDao;
|
||||
}
|
||||
|
||||
protected void addTestEmployees() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) {
|
||||
employeeDao.merge(TEST_EMPLOYEES[i]);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
public void setEmployeeDao(EmployeeDao employeeDao) {
|
||||
this.employeeDao = employeeDao;
|
||||
}
|
||||
|
||||
protected void addTestData() {
|
||||
addTestSkills();
|
||||
addTestEmployees();
|
||||
}
|
||||
protected void addTestSkills() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_SKILLS.length; i < j; i++) {
|
||||
skillDao.merge(TEST_SKILLS[i]);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
addTestData();
|
||||
}
|
||||
protected void addTestEmployees() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) {
|
||||
employeeDao.merge(TEST_EMPLOYEES[i]);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTestData() {
|
||||
addTestSkills();
|
||||
addTestEmployees();
|
||||
}
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
addTestData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
-17
@@ -21,37 +21,40 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
|
||||
import org.apache.struts2.dispatcher.SessionMap;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import org.apache.struts2.dispatcher.SessionMap;
|
||||
|
||||
public class ChatAuthenticationInterceptor implements Interceptor {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatAuthenticationInterceptor.class);
|
||||
public static final String USER_SESSION_KEY = "chatUserSessionKey";
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatAuthenticationInterceptor.class);
|
||||
|
||||
public void init() {
|
||||
}
|
||||
public static final String USER_SESSION_KEY = "chatUserSessionKey";
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
LOG.debug("Authenticating chat user");
|
||||
public void init() {
|
||||
}
|
||||
|
||||
SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User user = (User) session.get(USER_SESSION_KEY);
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
|
||||
if (user == null) {
|
||||
return Action.LOGIN;
|
||||
}
|
||||
return invocation.invoke();
|
||||
}
|
||||
LOG.debug("Authenticating chat user");
|
||||
|
||||
SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User user = (User) session.get(USER_SESSION_KEY);
|
||||
|
||||
if (user == null) {
|
||||
return Action.LOGIN;
|
||||
}
|
||||
return invocation.invoke();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ package org.apache.struts2.showcase.chat;
|
||||
|
||||
public class ChatException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum ErrorType {
|
||||
ROOM_ALREADY_EXISTS,
|
||||
USER_ALREADY_EXISTS,
|
||||
NO_SUCH_ROOM_EXISTS
|
||||
}
|
||||
public enum ErrorType {
|
||||
ROOM_ALREADY_EXISTS,
|
||||
USER_ALREADY_EXISTS,
|
||||
NO_SUCH_ROOM_EXISTS
|
||||
}
|
||||
|
||||
public ChatException(String description, ErrorType type) {
|
||||
super(description);
|
||||
}
|
||||
public ChatException(String description, ErrorType type) {
|
||||
super(description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
@@ -27,34 +29,32 @@ import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* Authenticate showcase chat example, make sure everyone have a username.
|
||||
*/
|
||||
public class ChatInterceptor implements Interceptor {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatInterceptor.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatInterceptor.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
|
||||
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
|
||||
if (chatUser == null) {
|
||||
LOG.debug("Chat user not logged in");
|
||||
return Action.LOGIN;
|
||||
}
|
||||
return invocation.invoke();
|
||||
}
|
||||
public String intercept(ActionInvocation invocation) throws Exception {
|
||||
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
|
||||
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
|
||||
if (chatUser == null) {
|
||||
LOG.debug("Chat user not logged in");
|
||||
return Action.LOGIN;
|
||||
}
|
||||
return invocation.invoke();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,48 +20,49 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
|
||||
import java.util.Map;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class ChatLoginAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private Map session;
|
||||
private ChatService chatService;
|
||||
private Map session;
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
public ChatLoginAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public ChatLoginAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
chatService.login(new User(name));
|
||||
session.put(ChatAuthenticationInterceptor.USER_SESSION_KEY, new User(name));
|
||||
} catch (ChatException e) {
|
||||
e.printStackTrace();
|
||||
addActionError(e.getMessage());
|
||||
return INPUT;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
chatService.login(new User(name));
|
||||
session.put(ChatAuthenticationInterceptor.USER_SESSION_KEY, new User(name));
|
||||
}
|
||||
catch(ChatException e) {
|
||||
e.printStackTrace();
|
||||
addActionError(e.getMessage());
|
||||
return INPUT;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-20
@@ -20,38 +20,39 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
|
||||
import java.util.Map;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class ChatLogoutAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private ChatService chatService;
|
||||
|
||||
private Map session;
|
||||
private Map session;
|
||||
|
||||
|
||||
public ChatLogoutAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public ChatLogoutAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
public String execute() throws Exception {
|
||||
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
if (user != null) {
|
||||
chatService.logout(user.getName());
|
||||
session.remove(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
}
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
if (user != null) {
|
||||
chatService.logout(user.getName());
|
||||
session.remove(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,28 +24,26 @@ import java.util.Date;
|
||||
|
||||
public class ChatMessage {
|
||||
|
||||
private Date creationDate;
|
||||
private String message;
|
||||
private User creator;
|
||||
private Date creationDate;
|
||||
private String message;
|
||||
private User creator;
|
||||
|
||||
public ChatMessage(String message, User creator) {
|
||||
assert (message != null);
|
||||
assert (creator != null);
|
||||
public ChatMessage(String message, User creator) {
|
||||
assert(message != null);
|
||||
assert(creator != null);
|
||||
|
||||
this.creationDate = new Date(System.currentTimeMillis());
|
||||
this.message = message;
|
||||
this.creator = creator;
|
||||
}
|
||||
this.creationDate = new Date(System.currentTimeMillis());
|
||||
this.message = message;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public User getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
public User getCreator() {
|
||||
return creator;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,23 +23,15 @@ package org.apache.struts2.showcase.chat;
|
||||
import java.util.List;
|
||||
|
||||
public interface ChatService {
|
||||
List<User> getAvailableUsers();
|
||||
List<User> getAvailableUsers();
|
||||
void login(User user);
|
||||
void logout(String name);
|
||||
|
||||
void login(User user);
|
||||
|
||||
void logout(String name);
|
||||
|
||||
List<Room> getAvailableRooms();
|
||||
|
||||
void addRoom(Room room);
|
||||
|
||||
void enterRoom(User user, String roomName);
|
||||
|
||||
void exitRoom(String userName, String roomName);
|
||||
|
||||
List<ChatMessage> getMessagesInRoom(String roomName);
|
||||
|
||||
void sendMessageToRoom(String roomName, User user, String message);
|
||||
|
||||
List<User> getUsersAvailableInRoom(String roomName);
|
||||
List<Room> getAvailableRooms();
|
||||
void addRoom(Room room);
|
||||
void enterRoom(User user, String roomName);
|
||||
void exitRoom(String userName, String roomName);
|
||||
List<ChatMessage> getMessagesInRoom(String roomName);
|
||||
void sendMessageToRoom(String roomName, User user, String message);
|
||||
List<User> getUsersAvailableInRoom(String roomName);
|
||||
}
|
||||
|
||||
@@ -27,89 +27,89 @@ import java.util.Map;
|
||||
|
||||
public class ChatServiceImpl implements ChatService {
|
||||
|
||||
private Map<String, User> availableUsers = new LinkedHashMap<String, User>();
|
||||
private Map<String, Room> availableRooms = new LinkedHashMap<String, Room>();
|
||||
private Map<String, User> availableUsers = new LinkedHashMap<String, User>();
|
||||
private Map<String, Room> availableRooms = new LinkedHashMap<String, Room>();
|
||||
|
||||
|
||||
public List<User> getAvailableUsers() {
|
||||
return new ArrayList<User>(availableUsers.values());
|
||||
}
|
||||
public List<User> getAvailableUsers() {
|
||||
return new ArrayList<User>(availableUsers.values());
|
||||
}
|
||||
|
||||
public List<Room> getAvailableRooms() {
|
||||
return new ArrayList<Room>(availableRooms.values());
|
||||
}
|
||||
public List<Room> getAvailableRooms() {
|
||||
return new ArrayList<Room>(availableRooms.values());
|
||||
}
|
||||
|
||||
public void addRoom(Room room) {
|
||||
if (availableRooms.containsKey(room.getName())) {
|
||||
throw new ChatException("room [" + room.getName() + "] is already available", ChatException.ErrorType.valueOf("ROOM_ALREADY_EXISTS"));
|
||||
}
|
||||
availableRooms.put(room.getName(), room);
|
||||
}
|
||||
public void addRoom(Room room) {
|
||||
if (availableRooms.containsKey(room.getName())) {
|
||||
throw new ChatException("room ["+room.getName()+"] is already available", ChatException.ErrorType.valueOf("ROOM_ALREADY_EXISTS"));
|
||||
}
|
||||
availableRooms.put(room.getName(), room);
|
||||
}
|
||||
|
||||
public void login(User user) {
|
||||
assert (user != null);
|
||||
if (availableUsers.containsKey(user.getName())) {
|
||||
throw new ChatException("User [" + user.getName() + "] already exists", ChatException.ErrorType.valueOf("USER_ALREADY_EXISTS"));
|
||||
}
|
||||
availableUsers.put(user.getName(), user);
|
||||
}
|
||||
public void login(User user) {
|
||||
assert(user != null);
|
||||
if (availableUsers.containsKey(user.getName())) {
|
||||
throw new ChatException("User ["+user.getName()+"] already exists", ChatException.ErrorType.valueOf("USER_ALREADY_EXISTS"));
|
||||
}
|
||||
availableUsers.put(user.getName(), user);
|
||||
}
|
||||
|
||||
public void logout(String name) {
|
||||
assert (name != null);
|
||||
assert (name.trim().length() > 0);
|
||||
availableUsers.remove(name);
|
||||
for (Room room : availableRooms.values()) {
|
||||
if (room.hasMember(name)) {
|
||||
room.memberExit(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void logout(String name) {
|
||||
assert(name != null);
|
||||
assert(name.trim().length() > 0);
|
||||
availableUsers.remove(name);
|
||||
for (Room room : availableRooms.values()) {
|
||||
if (room.hasMember(name)) {
|
||||
room.memberExit(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exitRoom(String userName, String roomName) {
|
||||
assert (roomName != null);
|
||||
assert (roomName.trim().length() > 0);
|
||||
public void exitRoom(String userName, String roomName) {
|
||||
assert(roomName != null);
|
||||
assert(roomName.trim().length()> 0);
|
||||
|
||||
if (availableRooms.containsKey(roomName)) {
|
||||
Room room = availableRooms.get(roomName);
|
||||
room.memberExit(userName);
|
||||
}
|
||||
}
|
||||
if (availableRooms.containsKey(roomName)) {
|
||||
Room room = availableRooms.get(roomName);
|
||||
room.memberExit(userName);
|
||||
}
|
||||
}
|
||||
|
||||
public void enterRoom(User user, String roomName) {
|
||||
assert (roomName != null);
|
||||
assert (roomName.trim().length() > 0);
|
||||
if (!availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
room.memberEnter(user);
|
||||
}
|
||||
public void enterRoom(User user, String roomName) {
|
||||
assert(roomName != null);
|
||||
assert(roomName.trim().length() > 0);
|
||||
if (! availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
room.memberEnter(user);
|
||||
}
|
||||
|
||||
public List<ChatMessage> getMessagesInRoom(String roomName) {
|
||||
assert (roomName != null);
|
||||
assert (roomName.trim().length() > 0);
|
||||
if (!availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
return room.getChatMessages();
|
||||
}
|
||||
public List<ChatMessage> getMessagesInRoom(String roomName) {
|
||||
assert(roomName != null);
|
||||
assert(roomName.trim().length() > 0);
|
||||
if (! availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
return room.getChatMessages();
|
||||
}
|
||||
|
||||
public void sendMessageToRoom(String roomName, User user, String message) {
|
||||
assert (roomName != null);
|
||||
if (!availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
room.addMessage(new ChatMessage(message, user));
|
||||
}
|
||||
public void sendMessageToRoom(String roomName, User user, String message) {
|
||||
assert(roomName != null);
|
||||
if (! availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
room.addMessage(new ChatMessage(message, user));
|
||||
}
|
||||
|
||||
public List<User> getUsersAvailableInRoom(String roomName) {
|
||||
assert (roomName != null);
|
||||
if (!availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists [" + roomName + "]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
return room.getMembers();
|
||||
}
|
||||
public List<User> getUsersAvailableInRoom(String roomName) {
|
||||
assert(roomName != null);
|
||||
if (! availableRooms.containsKey(roomName)) {
|
||||
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
|
||||
}
|
||||
Room room = availableRooms.get(roomName);
|
||||
return room.getMembers();
|
||||
}
|
||||
}
|
||||
|
||||
+21
-20
@@ -20,34 +20,35 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
public class ChatSessionListener implements HttpSessionListener {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatSessionListener.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ChatSessionListener.class);
|
||||
|
||||
public void sessionCreated(HttpSessionEvent event) {
|
||||
}
|
||||
public void sessionCreated(HttpSessionEvent event) {
|
||||
}
|
||||
|
||||
public void sessionDestroyed(HttpSessionEvent event) {
|
||||
HttpSession session = event.getSession();
|
||||
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
|
||||
if (context != null) {
|
||||
User user = (User) session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY);
|
||||
if (user != null) {
|
||||
ChatService service = (ChatService) context.getBean("chatService");
|
||||
service.logout(user.getName());
|
||||
public void sessionDestroyed(HttpSessionEvent event) {
|
||||
HttpSession session = event.getSession();
|
||||
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
|
||||
if (context != null) {
|
||||
User user = (User) session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY);
|
||||
if (user != null) {
|
||||
ChatService service = (ChatService) context.getBean("chatService");
|
||||
service.logout(user.getName());
|
||||
|
||||
LOG.info("session expired, logged user [" + user.getName() + "] out");
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG.info("session expired, logged user ["+user.getName()+"] out");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,5 +21,5 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
public class Constants {
|
||||
public static String UPDATE_FREQ = "5000";
|
||||
public static String UPDATE_FREQ = "5000";
|
||||
}
|
||||
|
||||
@@ -24,40 +24,41 @@ import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class CrudRoomAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private ChatService chatService;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public CrudRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public CrudRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String create() throws Exception {
|
||||
try {
|
||||
chatService.addRoom(new Room(name, description));
|
||||
} catch (ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String create() throws Exception {
|
||||
try {
|
||||
chatService.addRoom(new Room(name, description));
|
||||
}
|
||||
catch(ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,39 +20,41 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
import org.apache.struts2.util.StrutsTypeConverter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.util.StrutsTypeConverter;
|
||||
|
||||
import com.opensymphony.xwork2.util.logging.Logger;
|
||||
import com.opensymphony.xwork2.util.logging.LoggerFactory;
|
||||
|
||||
public class DateConverter extends StrutsTypeConverter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DateConverter.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DateConverter.class);
|
||||
|
||||
public Object convertFromString(Map context, String[] values, Class toClass) {
|
||||
public Object convertFromString(Map context, String[] values, Class toClass) {
|
||||
|
||||
if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
try {
|
||||
return sdf.parse(values[0]);
|
||||
} catch (ParseException e) {
|
||||
LOG.error("error converting value [" + values[0] + "] to Date ", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat();
|
||||
try {
|
||||
return sdf.parse(values[0]);
|
||||
}
|
||||
catch(ParseException e) {
|
||||
LOG.error("error converting value ["+values[0]+"] to Date ", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String convertToString(Map context, Object o) {
|
||||
public String convertToString(Map context, Object o) {
|
||||
|
||||
if (o instanceof Date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||
return sdf.format((Date) o);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
if (o instanceof Date) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||
return sdf.format((Date) o);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,46 +20,43 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
|
||||
import java.util.Map;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class EnterRoomAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private Map session;
|
||||
private String roomName;
|
||||
private ChatService chatService;
|
||||
private Map session;
|
||||
private String roomName;
|
||||
|
||||
public String getRoomName() {
|
||||
return this.roomName;
|
||||
}
|
||||
public String getRoomName() { return this.roomName; }
|
||||
public void setRoomName(String roomName) { this.roomName = roomName; }
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
public EnterRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public EnterRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
|
||||
public String execute() throws Exception {
|
||||
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
try {
|
||||
chatService.enterRoom(user, roomName);
|
||||
} catch (Exception e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
try {
|
||||
chatService.enterRoom(user, roomName);
|
||||
}
|
||||
catch(Exception e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,43 +20,39 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
|
||||
import java.util.Map;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class ExitRoomAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String roomName;
|
||||
private String roomName;
|
||||
|
||||
private Map session;
|
||||
private Map session;
|
||||
|
||||
public String getRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
public String getRoomName() { return roomName; }
|
||||
public void setRoomName(String roomName) { this.roomName = roomName; }
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
private ChatService chatService;
|
||||
|
||||
private ChatService chatService;
|
||||
public ExitRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public ExitRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
chatService.exitRoom(user.getName(), roomName);
|
||||
|
||||
public String execute() throws Exception {
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
chatService.exitRoom(user.getName(), roomName);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
// === SessionAware ===
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+25
-27
@@ -20,42 +20,40 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class MessagesAvailableInRoomAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String roomName;
|
||||
private ChatService chatService;
|
||||
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
|
||||
private String roomName;
|
||||
private ChatService chatService;
|
||||
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
|
||||
|
||||
public String getRoomName() {
|
||||
return this.roomName;
|
||||
}
|
||||
public String getRoomName() { return this.roomName; }
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
public List<ChatMessage> getMessagesAvailableInRoom() {
|
||||
return messagesAvailableInRoom;
|
||||
}
|
||||
|
||||
public List<ChatMessage> getMessagesAvailableInRoom() {
|
||||
return messagesAvailableInRoom;
|
||||
}
|
||||
public MessagesAvailableInRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public MessagesAvailableInRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
messagesAvailableInRoom = chatService.getMessagesInRoom(roomName);
|
||||
} catch (ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
messagesAvailableInRoom = chatService.getMessagesInRoom(roomName);
|
||||
}
|
||||
catch(ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,81 +20,82 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Room {
|
||||
|
||||
private static final int MAX_CHAT_MESSAGES = 10;
|
||||
private static final int MAX_CHAT_MESSAGES = 10;
|
||||
|
||||
private String name;
|
||||
private String description;
|
||||
private Date creationDate;
|
||||
private String name;
|
||||
private String description;
|
||||
private Date creationDate;
|
||||
|
||||
private List<ChatMessage> messages = new ArrayList<ChatMessage>();
|
||||
private List<ChatMessage> messages = new ArrayList<ChatMessage>();
|
||||
|
||||
private Map<String, User> members = new LinkedHashMap<String, User>();
|
||||
private Map<String, User> members = new LinkedHashMap<String, User>();
|
||||
|
||||
public Room(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.creationDate = new Date(System.currentTimeMillis());
|
||||
}
|
||||
public Room(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.creationDate = new Date(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
// properties
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
// properties
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
// (behaviour) members
|
||||
public List<User> getMembers() {
|
||||
return new ArrayList<User>(members.values());
|
||||
}
|
||||
// (behaviour) members
|
||||
public List<User> getMembers() {
|
||||
return new ArrayList<User>(members.values());
|
||||
}
|
||||
public User findMember(String name) {
|
||||
assert(name != null);
|
||||
return members.get(name);
|
||||
}
|
||||
public boolean hasMember(String name) {
|
||||
assert(name != null);
|
||||
return members.containsKey(name);
|
||||
}
|
||||
public void memberEnter(User member) {
|
||||
assert(member != null);
|
||||
if (! hasMember(member.getName())) {
|
||||
members.put(member.getName(), member);
|
||||
}
|
||||
}
|
||||
|
||||
public User findMember(String name) {
|
||||
assert (name != null);
|
||||
return members.get(name);
|
||||
}
|
||||
|
||||
public boolean hasMember(String name) {
|
||||
assert (name != null);
|
||||
return members.containsKey(name);
|
||||
}
|
||||
|
||||
public void memberEnter(User member) {
|
||||
assert (member != null);
|
||||
if (!hasMember(member.getName())) {
|
||||
members.put(member.getName(), member);
|
||||
}
|
||||
}
|
||||
|
||||
public void memberExit(String memberName) {
|
||||
assert (memberName != null);
|
||||
assert (memberName.trim().length() > 0);
|
||||
members.remove(memberName);
|
||||
}
|
||||
public void memberExit(String memberName) {
|
||||
assert(memberName != null);
|
||||
assert(memberName.trim().length() > 0);
|
||||
members.remove(memberName);
|
||||
}
|
||||
|
||||
|
||||
// (behaviour) chat messags
|
||||
public void addMessage(ChatMessage chatMessage) {
|
||||
if (messages.size() > MAX_CHAT_MESSAGES) {
|
||||
// messages.remove(messages.size() - 1);
|
||||
messages.remove(0);
|
||||
}
|
||||
messages.add(chatMessage);
|
||||
}
|
||||
// (behaviour) chat messags
|
||||
public void addMessage(ChatMessage chatMessage) {
|
||||
if (messages.size() > MAX_CHAT_MESSAGES) {
|
||||
// messages.remove(messages.size() - 1);
|
||||
messages.remove(0);
|
||||
}
|
||||
messages.add(chatMessage);
|
||||
}
|
||||
|
||||
public List<ChatMessage> getChatMessages() {
|
||||
return new ArrayList<ChatMessage>(messages);
|
||||
}
|
||||
public List<ChatMessage> getChatMessages() {
|
||||
return new ArrayList<ChatMessage>(messages);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-15
@@ -20,29 +20,29 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class RoomsAvailableAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<Room> availableRooms = new ArrayList<Room>();
|
||||
private List<Room> availableRooms = new ArrayList<Room>();
|
||||
|
||||
private ChatService chatService;
|
||||
private ChatService chatService;
|
||||
|
||||
public RoomsAvailableAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public RoomsAvailableAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
availableRooms = chatService.getAvailableRooms();
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
availableRooms = chatService.getAvailableRooms();
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public List<Room> getAvailableRooms() {
|
||||
return availableRooms;
|
||||
}
|
||||
public List<Room> getAvailableRooms() {
|
||||
return availableRooms;
|
||||
}
|
||||
}
|
||||
|
||||
+31
-36
@@ -20,56 +20,51 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.struts2.interceptor.SessionAware;
|
||||
|
||||
import java.util.Map;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class SendMessageToRoomAction extends ActionSupport implements SessionAware {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private ChatService chatService;
|
||||
|
||||
private String roomName;
|
||||
private String message;
|
||||
private Map session;
|
||||
private String roomName;
|
||||
private String message;
|
||||
private Map session;
|
||||
|
||||
|
||||
public SendMessageToRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public SendMessageToRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String getRoomName() {
|
||||
return this.roomName;
|
||||
}
|
||||
public String getRoomName() { return this.roomName; }
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
public String getMessage() { return this.message; }
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
try {
|
||||
chatService.sendMessageToRoom(roomName, user, message);
|
||||
} catch (ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
|
||||
try {
|
||||
chatService.sendMessageToRoom(roomName, user, message);
|
||||
}catch(ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
public void setSession(Map session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,24 +26,23 @@ import java.util.Date;
|
||||
/**
|
||||
* Represends a user in the Chat example.
|
||||
*/
|
||||
public class User implements Serializable {
|
||||
public class User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1434958919516089297L;
|
||||
private static final long serialVersionUID = -1434958919516089297L;
|
||||
|
||||
private String name;
|
||||
private Date creationDate;
|
||||
private String name;
|
||||
private Date creationDate;
|
||||
|
||||
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
this.creationDate = new Date(System.currentTimeMillis());
|
||||
}
|
||||
public User(String name) {
|
||||
this.name = name;
|
||||
this.creationDate = new Date(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-15
@@ -20,30 +20,30 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class UsersAvailableAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<User> availableUsers = new ArrayList<User>();
|
||||
private ChatService chatService;
|
||||
private List<User> availableUsers = new ArrayList<User>();
|
||||
private ChatService chatService;
|
||||
|
||||
public UsersAvailableAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public UsersAvailableAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
public String execute() throws Exception {
|
||||
|
||||
availableUsers = chatService.getAvailableUsers();
|
||||
availableUsers = chatService.getAvailableUsers();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public List<User> getAvailableUsers() {
|
||||
return availableUsers;
|
||||
}
|
||||
public List<User> getAvailableUsers() {
|
||||
return availableUsers;
|
||||
}
|
||||
}
|
||||
|
||||
+25
-27
@@ -20,44 +20,42 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
public class UsersAvailableInRoomAction extends ActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ChatService chatService;
|
||||
private List<User> usersAvailableInRoom = new ArrayList<User>();
|
||||
private ChatService chatService;
|
||||
private List<User> usersAvailableInRoom = new ArrayList<User>();
|
||||
|
||||
private String roomName;
|
||||
private String roomName;
|
||||
|
||||
public UsersAvailableInRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
public UsersAvailableInRoomAction(ChatService chatService) {
|
||||
this.chatService = chatService;
|
||||
}
|
||||
|
||||
|
||||
public String getRoomName() {
|
||||
return this.roomName;
|
||||
}
|
||||
public String getRoomName() { return this.roomName; }
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
|
||||
public void setRoomName(String roomName) {
|
||||
this.roomName = roomName;
|
||||
}
|
||||
public List<User> getUsersAvailableInRoom() {
|
||||
return usersAvailableInRoom;
|
||||
}
|
||||
|
||||
public List<User> getUsersAvailableInRoom() {
|
||||
return usersAvailableInRoom;
|
||||
}
|
||||
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
|
||||
} catch (ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
public String execute() throws Exception {
|
||||
try {
|
||||
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
|
||||
}
|
||||
catch(ChatException e) {
|
||||
addActionError(e.getMessage());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,23 +26,13 @@ package org.apache.struts2.showcase.conversion;
|
||||
*/
|
||||
public class Address {
|
||||
|
||||
private String id;
|
||||
private String address;
|
||||
private String id;
|
||||
private String address;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
public String getAddress() { return address; }
|
||||
public void setAddress(String address) { this.address = address; }
|
||||
|
||||
}
|
||||
|
||||
+12
-16
@@ -20,32 +20,28 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.conversion;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
* @version $Date$ $Id$
|
||||
*/
|
||||
public class AddressAction extends ActionSupport {
|
||||
|
||||
private Set<Address> addresses = new LinkedHashSet<Address>();
|
||||
private Set addresses = new LinkedHashSet();
|
||||
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
public Set getAddresses() { return addresses; }
|
||||
public void setAddresses(Set addresses) { this.addresses = addresses; }
|
||||
|
||||
public String submit() throws Exception {
|
||||
System.out.println(addresses);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public Set<Address> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
public String input() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
public void setAddresses(Set<Address> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
public String submit() throws Exception {
|
||||
System.out.println(addresses);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-22
@@ -20,39 +20,39 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.conversion;
|
||||
|
||||
import org.apache.struts2.util.StrutsTypeConverter;
|
||||
|
||||
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 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;
|
||||
}
|
||||
@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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user