mirror of
https://github.com/apache/struts.git
synced 2026-08-08 08:07:17 +00:00
Compare commits
124 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8cadf565a | |||
| d09da593eb | |||
| 6d6492b1f0 | |||
| c872ba3108 | |||
| 137da15d07 | |||
| e2b0819538 | |||
| ca2fa277d3 | |||
| 733fb5e8a2 | |||
| 802ed18ca4 | |||
| 26b76a25f1 | |||
| 1a537ff27c | |||
| 9cd3aa23a8 | |||
| 4f342ae935 | |||
| e5696eff33 | |||
| e6d012a9ae | |||
| 8c775ce550 | |||
| 6a4ea41f79 | |||
| 66bec3e8ab | |||
| cc48951911 | |||
| f72fada5cb | |||
| 81d5ca327a | |||
| af781d0079 | |||
| b416c2fbe1 | |||
| 501f80d465 | |||
| b25dc1b3c3 | |||
| 37d78edf96 | |||
| 8c3f7952dd | |||
| e601d02be6 | |||
| 19efe8ff3a | |||
| 6fd66f2695 | |||
| 786a94f35e | |||
| c23822d31b | |||
| 369b22af7b | |||
| ce3042977f | |||
| c082194bd4 | |||
| add167aefd | |||
| 168bf5e8ab | |||
| e977b5a63e | |||
| fb57ae14cd | |||
| 6cd8b820fb | |||
| 217c43f21c | |||
| ce80410c58 | |||
| 55ea2ea1d9 | |||
| ccc7b7471c | |||
| e0a606e2b7 | |||
| a6aedd2dfb | |||
| d8ac6de7bb | |||
| 4b6504b01e | |||
| 11a819d4d2 | |||
| 7c11bd3564 | |||
| 7ec7764e16 | |||
| 60227b13f0 | |||
| 67de561c2a | |||
| ad4c656209 | |||
| fe1ef6b99e | |||
| 3d3ed4d537 | |||
| 90c9f6ff3b | |||
| 9fe437b44a | |||
| 34d8707456 | |||
| 8f411c1d12 | |||
| 5e68db2e90 | |||
| 3bc1186993 | |||
| 6e141ac437 | |||
| 051f059e70 | |||
| ac5928a0bc | |||
| 8646947822 | |||
| 4f37c65f78 | |||
| fefbe21884 | |||
| e7e6065b36 | |||
| 3fea9c6f50 | |||
| 64a653aa59 | |||
| 45ab263e00 | |||
| 3715572d7c | |||
| 672bb186cd | |||
| f54b26d71f | |||
| 9fbbeea663 | |||
| 06d7cb4e06 | |||
| 1800f44731 | |||
| 8f4dfbe63f | |||
| de9f68d868 | |||
| 0b24ede354 | |||
| d222f92835 | |||
| 266a553f5d | |||
| 3774507d5f | |||
| fe8fd6125c | |||
| 979b8c0544 | |||
| a42a60b1ab | |||
| 330f6ecb56 | |||
| 2440ce6bdb | |||
| bdbe0bf7f9 | |||
| 463ce50112 | |||
| f50c16070f | |||
| ebb6c3f814 | |||
| b5b90755f5 | |||
| bc9c3477bf | |||
| 90a91201e8 | |||
| 59a63106a0 | |||
| c1ff9ac97b | |||
| cad5823cb8 | |||
| ff78317b63 | |||
| 524c3d5c15 | |||
| b8ccb9e9c3 | |||
| 4ce0026a55 | |||
| 2ea2f95b36 | |||
| daa46fb71f | |||
| 20da1d6161 | |||
| 80bb25dd2f | |||
| f4d14204e3 | |||
| cf351ce368 | |||
| 13b5b3a41a | |||
| 560213cbe9 | |||
| b42a06f505 | |||
| e6c552dffa | |||
| 8066a53a0b | |||
| 65cf49a1a1 | |||
| bf1fc42345 | |||
| 0875a59f33 | |||
| 44aeb64064 | |||
| cbe136ab09 | |||
| 3d9f578992 | |||
| c2f13be89b | |||
| ffd0fb693b | |||
| 00c246f530 | |||
| 170f5226ea |
+22
@@ -1,4 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<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>
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<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>
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<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>
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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 mailreader2;
|
||||
|
||||
import com.opensymphony.xwork2.interceptor.Interceptor;
|
||||
|
||||
+19
-16
@@ -1,21 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright 2005-2006 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
@@ -58,7 +61,7 @@
|
||||
<dependency>
|
||||
<groupId>com.hostedqa</groupId>
|
||||
<artifactId>hostedqa-remote-ant</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -121,7 +124,7 @@
|
||||
<dependency>
|
||||
<groupId>com.hostedqa</groupId>
|
||||
<artifactId>hostedqa-remote-ant</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
+59
-7
@@ -1,4 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<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>
|
||||
@@ -87,14 +109,22 @@
|
||||
<artifactId>commons-digester</artifactId>
|
||||
<version>1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
@@ -103,4 +133,26 @@
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>rat-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>pom.xml</include>
|
||||
<include>src/**</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>src/main/etc/gridsphere/README-gridsphere.txt</exclude>
|
||||
<exclude>src/main/etc/gridsphere/struts-portlet</exclude>
|
||||
<exclude>src/main/etc/jetspeed2/README-jetspeed2.txt</exclude>
|
||||
<exclude>src/main/etc/jetspeed2/struts-portlet.psml</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* $Id: FormExample.java 471756 2006-11-06 15:01:43Z husted $
|
||||
*
|
||||
* 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;
|
||||
|
||||
import org.apache.struts2.portlet.example.model.Name;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class FormExampleModelDriven extends ActionSupport implements ModelDriven<Name> {
|
||||
|
||||
private Name name = new Name();
|
||||
|
||||
public Name getModel() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* $Id: $
|
||||
*
|
||||
* 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.fileupload;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.struts2.dispatcher.DefaultActionSupport;
|
||||
|
||||
/**
|
||||
* File Upload example's action. <code>FileUploadAction</code>
|
||||
*
|
||||
*/
|
||||
public class FileUploadAction extends DefaultActionSupport {
|
||||
|
||||
private static final long serialVersionUID = 5156288255337069381L;
|
||||
|
||||
private String contentType;
|
||||
private File upload;
|
||||
private String fileName;
|
||||
private String caption;
|
||||
|
||||
// since we are using <s:file name="upload" .../> the file name will be
|
||||
// obtained through getter/setter of <file-tag-name>FileName
|
||||
public String getUploadFileName() {
|
||||
return fileName;
|
||||
}
|
||||
public void setUploadFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
|
||||
// since we are using <s:file name="upload" ... /> the content type will be
|
||||
// obtained through getter/setter of <file-tag-name>ContentType
|
||||
public String getUploadContentType() {
|
||||
return contentType;
|
||||
}
|
||||
public void setUploadContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
|
||||
// since we are using <s:file name="upload" ... /> the File itself will be
|
||||
// obtained through getter/setter of <file-tag-name>
|
||||
public File getUpload() {
|
||||
return upload;
|
||||
}
|
||||
public void setUpload(File upload) {
|
||||
this.upload = upload;
|
||||
}
|
||||
|
||||
|
||||
public String getCaption() {
|
||||
return caption;
|
||||
}
|
||||
public void setCaption(String caption) {
|
||||
this.caption = caption;
|
||||
}
|
||||
|
||||
public String upload() throws Exception {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.apache.struts2.portlet.example.model;
|
||||
|
||||
public class Name {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//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"
|
||||
namespace="/edit">
|
||||
<action name="index"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/edit/index.jsp</result>
|
||||
</action>
|
||||
<action name="test"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/edit/test.jsp</result>
|
||||
</action>
|
||||
<action name="formExampleEdit"
|
||||
class="org.apache.struts2.portlet.example.FormExample" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/edit/formExampleInput.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFormExampleEdit"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="input">
|
||||
/WEB-INF/edit/formExampleInput.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/edit/processFormExampleForward.action?firstName=${firstName}&lastName=${lastName}
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFormExampleForward"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="success">
|
||||
/WEB-INF/edit/formExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
</package>
|
||||
|
||||
<package name="editTest" extends="edit" namespace="/edit/dummy/test">
|
||||
<action name="testAction"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/edit/namespaceTest.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
</struts>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//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"
|
||||
namespace="/help">
|
||||
<action name="index"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/help/index.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
</struts>
|
||||
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE struts PUBLIC
|
||||
"-//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"
|
||||
namespace="/view">
|
||||
<action name="index"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/view/index.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="formExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInput.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFormExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInput.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/WEB-INF/view/formExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="formExampleModelDriven"
|
||||
class="org.apache.struts2.portlet.example.FormExampleModelDriven">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInputModelDriven.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/WEB-INF/view/formExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="validationExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInputValidation.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processValidationExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="success">
|
||||
/WEB-INF/view/formExample.jsp
|
||||
</result>
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInputValidation.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="fileUpload" class="org.apache.struts2.portlet.example.fileupload.FileUploadAction">
|
||||
<result name="input">
|
||||
/WEB-INF/view/fileUpload.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/WEB-INF/view/fileUploadSuccess.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="tokenExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/view/tokenExampleInput.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processTokenExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="input">
|
||||
/WEB-INF/view/tokenExampleInput.jsp
|
||||
</result>
|
||||
<result name="invalid.token">
|
||||
/WEB-INF/view/tokenExampleInput.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/WEB-INF/view/tokenExample.jsp
|
||||
</result>
|
||||
<interceptor-ref name="portletDefaultStackWithToken" />
|
||||
</action>
|
||||
|
||||
<action name="springExample" class="springAction">
|
||||
<result name="success">
|
||||
/WEB-INF/view/springExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="freeMarkerExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport" method="input">
|
||||
<result type="freemarker" name="input">
|
||||
/WEB-INF/view/freeMarkerExampleInput.ftl
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFreeMarkerExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="success">/view/processFreeMarkerView.action?firstName=${firstName}&lastName=${lastName}</result>
|
||||
</action>
|
||||
|
||||
<action name="processFreeMarkerView" class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result type="freemarker" name="success">/WEB-INF/view/freeMarkerExample.ftl</result>
|
||||
</action>
|
||||
|
||||
<action name="velocityHelloWorld" class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result type="velocity" name="success">/WEB-INF/view/helloWorld.vm</result>
|
||||
</action>
|
||||
|
||||
</package>
|
||||
</struts>
|
||||
@@ -1 +0,0 @@
|
||||
struts.objectFactory = spring
|
||||
@@ -4,159 +4,7 @@
|
||||
"http://struts.apache.org/dtds/struts-2.0.dtd">
|
||||
|
||||
<struts>
|
||||
<include file="struts-portlet-default.xml" />
|
||||
|
||||
<package name="view" extends="struts-portlet-default"
|
||||
namespace="/view">
|
||||
<action name="index"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/view/index.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="formExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInput.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFormExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInput.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/WEB-INF/view/formExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="validationExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInputValidation.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processValidationExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="success">
|
||||
/WEB-INF/view/formExample.jsp
|
||||
</result>
|
||||
<result name="input">
|
||||
/WEB-INF/view/formExampleInputValidation.jsp
|
||||
</result>
|
||||
<interceptor-ref name="validationWorkflowStack" />
|
||||
</action>
|
||||
|
||||
<action name="tokenExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/view/tokenExampleInput.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processTokenExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="input">
|
||||
/WEB-INF/view/tokenExampleInput.jsp
|
||||
</result>
|
||||
<result name="invalid.token">
|
||||
/WEB-INF/view/tokenExampleInput.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/WEB-INF/view/tokenExample.jsp
|
||||
</result>
|
||||
<interceptor-ref name="token" />
|
||||
<interceptor-ref name="defaultStack" />
|
||||
</action>
|
||||
|
||||
<action name="springExample" class="springAction">
|
||||
<result name="success">
|
||||
/WEB-INF/view/springExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="ajaxExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">
|
||||
/WEB-INF/view/ajaxExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="ajaxData"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/view/ajaxData.jsp</result>
|
||||
</action>
|
||||
|
||||
<action name="freeMarkerExample"
|
||||
class="com.opensymphony.xwork2.ActionSupport" method="input">
|
||||
<result type="freemarker" name="input">
|
||||
/WEB-INF/view/freeMarkerExampleInput.ftl
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFreeMarkerExample"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="success">/view/processFreeMarkerView.action?firstName=${firstName}&lastName=${lastName}</result>
|
||||
</action>
|
||||
|
||||
<action name="processFreeMarkerView" class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result type="freemarker" name="success">/WEB-INF/view/freeMarkerExample.ftl</result>
|
||||
</action>
|
||||
|
||||
<action name="velocityHelloWorld" class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result type="velocity" name="success">/WEB-INF/view/helloWorld.vm</result>
|
||||
</action>
|
||||
|
||||
</package>
|
||||
|
||||
<package name="edit" extends="struts-portlet-default"
|
||||
namespace="/edit">
|
||||
<action name="index"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/edit/index.jsp</result>
|
||||
</action>
|
||||
<action name="test"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/edit/test.jsp</result>
|
||||
</action>
|
||||
<action name="formExampleEdit"
|
||||
class="org.apache.struts2.portlet.example.FormExample" method="input">
|
||||
<result name="input">
|
||||
/WEB-INF/edit/formExampleInput.jsp
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFormExampleEdit"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="input">
|
||||
/WEB-INF/edit/formExampleInput.jsp
|
||||
</result>
|
||||
<result name="success">
|
||||
/edit/processFormExampleForward.action?firstName=${firstName}&lastName=${lastName}
|
||||
</result>
|
||||
</action>
|
||||
|
||||
<action name="processFormExampleForward"
|
||||
class="org.apache.struts2.portlet.example.FormExample">
|
||||
<result name="success">
|
||||
/WEB-INF/edit/formExample.jsp
|
||||
</result>
|
||||
</action>
|
||||
</package>
|
||||
|
||||
<package name="editTest" extends="edit" namespace="/edit/dummy/test">
|
||||
<action name="testAction"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/edit/namespaceTest.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
|
||||
<package name="help" extends="struts-portlet-default"
|
||||
namespace="/help">
|
||||
<action name="index"
|
||||
class="com.opensymphony.xwork2.ActionSupport">
|
||||
<result name="success">/WEB-INF/help/index.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
<include file="struts-view.xml"/>
|
||||
<include file="struts-edit.xml"/>
|
||||
<include file="struts-help.xml"/>
|
||||
</struts>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE dwr PUBLIC
|
||||
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
|
||||
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
|
||||
<dwr>
|
||||
<allow>
|
||||
<create creator="new" javascript="validator">
|
||||
<param name="class" value="org.apache.struts2.validators.DWRValidator"/>
|
||||
</create>
|
||||
<convert converter="bean" match="com.opensymphony.xwork2.ValidationAwareSupport"/>
|
||||
</allow>
|
||||
|
||||
<signatures>
|
||||
<![CDATA[
|
||||
import java.util.Map;
|
||||
import org.apache.struts2.validators.DWRValidator;
|
||||
|
||||
DWRValidator.doPost(String, String, Map<String, String>);
|
||||
]]>
|
||||
</signatures>
|
||||
</dwr>
|
||||
@@ -1,118 +1,131 @@
|
||||
<portlet-app 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>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<portlet-app
|
||||
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>
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
|
||||
|
||||
<init-param>
|
||||
<!-- The view mode namespace. Maps to a namespace in the xwork config file -->
|
||||
<name>viewNamespace</name>
|
||||
<value>/view</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The default action to invoke in view mode -->
|
||||
<name>defaultViewAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The view mode namespace. Maps to a namespace in the xwork config file -->
|
||||
<name>editNamespace</name>
|
||||
<value>/edit</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The default action to invoke in view mode -->
|
||||
<name>defaultEditAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The view mode namespace. Maps to a namespace in the xwork config file -->
|
||||
<name>helpNamespace</name>
|
||||
<value>/help</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The default action to invoke in view mode -->
|
||||
<name>defaultHelpAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
<!-- 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>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>edit</portlet-mode>
|
||||
<portlet-mode>help</portlet-mode>
|
||||
</supports>
|
||||
<supported-locale>en</supported-locale>
|
||||
|
||||
<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-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 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>
|
||||
<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
|
||||
|
||||
<init-param>
|
||||
<!-- The view mode namespace. Maps to a namespace in the xwork config file -->
|
||||
<name>viewNamespace</name>
|
||||
<value>/view</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The default action to invoke in view mode -->
|
||||
<name>defaultViewAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The view mode namespace. Maps to a namespace in the xwork config file -->
|
||||
<name>editNamespace</name>
|
||||
<value>/edit</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The default action to invoke in view mode -->
|
||||
<name>defaultEditAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The view mode namespace. Maps to a namespace in the xwork config file -->
|
||||
<name>helpNamespace</name>
|
||||
<value>/help</value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<!-- The default action to invoke in view mode -->
|
||||
<name>defaultHelpAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<!-- The view mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>viewNamespace</name>
|
||||
<value>/view</value>
|
||||
</init-param>
|
||||
|
||||
|
||||
<expiration-cache>0</expiration-cache>
|
||||
<!-- The default action to invoke in view mode. -->
|
||||
<init-param>
|
||||
<name>defaultViewAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<supports>
|
||||
<mime-type>text/html</mime-type>
|
||||
<portlet-mode>edit</portlet-mode>
|
||||
<portlet-mode>help</portlet-mode>
|
||||
</supports>
|
||||
<!-- The edit mode namespace. Maps to a namespace in the Struts 2 config file. -->
|
||||
<init-param>
|
||||
<name>editNamespace</name>
|
||||
<value>/edit</value>
|
||||
</init-param>
|
||||
|
||||
<supported-locale>en</supported-locale>
|
||||
<!-- The default action to invoke in edit mode. -->
|
||||
<init-param>
|
||||
<name>defaultEditAction</name>
|
||||
<value>index</value>
|
||||
</init-param>
|
||||
|
||||
<portlet-info>
|
||||
<title>My StrutsPortlet portlet2</title>
|
||||
<short-title>SP2</short-title>
|
||||
<keywords>struts,portlet</keywords>
|
||||
</portlet-info>
|
||||
</portlet>
|
||||
<!-- 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 StrutsPortlet portlet2</title>
|
||||
<short-title>SP2</short-title>
|
||||
<keywords>struts,portlet</keywords>
|
||||
</portlet-info>
|
||||
</portlet>
|
||||
|
||||
</portlet-app>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<H2>Hello from Ajax!</H2>
|
||||
@@ -1 +0,0 @@
|
||||
This data is fetched via Ajax! The server time is <%= new java.util.Date() %>
|
||||
@@ -1,48 +0,0 @@
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
<s:head theme="ajax"/>
|
||||
<link rel="stylesheet" type="text/css" href="<s:url value="/struts/tabs.css"/>">
|
||||
<b>This is a tabbed pane with two panels that fetches data from a remote action via ajax</b>
|
||||
|
||||
<s:tabbedPanel id="test2" theme="simple" >
|
||||
<s:div id="left" label="left" theme="ajax">
|
||||
This is the left pane<br/>
|
||||
<s:form >
|
||||
<s:textfield name="tt" label="Test Text" /> <br/>
|
||||
<s:textfield name="tt2" label="Test Text2" />
|
||||
</s:form>
|
||||
</s:div>
|
||||
<s:div href="<s:url action="ajaxData"/>" id="ryh1" theme="ajax" label="remote one" />
|
||||
<s:div id="middle" label="middle" theme="ajax">
|
||||
middle tab<br/>
|
||||
<s:form >
|
||||
<s:textfield name="tt" label="Test Text44" /> <br/>
|
||||
<s:textfield name="tt2" label="Test Text442" />
|
||||
</s:form>
|
||||
</s:div>
|
||||
<s:div href="<s:url action="ajaxData"/>" id="ryh21" theme="ajax" label="remote right" />
|
||||
</s:tabbedPanel>
|
||||
|
||||
<p/>
|
||||
A DIV that waits for 5 seconds before loading the contents
|
||||
<s:div
|
||||
id="once"
|
||||
theme="ajax"
|
||||
cssStyle="border: 1px solid yellow;"
|
||||
href="<s:url action="ajaxData"/>"
|
||||
delay="5000"
|
||||
loadingText="loading...">
|
||||
Waiting for data</s:div>
|
||||
<p/>
|
||||
A DIV that is updated every 2 seconds
|
||||
<s:div
|
||||
id="twoseconds"
|
||||
cssStyle="border: 1px solid yellow;"
|
||||
href="<s:url action="ajaxData"/>"
|
||||
theme="ajax"
|
||||
delay="2000"
|
||||
updateFreq="2000"
|
||||
errorText="There was an error"
|
||||
loadingText="loading...">Initial Content
|
||||
</s:div>
|
||||
<p/>
|
||||
<a href="<s:url action="index"/>">Back to front page</a>
|
||||
@@ -0,0 +1,13 @@
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<h1>Fileupload sample</h1>
|
||||
|
||||
<s:actionerror />
|
||||
<s:fielderror />
|
||||
<s:form action="fileUpload" method="POST" enctype="multipart/form-data">
|
||||
<s:file name="upload" label="File"/>
|
||||
<s:textfield name="caption" label="Caption"/>
|
||||
<s:submit />
|
||||
</s:form>
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<h1>Fileupload sample</h1>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>ContentType: <s:property value="uploadContentType" /></li>
|
||||
<li>FileName: <s:property value="uploadFileName" /></li>
|
||||
<li>File: <s:property value="upload" /></li>
|
||||
<li>Caption:<s:property value="caption" /></li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
|
||||
<H2>Input your name</H2>
|
||||
<s:form action="formExampleModelDriven" method="POST">
|
||||
<s:textfield label="First name" name="firstName" value="%{firstName}"/>
|
||||
<s:textfield label="Last name" name="lastName" value="%{lastName}"/>
|
||||
<s:submit value="Submit the form"/>
|
||||
</s:form>
|
||||
@@ -4,10 +4,11 @@
|
||||
Here you'll find examples of what is possible with the Struts Portlet integration framework.
|
||||
<ul>
|
||||
<li><a href="<s:url action="formExample"/>">A simple form</a></li>
|
||||
<li><a href="<s:url action="formExampleModelDriven" method="input"/>">Model driven example</li>
|
||||
<li><a href="<s:url action="validationExample"/>">Validation</a></li>
|
||||
<li><a href="<s:url action="tokenExample"/>">Token</a></li>
|
||||
<li><a href="<s:url action="springExample"/>">Spring integration</a></li>
|
||||
<li><a href="<s:url action="ajaxExample"/>">Ajax</a></li>
|
||||
<li><a href="<s:url action="fileUpload" method="input"/>">File upload</li>
|
||||
<li><a href="<s:url action="freeMarkerExample"/>">FreeMarker</a></li>
|
||||
<li><a href="<s:url action="velocityHelloWorld"/>">Velocity</a></li>
|
||||
<li><a href="<s:url action="index" portletMode="edit"/>">Go to edit mode and see what's there</a></li>
|
||||
|
||||
@@ -4,46 +4,30 @@
|
||||
<!-- Uncomment/comment this if you need/don't need Spring support -->
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>/WEB-INF/applicationContext*.xml</param-value>
|
||||
<param-value>
|
||||
/WEB-INF/applicationContext*.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
<filter id="filterdispatcher">
|
||||
<filter-name>action2</filter-name>
|
||||
<filter-class>
|
||||
org.apache.struts2.dispatcher.FilterDispatcher
|
||||
</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>action2</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<listener>
|
||||
<listener-class>
|
||||
org.springframework.web.context.ContextLoaderListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
<filter id="filterdispatcher">
|
||||
<filter-name>Struts2</filter-name>
|
||||
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>Struts2</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<listener>
|
||||
<listener-class>
|
||||
org.apache.struts2.portlet.context.ServletContextHolderListener
|
||||
</listener-class>
|
||||
<listener-class> org.springframework.web.context.ContextLoaderListener
|
||||
</listener-class>
|
||||
</listener>
|
||||
|
||||
|
||||
<servlet id="preparator">
|
||||
<servlet-name>preparator</servlet-name>
|
||||
<servlet-class>
|
||||
org.apache.struts2.portlet.context.PreparatorServlet
|
||||
</servlet-class>
|
||||
</servlet>
|
||||
<servlet id="dwr">
|
||||
<servlet-name>dwr</servlet-name>
|
||||
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>dwr</servlet-name>
|
||||
<url-pattern>/dwr/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- 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>
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<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>
|
||||
|
||||
+20
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id: pom.xml 559206 2007-07-24 21:01:18Z apetrelli $
|
||||
*
|
||||
* 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.showcase;
|
||||
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
+20
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id: pom.xml 559206 2007-07-24 21:01:18Z apetrelli $
|
||||
*
|
||||
* 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.showcase.ajax;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -72,6 +72,10 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
}
|
||||
}
|
||||
pageLines = read(in, -1);
|
||||
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (className != null && className.trim().length() > 0) {
|
||||
@@ -81,6 +85,10 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
|
||||
in = servletContext.getResourceAsStream("/WEB-INF/src"+className);
|
||||
}
|
||||
classLines = read(in, -1);
|
||||
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
String rootPath = ServletActionContext.getServletContext().getRealPath("/");
|
||||
|
||||
@@ -2,4 +2,5 @@ Apache Struts
|
||||
Copyright 2000-2007 The Apache Software Foundation
|
||||
|
||||
This product includes software developed by
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
Nifty Corners (http://www.html.it/articoli/nifty/index.html).
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
</action>
|
||||
<action name="quizAjax" class="org.apache.struts2.showcase.validation.QuizAction">
|
||||
<interceptor-ref name="jsonValidationWorkflowStack"/>
|
||||
<result name="input">/validation/quiz-ajax.jsp</result>
|
||||
<result>/validation/quiz-success.jsp</result>
|
||||
</action>
|
||||
<action name="getNodes" class="org.apache.struts2.showcase.ShowAjaxDynamicTreeAction">
|
||||
|
||||
@@ -7,39 +7,39 @@
|
||||
<struts>
|
||||
<package name="integration" extends="struts1-default" namespace="/integration">
|
||||
|
||||
<interceptors>
|
||||
<interceptor name="gangsterForm" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
|
||||
<param name="className">org.apache.struts2.showcase.integration.GangsterForm</param>
|
||||
<param name="name">gangsterForm</param>
|
||||
</interceptor>
|
||||
<interceptor name="gangsterValidation" class="org.apache.struts2.s1.ActionFormValidationInterceptor">
|
||||
<param name="pathnames">/org/apache/struts/validator/validator-rules.xml,/WEB-INF/validation.xml</param>
|
||||
</interceptor>
|
||||
<interceptors>
|
||||
<interceptor name="gangsterForm" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor">
|
||||
<param name="className">org.apache.struts2.showcase.integration.GangsterForm</param>
|
||||
<param name="name">gangsterForm</param>
|
||||
</interceptor>
|
||||
<interceptor name="gangsterValidation" class="org.apache.struts2.s1.ActionFormValidationInterceptor">
|
||||
<param name="pathnames">/org/apache/struts/validator/validator-rules.xml,/WEB-INF/validation.xml</param>
|
||||
</interceptor>
|
||||
|
||||
<interceptor-stack name="integration">
|
||||
<interceptor-ref name="staticParams"/>
|
||||
<interceptor-ref name="gangsterForm"/>
|
||||
<interceptor-ref name="modelDriven"/>
|
||||
<interceptor-ref name="actionForm-reset"/>
|
||||
<interceptor-ref name="basicStack"/>
|
||||
<interceptor-ref name="gangsterValidation"/>
|
||||
<interceptor-ref name="workflow"/>
|
||||
</interceptor-stack>
|
||||
</interceptors>
|
||||
<interceptor-stack name="integration">
|
||||
<interceptor-ref name="staticParams"/>
|
||||
<interceptor-ref name="gangsterForm"/>
|
||||
<interceptor-ref name="modelDriven"/>
|
||||
<interceptor-ref name="actionForm-reset"/>
|
||||
<interceptor-ref name="basicStack"/>
|
||||
<interceptor-ref name="gangsterValidation"/>
|
||||
<interceptor-ref name="workflow"/>
|
||||
</interceptor-stack>
|
||||
</interceptors>
|
||||
|
||||
<default-interceptor-ref name="integration" />
|
||||
<default-action-ref name="editGangster" />
|
||||
<default-interceptor-ref name="integration"/>
|
||||
<default-action-ref name="editGangster"/>
|
||||
|
||||
<!-- Diplay entry page that uses Model-Driven technique -->
|
||||
<!-- Display entry page that uses Model-Driven technique -->
|
||||
<action name="editGangster" class="org.apache.struts2.s1.Struts1Action">
|
||||
<param name="className">org.apache.struts2.showcase.integration.EditGangsterAction</param>
|
||||
<param name="className">org.apache.struts2.showcase.integration.EditGangsterAction</param>
|
||||
<result>modelDriven.jsp</result>
|
||||
</action>
|
||||
|
||||
<!-- Display the result page whose content is populated using the Model-Driven technique -->
|
||||
<action name="saveGangster" class="org.apache.struts2.s1.Struts1Action">
|
||||
<param name="className">org.apache.struts2.showcase.integration.SaveGangsterAction</param>
|
||||
<param name="validate">true</param>
|
||||
<param name="className">org.apache.struts2.showcase.integration.SaveGangsterAction</param>
|
||||
<param name="validate">true</param>
|
||||
<result name="input">modelDriven.jsp</result>
|
||||
<result>modelDrivenResult.jsp</result>
|
||||
</action>
|
||||
|
||||
@@ -62,7 +62,8 @@ Using a JSON list returned from an action (href="/JSONList.action"), without aut
|
||||
|
||||
Reload on type (loadOnTextChange="true"), after 3 characters (loadMinimumCount="3", it is "3" by default), without the down arrow button (showDownArrow="false")
|
||||
<br/>
|
||||
<sx:autocompleter
|
||||
<sx:autocompleter
|
||||
id="auto2"
|
||||
indicator="indicator"
|
||||
href="%{jsonList}"
|
||||
cssStyle="width: 200px;"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<p>
|
||||
1. Attach to "onclick" event on button. Update content of Div 1. Use with indicator.
|
||||
<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
|
||||
<sx:bind id="ex1" href="%{#ajaxTest}" sources="button" targets="div1" events="onclick" indicator="indicator" />
|
||||
<sx:bind href="%{#ajaxTest}" sources="button" targets="div1" events="onclick" indicator="indicator" />
|
||||
<br/>
|
||||
<s:submit theme="simple" type="submit" value="submit" id="button"/>
|
||||
</p>
|
||||
|
||||
@@ -38,7 +38,7 @@ A submit button, that highlights (blue color) its targets
|
||||
|
||||
A submit button, with an indicator
|
||||
<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
|
||||
<sx:submit type="submit" value="submit" targets="t1" href="%{ajaxTest}" indicator="indicator"/>
|
||||
<sx:submit id="submit2" type="submit" value="submit" targets="t1" href="%{ajaxTest}" indicator="indicator"/>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
<body>
|
||||
<sx:div
|
||||
id="once"
|
||||
cssStyle="border: 1px solid yellow;"
|
||||
href="%{ajaxTest}">
|
||||
Initial Content</sx:div>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<s:url var="ajaxTest" value="/AjaxTest.action" />
|
||||
<s:url var="test3" value="/Test3.action" />
|
||||
|
||||
<sx:a id="link0"
|
||||
<sx:a
|
||||
href="%{#ajaxTest}"
|
||||
targets="t1"
|
||||
highlightColor="red"
|
||||
|
||||
@@ -11,18 +11,15 @@
|
||||
|
||||
<body>
|
||||
|
||||
<sx:tabbedpanel id="test2" cssStyle="width: 500px; height: 300px;" doLayout="true">
|
||||
<sx:div id="left" label="test1" >
|
||||
I'm a Tab!!!
|
||||
</sx:div >
|
||||
<sx:div id="middle" label="test2" >
|
||||
I'm the other Tab!!!
|
||||
</sx:div >
|
||||
|
||||
</sx:tabbedpanel>
|
||||
<sx:tabbedpanel id="test2" cssStyle="width: 500px; height: 300px;" doLayout="true">
|
||||
<sx:div label="test1" >
|
||||
I'm a Tab!!!
|
||||
</sx:div >
|
||||
<sx:div id="middle" label="test2" >
|
||||
I'm the other Tab!!!
|
||||
</sx:div >
|
||||
</sx:tabbedpanel>
|
||||
|
||||
|
||||
|
||||
<s:include value="../footer.jsp"/>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="s" uri="/struts-tags" %>
|
||||
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
@@ -19,16 +20,16 @@ NOTES:
|
||||
|
||||
Default Editor configuration:<br/>
|
||||
<s:form id="form1" action="AjaxRemoteForm" method="post">
|
||||
<s:textarea name="data" theme="ajax" cols="50" rows="10" value="Test Data 1" />
|
||||
<sx:textarea name="data" cols="50" rows="10" value="Test Data 1" />
|
||||
<s:submit value="Submit"/>
|
||||
</s:form>
|
||||
<br/>
|
||||
|
||||
Configured Editor configuration:<br/>
|
||||
Configured Editor configuration:<br/>
|
||||
<s:form id="form2" action="AjaxRemoteForm" method="post">
|
||||
<s:textarea id="editor2" name="data" theme="ajax" cols="50" rows="10" value="Test Data 2">
|
||||
<sx:textarea id="editor2" name="data" cols="50" rows="10" value="Test Data 2">
|
||||
<s:param name="editorControls">textGroup;|;justifyGroup;|;listGroup;|;indentGroup</s:param>
|
||||
</s:textarea>
|
||||
</sx:textarea>
|
||||
<s:submit value="Submit"/>
|
||||
</s:form>
|
||||
<br/>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<ul>
|
||||
<li><a href="<s:url value="/showcase.jsp"/>">Home</a></li>
|
||||
<li><a href="<s:url value="/interactive/index.jsp" />">Interactive demo of OGNL and JSP tags</a></li>
|
||||
<li><a href="<s:url value="/ajax/index.jsp" />">Ajax pugin for Struts</a></li>
|
||||
<li><a href="<s:url value="/ajax/index.jsp" />">Ajax plugin for Struts</a></li>
|
||||
<li><a href="<s:url value="/chat/index.jsp"/>">Ajax Chat</a>
|
||||
<li><a href="<s:url action="actionChain1!input" namespace="/actionchaining" includeParams="none" />">Action Chaining</a></li>
|
||||
<li><a href="<s:url action="index" namespace="/config-browser" includeParams="none" />">Config Browser</a></li>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<body>
|
||||
<table>
|
||||
<sx:datetimepicker label="toggleType='wipe'" value="%{'2006-10-31'}" toggleType="wipe" toggleDuration="300" name="test"/>
|
||||
<sx:datetimepicker label="toggleType='explode'" value="%{'2006-07-22'}" toggleType="explode" toggleDuration="500"/>
|
||||
<sx:datetimepicker label="toggleType='explode'" value="%{'2006-07-22'}" toggleType="explode" toggleDuration="500" id="dp2"/>
|
||||
<sx:datetimepicker label="toggleType='fade'" value="%{'2006-06-30'}" toggleType="fade" toggleDuration="500"/>
|
||||
<sx:datetimepicker label="With value='today'" name="dddp1" value="%{'today'}" />
|
||||
<sx:datetimepicker label="US format, empty" name="dddp2" language="en-us" />
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
dojo.event.topic.subscribe("treeSelected", function treeNodeSelected(node) {
|
||||
dojo.io.bind({
|
||||
url: "<s:url value='/tags/ui/ajax/dynamicTreeSelectAction.action'/>&nodeId="+node.node.widgetId,
|
||||
url: "<s:url value='/tags/ui/ajax/dynamicTreeSelectAction.action'/>?nodeId="+node.node.widgetId,
|
||||
load: function(type, data, evt) {
|
||||
var divDisplay = dojo.byId("displayId");
|
||||
divDisplay.innerHTML=data;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Showcase - UI Tag Example - Tree Example (Static)</title>
|
||||
<sx:head />
|
||||
<sx:head/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
dojo.event.topic.subscribe("treeSelected", function treeNodeSelected(node) {
|
||||
dojo.io.bind({
|
||||
url: "<s:url value='/tags/ui/ajax/staticTreeSelectAction.action'/>&nodeId="+node.node.title,
|
||||
url: "<s:url value='/tags/ui/ajax/staticTreeSelectAction.action'/>?nodeId="+node.node.title,
|
||||
load: function(type, data, evt) {
|
||||
var divDisplay = dojo.byId("displayIt");
|
||||
divDisplay.innerHTML=data;
|
||||
@@ -24,9 +24,9 @@
|
||||
|
||||
|
||||
<div style="float:left; margin-right: 50px;">
|
||||
<sx:tree label="parent" id="parentId" templateCssPath="/struts/tree.css"
|
||||
<sx:tree label="parent" templateCssPath="/struts/tree.css"
|
||||
showRootGrid="true" showGrid="true" treeSelectedTopic="treeSelected">
|
||||
<sx:treenode label="child1" id="child1Id">
|
||||
<sx:treenode label="child1" >
|
||||
<sx:treenode label="grandchild1" id="grandchild1Id"/>
|
||||
<sx:treenode label="grandchild2" id="grandchild2Id"/>
|
||||
<sx:treenode label="grandchild3" id="grandchild3Id"/>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Validation -Ajax</title>
|
||||
<sx:head cache="true" compressed="false"/>
|
||||
<title>Validation - Ajax</title>
|
||||
<sx:head cache="false" compressed="false"/>
|
||||
</head>
|
||||
|
||||
<s:url var="url" namespace="/validation" action="quizAjax"/>
|
||||
|
||||
+1
-1
@@ -383,7 +383,7 @@
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<version>1.0-alpha-10-SNAPSHOT</version>
|
||||
<version>1.0-alpha-10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
+44
-5
@@ -1,4 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<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>
|
||||
@@ -22,7 +44,7 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.0-alpha-1-SNAPSHOT</version>
|
||||
<version>2.0-alpha-4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack-xwork</id>
|
||||
@@ -33,7 +55,7 @@
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>opensymphony</groupId>
|
||||
<groupId>com.opensymphony.xwork</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
<classifier>sources</classifier>
|
||||
@@ -48,7 +70,7 @@
|
||||
<groupId>org.apache.myfaces.tobago</groupId>
|
||||
<artifactId>maven-apt-plugin</artifactId>
|
||||
<configuration>
|
||||
<A>uri=/struts-tags,tlibVersion=2.2.3,jspVersion=1.2,shortName=s,displayName="Struts Tags",
|
||||
<A>uri=/struts-tags,tlibVersion=2.2.3,jspVersion=2.0,shortName=s,displayName="Struts Tags",
|
||||
outFile=${basedir}/target/classes/META-INF/struts-tags.tld,
|
||||
description="To make it easier to access dynamic data;
|
||||
the Apache Struts framework includes a library of custom tags.
|
||||
@@ -107,6 +129,23 @@
|
||||
</links>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>rat-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-2</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>pom.xml</include>
|
||||
<include>src/**</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>src/test/resources/org/apache/struts2/views/jsp/ui/*</exclude>
|
||||
<exclude>src/main/resources/org/apache/struts2/static/domTT.js</exclude>
|
||||
<exclude>src/test/resources/org/apache/struts2/interceptor/validation/*</exclude>
|
||||
<exclude>src/site/resources/tags/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
@@ -250,7 +289,7 @@
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>opensymphony</groupId>
|
||||
<groupId>com.opensymphony.xwork</groupId>
|
||||
<artifactId>xwork</artifactId>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
@@ -446,7 +485,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts-annotations</artifactId>
|
||||
<version>1.0.2-SNAPSHOT</version>
|
||||
<version>1.0.2</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -161,5 +161,8 @@ public final class StrutsConstants {
|
||||
|
||||
/** The name of the parameter to create when mapping an id (used by some action mappers) */
|
||||
public static final String STRUTS_ID_PARAMETER_NAME = "struts.mapper.idParameterName";
|
||||
|
||||
/** The name of the parameter to determine whether static method access will be allowed in OGNL expressions or not */
|
||||
public static final String STRUTS_ALLOW_STATIC_METHOD_ACCESS = "struts.ognl.allowStaticMethodAccess";
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* <!-- START SNIPPET: example -->
|
||||
*
|
||||
* <s:actionerror />
|
||||
* <s:form .... >>
|
||||
* <s:form .... >
|
||||
* ....
|
||||
* </s:form>
|
||||
*
|
||||
|
||||
@@ -46,7 +46,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="a", tldTagClass="org.apache.struts2.views.jsp.ui.AnchorTag", description="Render a HTML href element that when clicked can optionally call a URL via remote XMLHttpRequest and updates its targets")
|
||||
@StrutsTag(
|
||||
name="a",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.AnchorTag",
|
||||
description="Render a HTML href element that when clicked can optionally call a URL via remote XMLHttpRequest and updates its targets",
|
||||
allowDynamicAttributes=true)
|
||||
public class Anchor extends ClosingUIBean {
|
||||
public static final String OPEN_TEMPLATE = "a";
|
||||
public static final String TEMPLATE = "a-close";
|
||||
|
||||
@@ -50,7 +50,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="checkbox", tldTagClass="org.apache.struts2.views.jsp.ui.CheckboxTag", description="Render a checkbox input field")
|
||||
@StrutsTag(
|
||||
name="checkbox",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.CheckboxTag",
|
||||
description="Render a checkbox input field",
|
||||
allowDynamicAttributes=true)
|
||||
public class Checkbox extends UIBean {
|
||||
final public static String TEMPLATE = "checkbox";
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the name of this component.
|
||||
* Gets the name of this component.
|
||||
* @return the name of this component.
|
||||
*/
|
||||
private String getComponentName() {
|
||||
@@ -86,7 +86,7 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the OGNL value stack assoicated with this component.
|
||||
* Gets the OGNL value stack assoicated with this component.
|
||||
* @return the OGNL value stack assoicated with this component.
|
||||
*/
|
||||
public ValueStack getStack() {
|
||||
@@ -94,7 +94,7 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the component stack of this component.
|
||||
* Gets the component stack of this component.
|
||||
* @return the component stack of this component, never <tt>null</tt>.
|
||||
*/
|
||||
public Stack getComponentStack() {
|
||||
@@ -214,7 +214,7 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs?a <code>RuntimeException</code> based on the given information.
|
||||
* Constructs a <code>RuntimeException</code> based on the given information.
|
||||
* <p/>
|
||||
* A message is constructed and logged at ERROR level before being returned
|
||||
* as a <code>RuntimeException</code>.
|
||||
@@ -333,16 +333,20 @@ public class Component {
|
||||
* @param scheme http or https
|
||||
* @param includeContext should the context path be included or not
|
||||
* @param encodeResult should the url be encoded
|
||||
* @param forceAddSchemeHostAndPort should the scheme host and port be forced
|
||||
* @param escapeAmp should ampersand (&) be escaped to &
|
||||
* @return the action url.
|
||||
*/
|
||||
protected String determineActionURL(String action, String namespace, String method,
|
||||
HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme,
|
||||
boolean includeContext, boolean encodeResult) {
|
||||
boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort,
|
||||
boolean escapeAmp) {
|
||||
String finalAction = findString(action);
|
||||
String finalMethod = method != null ? findString(method) : method;
|
||||
String finalNamespace = determineNamespace(namespace, getStack(), req);
|
||||
ActionMapping mapping = new ActionMapping(finalAction, finalNamespace, method, parameters);
|
||||
ActionMapping mapping = new ActionMapping(finalAction, finalNamespace, finalMethod, parameters);
|
||||
String uri = actionMapper.getUriFromActionMapping(mapping);
|
||||
return UrlHelper.buildUrl(uri, req, res, parameters, scheme, includeContext, encodeResult);
|
||||
return UrlHelper.buildUrl(uri, req, res, parameters, scheme, includeContext, encodeResult, forceAddSchemeHostAndPort, escapeAmp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,7 +410,7 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get's the parameters.
|
||||
* Gets the parameters.
|
||||
* @return the parameters. Is never <tt>null</tt>.
|
||||
*/
|
||||
public Map getParameters() {
|
||||
@@ -414,7 +418,7 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add's all the given parameters to this componenets own parameters.
|
||||
* Adds all the given parameters to this component's own parameters.
|
||||
* @param params the parameters to add.
|
||||
*/
|
||||
public void addAllParameters(Map params) {
|
||||
@@ -422,9 +426,9 @@ public class Component {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add's the given key and value to this components own parameter.
|
||||
* Adds the given key and value to this component's own parameter.
|
||||
* <p/>
|
||||
* If the provided key is <tt>null</tt> nothing happends.
|
||||
* If the provided key is <tt>null</tt> nothing happens.
|
||||
* If the provided value is <tt>null</tt> any existing parameter with
|
||||
* the given key name is removed.
|
||||
* @param key the key of the new parameter to add.
|
||||
@@ -449,5 +453,4 @@ public class Component {
|
||||
public boolean usesBody() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* <!-- END SNIPPET: javadoc -->
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="div", tldTagClass="org.apache.struts2.views.jsp.ui.DivTag", description="Render HTML div providing content from remote call via AJAX")
|
||||
@StrutsTag(
|
||||
name="div",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.DivTag",
|
||||
description="Render an HTML div",
|
||||
allowDynamicAttributes=true)
|
||||
public class Div extends ClosingUIBean {
|
||||
|
||||
public static final String TEMPLATE = "div";
|
||||
|
||||
@@ -51,7 +51,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* <s:param>field1</s:param>
|
||||
* <s:param>field2</s:param>
|
||||
* </s:fielderror>
|
||||
* <s:form .... >>
|
||||
* <s:form .... >
|
||||
* ....
|
||||
* </s:form>
|
||||
*
|
||||
@@ -61,7 +61,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* <s:param value="%{'field1'}" />
|
||||
* <s:param value="%{'field2'}" />
|
||||
* </s:fielderror>
|
||||
* <s:form .... >>
|
||||
* <s:form .... >
|
||||
* ....
|
||||
* </s:form>
|
||||
*
|
||||
|
||||
@@ -45,7 +45,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="file", tldTagClass="org.apache.struts2.views.jsp.ui.FileTag", description="Render a file input field")
|
||||
@StrutsTag(
|
||||
name="file",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.FileTag",
|
||||
description="Render a file input field",
|
||||
allowDynamicAttributes=true)
|
||||
public class File extends UIBean {
|
||||
private final static Log log = LogFactory.getLog(File.class);
|
||||
|
||||
|
||||
@@ -20,26 +20,6 @@
|
||||
*/
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
//import org.apache.struts2.portlet.context.PortletActionContext;
|
||||
//import org.apache.struts2.portlet.util.PortletUrlHelper;
|
||||
import org.apache.struts2.views.util.UrlHelper;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ObjectFactory;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.RuntimeConfiguration;
|
||||
@@ -48,11 +28,18 @@ import com.opensymphony.xwork2.config.entities.InterceptorMapping;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptorUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.TextUtils;
|
||||
import com.opensymphony.xwork2.validator.ActionValidatorManagerFactory;
|
||||
import com.opensymphony.xwork2.validator.FieldValidator;
|
||||
import com.opensymphony.xwork2.validator.ValidationInterceptor;
|
||||
import com.opensymphony.xwork2.validator.Validator;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
@@ -93,7 +80,11 @@ import com.opensymphony.xwork2.validator.Validator;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="form", tldTagClass="org.apache.struts2.views.jsp.ui.FormTag", description="Renders an input form")
|
||||
@StrutsTag(
|
||||
name="form",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.FormTag",
|
||||
description="Renders an input form",
|
||||
allowDynamicAttributes=true)
|
||||
public class Form extends ClosingUIBean {
|
||||
public static final String OPEN_TEMPLATE = "form";
|
||||
public static final String TEMPLATE = "form-close";
|
||||
@@ -222,32 +213,26 @@ public class Form extends ClosingUIBean {
|
||||
* </ol>
|
||||
*/
|
||||
protected void populateComponentHtmlId(Form form) {
|
||||
boolean isAjax = "ajax".equalsIgnoreCase(this.theme);
|
||||
|
||||
String action = null;
|
||||
if (this.action != null) {
|
||||
// if it isn't specified, we'll make somethig up
|
||||
action = findString(this.action);
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
addParameter("id", escape(id));
|
||||
}
|
||||
|
||||
// if no id given, it will be tried to generate it from the action attribute
|
||||
// by the urlRenderer implementation
|
||||
urlRenderer.renderFormUrl(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isAjax
|
||||
* @param namespace
|
||||
* @param action
|
||||
* Evaluate client side JavaScript Enablement.
|
||||
* @param actionName the actioName to check for
|
||||
* @param namespace the namespace to check for
|
||||
* @param actionMethod the method to ckeck for
|
||||
*/
|
||||
|
||||
|
||||
protected void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod) {
|
||||
|
||||
// Only evaluate if Client-Side js is to be enable when validate=true
|
||||
Boolean validate = (Boolean) getParameters().get("validate");
|
||||
if (validate != null && validate.booleanValue()) {
|
||||
if (validate != null && validate) {
|
||||
|
||||
addParameter("performValidation", Boolean.FALSE);
|
||||
|
||||
@@ -255,9 +240,8 @@ public class Form extends ClosingUIBean {
|
||||
ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
|
||||
|
||||
if (actionConfig != null) {
|
||||
List interceptors = actionConfig.getInterceptors();
|
||||
for (Iterator i = interceptors.iterator(); i.hasNext();) {
|
||||
InterceptorMapping interceptorMapping = (InterceptorMapping) i.next();
|
||||
List<InterceptorMapping> interceptors = actionConfig.getInterceptors();
|
||||
for (InterceptorMapping interceptorMapping : interceptors) {
|
||||
if (ValidationInterceptor.class.isInstance(interceptorMapping.getInterceptor())) {
|
||||
ValidationInterceptor validationInterceptor = (ValidationInterceptor) interceptorMapping.getInterceptor();
|
||||
|
||||
@@ -280,10 +264,9 @@ public class Form extends ClosingUIBean {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
List all = ActionValidatorManagerFactory.getInstance().getValidators(actionClass, (String) getParameters().get("actionName"));
|
||||
List validators = new ArrayList();
|
||||
for (Iterator iterator = all.iterator(); iterator.hasNext();) {
|
||||
Validator validator = (Validator) iterator.next();
|
||||
List<Validator> all = ActionValidatorManagerFactory.getInstance().getValidators(actionClass, (String) getParameters().get("actionName"));
|
||||
List<Validator> validators = new ArrayList<Validator>();
|
||||
for (Validator validator : all) {
|
||||
if (validator instanceof FieldValidator) {
|
||||
FieldValidator fieldValidator = (FieldValidator) validator;
|
||||
if (fieldValidator.getFieldName().equals(name)) {
|
||||
@@ -311,7 +294,7 @@ public class Form extends ClosingUIBean {
|
||||
this.onsubmit = onsubmit;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Set action nane to submit to, without .action suffix", defaultValue="current action")
|
||||
@StrutsTagAttribute(description="Set action name to submit to, without .action suffix", defaultValue="current action")
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
@@ -342,7 +325,7 @@ public class Form extends ClosingUIBean {
|
||||
this.validate = validate;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="he portlet mode to display after the form submit")
|
||||
@StrutsTagAttribute(description="The portlet mode to display after the form submit")
|
||||
public void setPortletMode(String portletMode) {
|
||||
this.portletMode = portletMode;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="hidden", tldTagClass="org.apache.struts2.views.jsp.ui.HiddenTag", description="Render a hidden input field")
|
||||
@StrutsTag(
|
||||
name="hidden",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.HiddenTag",
|
||||
description="Render a hidden input field",
|
||||
allowDynamicAttributes=true)
|
||||
public class Hidden extends UIBean {
|
||||
final public static String TEMPLATE = "hidden";
|
||||
|
||||
|
||||
@@ -53,8 +53,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="label", tldTagClass="org.apache.struts2.views.jsp.ui.LabelTag", description="Render a label that displays" +
|
||||
" read-only information")
|
||||
@StrutsTag(
|
||||
name="label",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.LabelTag",
|
||||
description="Render a label that displays read-only information",
|
||||
allowDynamicAttributes=true)
|
||||
public class Label extends UIBean {
|
||||
final public static String TEMPLATE = "label";
|
||||
|
||||
|
||||
@@ -71,7 +71,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="optgroup", tldTagClass="org.apache.struts2.views.jsp.ui.OptGroupTag", description="Renders a Select Tag's OptGroup Tag")
|
||||
@StrutsTag(
|
||||
name="optgroup",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.OptGroupTag",
|
||||
description="Renders a Select Tag's OptGroup Tag",
|
||||
allowDynamicAttributes=true)
|
||||
public class OptGroup extends Component {
|
||||
|
||||
public static final String INTERNAL_LIST_UI_BEAN_LIST_PARAMETER_KEY = "optGroupInternalListUiBeanList";
|
||||
|
||||
@@ -46,7 +46,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="password", tldTagClass="org.apache.struts2.views.jsp.ui.PasswordTag", description="Render an HTML input tag of type password")
|
||||
@StrutsTag(
|
||||
name="password",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.PasswordTag",
|
||||
description="Render an HTML input tag of type password",
|
||||
allowDynamicAttributes=true)
|
||||
public class Password extends TextField {
|
||||
final public static String TEMPLATE = "password";
|
||||
|
||||
|
||||
@@ -56,7 +56,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="reset", tldTagClass="org.apache.struts2.views.jsp.ui.ResetTag", description="Render a reset button")
|
||||
@StrutsTag(
|
||||
name="reset",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.ResetTag",
|
||||
description="Render a reset button",
|
||||
allowDynamicAttributes=true)
|
||||
public class Reset extends FormButton {
|
||||
final public static String TEMPLATE = "reset";
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* multiple="true"
|
||||
* size="3"
|
||||
* required="true"
|
||||
* value="%{petDao.pets.{id}}"
|
||||
* />
|
||||
*
|
||||
* <s:select label="Months"
|
||||
@@ -77,7 +78,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* <!-- END SNIPPET: exnote -->
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="select", tldTagClass="org.apache.struts2.views.jsp.ui.SelectTag", description="Render a select element")
|
||||
@StrutsTag(
|
||||
name="select",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.SelectTag",
|
||||
description="Render a select element",
|
||||
allowDynamicAttributes=true)
|
||||
public class Select extends ListUIBean {
|
||||
final public static String TEMPLATE = "select";
|
||||
|
||||
@@ -132,8 +137,8 @@ public class Select extends ListUIBean {
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description=" Creates a multiple select. The tag will pre-select multiple values" +
|
||||
" if the values are passed as an Array (of appropriate types) via the value attribute. Passing " +
|
||||
"a Collection may work too? Haven't tested this.", type="Boolean", defaultValue="false")
|
||||
" if the values are passed as an Array or a Collection(of appropriate types) via the value attribute. If one of the keys equals" +
|
||||
" one of the values in the Collection or Array it wil be selected", type="Boolean", defaultValue="false")
|
||||
public void setMultiple(String multiple) {
|
||||
this.multiple = multiple;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.components;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.dispatcher.mapper.ActionMapping;
|
||||
import org.apache.struts2.views.util.UrlHelper;
|
||||
@@ -16,6 +38,11 @@ import com.opensymphony.xwork2.config.entities.ActionConfig;
|
||||
*
|
||||
*/
|
||||
public class ServletUrlRenderer implements UrlRenderer {
|
||||
/**
|
||||
* Provide a logging instance.
|
||||
*/
|
||||
private static final Log LOG = LogFactory.getLog(ServletUrlRenderer.class);
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -29,7 +56,7 @@ public class ServletUrlRenderer implements UrlRenderer {
|
||||
|
||||
String result;
|
||||
if (urlComponent.value == null && urlComponent.action != null) {
|
||||
result = urlComponent.determineActionURL(urlComponent.action, urlComponent.namespace, urlComponent.method, urlComponent.req, urlComponent.res, urlComponent.parameters, scheme, urlComponent.includeContext, urlComponent.encode);
|
||||
result = urlComponent.determineActionURL(urlComponent.action, urlComponent.namespace, urlComponent.method, urlComponent.req, urlComponent.res, urlComponent.parameters, scheme, urlComponent.includeContext, urlComponent.encode, urlComponent.forceAddSchemeHostAndPort, urlComponent.escapeAmp);
|
||||
} else {
|
||||
String _value = urlComponent.value;
|
||||
|
||||
@@ -38,7 +65,7 @@ public class ServletUrlRenderer implements UrlRenderer {
|
||||
if (_value != null && _value.indexOf("?") > 0) {
|
||||
_value = _value.substring(0, _value.indexOf("?"));
|
||||
}
|
||||
result = UrlHelper.buildUrl(_value, urlComponent.req, urlComponent.res, urlComponent.parameters, scheme, urlComponent.includeContext, urlComponent.encode);
|
||||
result = UrlHelper.buildUrl(_value, urlComponent.req, urlComponent.res, urlComponent.parameters, scheme, urlComponent.includeContext, urlComponent.encode, urlComponent.forceAddSchemeHostAndPort, urlComponent.escapeAmp);
|
||||
}
|
||||
if ( urlComponent.anchor != null && urlComponent.anchor.length() > 0 ) {
|
||||
result += '#' + urlComponent.anchor;
|
||||
@@ -66,13 +93,11 @@ public class ServletUrlRenderer implements UrlRenderer {
|
||||
public void renderFormUrl(Form formComponent) {
|
||||
String namespace = formComponent.determineNamespace(formComponent.namespace, formComponent.getStack(),
|
||||
formComponent.request);
|
||||
String action = null;
|
||||
String action;
|
||||
|
||||
if(formComponent.action != null) {
|
||||
action = formComponent.findString(formComponent.action);
|
||||
}
|
||||
|
||||
if (formComponent.action == null) {
|
||||
} else {
|
||||
// no action supplied? ok, then default to the current request
|
||||
// (action or general URL)
|
||||
ActionInvocation ai = (ActionInvocation) formComponent.getStack().getContext().get(
|
||||
@@ -127,15 +152,19 @@ public class ServletUrlRenderer implements UrlRenderer {
|
||||
}
|
||||
|
||||
// if the id isn't specified, use the action name
|
||||
if (formComponent.getId() == null) {
|
||||
formComponent.addParameter("id", action);
|
||||
if (formComponent.getId() == null && action!=null ) {
|
||||
formComponent.addParameter("id", formComponent.escape(action));
|
||||
}
|
||||
} else if (action != null) {
|
||||
// Since we can't find an action alias in the configuration, we just
|
||||
// assume
|
||||
// the action attribute supplied is the path to be used as the uri
|
||||
// this
|
||||
// form is submitting to.
|
||||
// assume the action attribute supplied is the path to be used as
|
||||
// the URI this form is submitting to.
|
||||
|
||||
// Warn user that the specified namespace/action combo
|
||||
// was not found in the configuration.
|
||||
if (namespace != null) {
|
||||
LOG.warn("No configuration found for the specified action: '" + action + "' in namespace: '" + namespace + "'. Form action defaulting to 'action' attribute's literal value.");
|
||||
}
|
||||
|
||||
String result = UrlHelper.buildUrl(action, formComponent.request, formComponent.response, null);
|
||||
formComponent.addParameter("action", result);
|
||||
@@ -165,9 +194,7 @@ public class ServletUrlRenderer implements UrlRenderer {
|
||||
|
||||
// WW-1284
|
||||
// evaluate if client-side js is to be enabled. (if validation
|
||||
// interceptor
|
||||
// does allow validation eg. method is not filtered out)
|
||||
// interceptor does allow validation eg. method is not filtered out)
|
||||
formComponent.evaluateClientSideJsEnablement(actionName, namespace, actionMethod);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* text shown on the button face, but has issues with Microsoft Internet Explorer at least up to 6.0
|
||||
* <!-- END SNIPPET: javadoc -->
|
||||
*/
|
||||
@StrutsTag(name="submit", tldTagClass="org.apache.struts2.views.jsp.ui.SubmitTag", description="Render a submit button")
|
||||
@StrutsTag(
|
||||
name="submit",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.SubmitTag",
|
||||
description="Render a submit button",
|
||||
allowDynamicAttributes=true)
|
||||
public class Submit extends FormButton {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Submit.class);
|
||||
|
||||
@@ -113,7 +113,11 @@ import com.opensymphony.xwork2.TextProvider;
|
||||
* @see Param
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="text", tldTagClass="org.apache.struts2.views.jsp.TextTag", description="Render a I18n text message")
|
||||
@StrutsTag(
|
||||
name="text",
|
||||
tldTagClass="org.apache.struts2.views.jsp.TextTag",
|
||||
description="Render a I18n text message",
|
||||
allowDynamicAttributes=true)
|
||||
public class Text extends ContextBean implements Param.UnnamedParametric {
|
||||
private static final Log LOG = LogFactory.getLog(Text.class);
|
||||
|
||||
|
||||
@@ -44,7 +44,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* @see TabbedPanel
|
||||
*
|
||||
*/
|
||||
@StrutsTag(name="textarea", tldTagClass="org.apache.struts2.views.jsp.ui.TextareaTag", description="Render HTML textarea tag.")
|
||||
@StrutsTag(
|
||||
name="textarea",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.TextareaTag",
|
||||
description="Render HTML textarea tag.",
|
||||
allowDynamicAttributes=true)
|
||||
public class TextArea extends UIBean {
|
||||
final public static String TEMPLATE = "textarea";
|
||||
|
||||
|
||||
@@ -51,7 +51,11 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </pre>
|
||||
|
||||
*/
|
||||
@StrutsTag(name="textfield", tldTagClass="org.apache.struts2.views.jsp.ui.TextFieldTag", description="Render an HTML input field of type text")
|
||||
@StrutsTag(
|
||||
name="textfield",
|
||||
tldTagClass="org.apache.struts2.views.jsp.ui.TextFieldTag",
|
||||
description="Render an HTML input field of type text",
|
||||
allowDynamicAttributes=true)
|
||||
public class TextField extends UIBean {
|
||||
/**
|
||||
* The name of the default template for the TextFieldTag
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -310,7 +311,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
*
|
||||
*
|
||||
* <!-- START SNIPPET: tooltipdescription -->
|
||||
* <b>tooltipConfig is deprecated, use individual tooltip configuration attributes instead </>
|
||||
* <b>tooltipConfig is deprecated, use individual tooltip configuration attributes instead </b>
|
||||
*
|
||||
* Every Form UI component (in xhtml / css_xhtml or any other that extends them) can
|
||||
* have tooltips assigned to them. The Form component's tooltip related attribute, once
|
||||
@@ -465,6 +466,9 @@ public abstract class UIBean extends Component {
|
||||
protected String tooltipDelay;
|
||||
protected String tooltipCssClass;
|
||||
protected String tooltipIconPath;
|
||||
|
||||
// dynamic attributes
|
||||
protected Map<String,Object> dynamicAttributes = new HashMap<String,Object>();
|
||||
|
||||
protected String defaultTemplateDir;
|
||||
protected String defaultUITheme;
|
||||
@@ -760,9 +764,6 @@ public abstract class UIBean extends Component {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tooltip & tooltipConfig
|
||||
if (tooltipConfig != null) {
|
||||
addParameter("tooltipConfig", findValue(tooltipConfig));
|
||||
@@ -821,8 +822,10 @@ public abstract class UIBean extends Component {
|
||||
|
||||
|
||||
}
|
||||
evaluateExtraParams();
|
||||
|
||||
addParameter("dynamicAttributes", dynamicAttributes);
|
||||
|
||||
evaluateExtraParams();
|
||||
}
|
||||
|
||||
protected String escape(String name) {
|
||||
@@ -902,7 +905,8 @@ public abstract class UIBean extends Component {
|
||||
|
||||
/**
|
||||
* Create HTML id element for the component and populate this component parmaeter
|
||||
* map.
|
||||
* map. Additionally, a parameter named escapedId is populated which contains the found id value filtered by
|
||||
* {@link #escape(String)}, needed eg. for naming Javascript identifiers based on the id value.
|
||||
*
|
||||
* The order is as follows :-
|
||||
* <ol>
|
||||
@@ -914,21 +918,24 @@ public abstract class UIBean extends Component {
|
||||
* @param form
|
||||
*/
|
||||
protected void populateComponentHtmlId(Form form) {
|
||||
String tryId;
|
||||
if (id != null) {
|
||||
// this check is needed for backwards compatibility with 2.1.x
|
||||
if (altSyntax()) {
|
||||
addParameter("id", findString(id));
|
||||
tryId = findString(id);
|
||||
} else {
|
||||
addParameter("id", id);
|
||||
tryId = id;
|
||||
}
|
||||
} else if (form != null) {
|
||||
addParameter("id", form.getParameters().get("id") + "_"
|
||||
+ escape(name != null ? findString(name) : null));
|
||||
tryId = form.getParameters().get("id") + "_"
|
||||
+ escape(name != null ? findString(name) : null);
|
||||
} else {
|
||||
addParameter("id", escape(name != null ? findString(name) : null));
|
||||
tryId = escape(name != null ? findString(name) : null);
|
||||
}
|
||||
addParameter("id", tryId);
|
||||
addParameter("escapedId", escape(tryId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get's the id for referencing element.
|
||||
* @return the id for referencing element.
|
||||
@@ -968,7 +975,7 @@ public abstract class UIBean extends Component {
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="The css style definitions for element ro use")
|
||||
@StrutsTagAttribute(description="The css style definitions for element to use")
|
||||
public void setCssStyle(String cssStyle) {
|
||||
this.cssStyle = cssStyle;
|
||||
}
|
||||
@@ -1133,4 +1140,8 @@ public abstract class UIBean extends Component {
|
||||
public void setTooltipIconPath(String tooltipIconPath) {
|
||||
this.tooltipIconPath = tooltipIconPath;
|
||||
}
|
||||
|
||||
public void setDynamicAttributes(Map<String,Object> dynamicAttributes) {
|
||||
this.dynamicAttributes = dynamicAttributes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
*/
|
||||
package org.apache.struts2.components;
|
||||
|
||||
import java.io.IOException;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
@@ -32,16 +34,11 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.annotations.StrutsTag;
|
||||
import org.apache.struts2.views.annotations.StrutsTagAttribute;
|
||||
import org.apache.struts2.StrutsException;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.dispatcher.Dispatcher;
|
||||
import org.apache.struts2.views.util.UrlHelper;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
*
|
||||
@@ -52,6 +49,12 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* an Iterable all the values will be added to the URL.</p>
|
||||
*
|
||||
* <b>NOTE:</b>
|
||||
* <p>By default request parameters will be separated using escaped ampersands (i.e., &amp;).
|
||||
* This is necessary for XHTML compliance, however, when using the URL generated by this tag
|
||||
* with the <s:property> tag, the <b>escapeAmp</b> attribute should be used to disable
|
||||
* ampersand escaping.</p>
|
||||
*
|
||||
* <b>NOTE:</b>
|
||||
* <p>When includeParams is 'all' or 'get', the parameter defined in <param> tag will take
|
||||
* precedence and will not be overriden if they exists in the parameter submitted. For
|
||||
* example, in Example 3 below, if there is a id parameter in the url where the page this
|
||||
@@ -67,16 +70,21 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* <ul>
|
||||
* <li>action (String) - (value or action choose either one, if both exist value takes precedence) action's name (alias) <li>
|
||||
* <li>value (String) - (value or action choose either one, if both exist value takes precedence) the url itself</li>
|
||||
* <li>scheme (String) - http scheme (http, https) default to the scheme this request is in</li>
|
||||
* <li>scheme (String) - http scheme (http, https) defaults to the scheme this request is in</li>
|
||||
* <li>namespace - action's namespace</li>
|
||||
* <li>method (String) - action's method, default to execute() </li>
|
||||
* <li>encode (Boolean) - url encode the generated url. Default is true</li>
|
||||
* <li>includeParams (String) - The includeParams attribute may have the value 'none', 'get' or 'all'. Default is 'get'.
|
||||
* <li>method (String) - action's method name, defaults to 'execute'</li>
|
||||
* <li>encode (Boolean) - url encode the generated url. Defaults to 'true'.</li>
|
||||
* <li>includeParams (String) - The includeParams attribute may have the value 'none', 'get' or 'all'. Defaults to 'get'.
|
||||
* none - include no parameters in the URL
|
||||
* get - include only GET parameters in the URL (default)
|
||||
* all - include both GET and POST parameters in the URL
|
||||
* </li>
|
||||
* <li>includeContext (Boolean) - determine wheather to include the web app context path. Default is true.</li>
|
||||
* <li>includeContext (Boolean) - Specifies whether to include the web app context path. Defaults to 'true'.</li>
|
||||
* <li>escapeAmp (Boolean) - Specifies whether to escape ampersand (&) to (&amp;) or not. Defaults to 'true'.</li>
|
||||
* <li>portletMode (String) - The resulting portlet mode.</li>
|
||||
* <li>windowState (String) - The resulting portlet window state.</li>
|
||||
* <li>portletUrlType (String) - Specifies if this should be a portlet render or action URL.</li>
|
||||
* <li>forceAddSchemeHostAndPort (Boolean) - Specifies whether to force the addition of scheme, host and port or not.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <!-- END SNIPPET: params -->
|
||||
@@ -96,7 +104,7 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* </s:url>
|
||||
*
|
||||
* <-- Example 3-->
|
||||
* <s:url includeParams="get" >
|
||||
* <s:url includeParams="get">
|
||||
* <s:param name="id" value="%{'22'}" />
|
||||
* </s:url>
|
||||
*
|
||||
@@ -134,10 +142,12 @@ public class URL extends ContextBean {
|
||||
protected String method;
|
||||
protected boolean encode = true;
|
||||
protected boolean includeContext = true;
|
||||
protected boolean escapeAmp = true;
|
||||
protected String portletMode;
|
||||
protected String windowState;
|
||||
protected String portletUrlType;
|
||||
protected String anchor;
|
||||
protected boolean forceAddSchemeHostAndPort;
|
||||
protected String urlIncludeParams;
|
||||
protected ExtraParameterProvider extraParameterProvider;
|
||||
protected UrlRenderer urlRenderer;
|
||||
@@ -285,7 +295,7 @@ public class URL extends ContextBean {
|
||||
this.windowState = windowState;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Specifies if this should be a portlet render or action URL")
|
||||
@StrutsTagAttribute(description="Specifies if this should be a portlet render or action URL. Default is \"render\". To create an action URL, use \"action\".")
|
||||
public void setPortletUrlType(String portletUrlType) {
|
||||
this.portletUrlType = portletUrlType;
|
||||
}
|
||||
@@ -294,6 +304,16 @@ public class URL extends ContextBean {
|
||||
public void setAnchor(String anchor) {
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Specifies whether to escape ampersand (&) to (&amp;) or not", type="Boolean", defaultValue="true")
|
||||
public void setEscapeAmp(boolean escapeAmp) {
|
||||
this.escapeAmp = escapeAmp;
|
||||
}
|
||||
|
||||
@StrutsTagAttribute(description="Specifies whether to force the addition of scheme, host and port or not", type="Boolean", defaultValue="false")
|
||||
public void setForceAddSchemeHostAndPort(boolean forceAddSchemeHostAndPort) {
|
||||
this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id: AttributeMap.java 471756 2006-11-06 15:01:43Z husted $
|
||||
*
|
||||
* 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.components;
|
||||
|
||||
import java.io.Writer;
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class BaseTemplateEngine implements TemplateEngine {
|
||||
if (props == null) {
|
||||
String propName = template.getDir() + "/" + template.getTheme() + "/"+getThemePropertiesFileName();
|
||||
|
||||
// WW-1292
|
||||
// WW-1292
|
||||
// let's try getting it from the filesystem
|
||||
File propFile = new File(propName);
|
||||
InputStream is = null;
|
||||
@@ -77,6 +77,12 @@ public abstract class BaseTemplateEngine implements TemplateEngine {
|
||||
props.load(is);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Could not load " + propName, e);
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch(IOException io) {
|
||||
LOG.warn("Unable to close input stream", io);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-27
@@ -20,32 +20,28 @@
|
||||
*/
|
||||
package org.apache.struts2.components.template;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.SimpleHash;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.SimpleHash;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Freemarker based template engine.
|
||||
@@ -54,8 +50,8 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine {
|
||||
static Class bodyContent = null;
|
||||
private FreemarkerManager freemarkerManager;
|
||||
|
||||
private HashMap<String, freemarker.template.Template> templates = new HashMap<String, freemarker.template.Template>();
|
||||
private HashSet<String> missingTemplates = new HashSet<String>();
|
||||
private final HashMap<String, freemarker.template.Template> templates = new HashMap<String, freemarker.template.Template>();
|
||||
private final HashSet<String> missingTemplates = new HashSet<String>();
|
||||
private boolean freemarkerCaching = false;
|
||||
|
||||
static {
|
||||
@@ -89,14 +85,13 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine {
|
||||
Configuration config = freemarkerManager.getConfiguration(servletContext);
|
||||
|
||||
// get the list of templates we can use
|
||||
List templates = templateContext.getTemplate().getPossibleTemplates(this);
|
||||
List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this);
|
||||
|
||||
// find the right template
|
||||
freemarker.template.Template template = null;
|
||||
String templateName = null;
|
||||
Exception exception = null;
|
||||
for (Iterator iterator = templates.iterator(); iterator.hasNext();) {
|
||||
Template t = (Template) iterator.next();
|
||||
for (Template t : templates) {
|
||||
templateName = getFinalTemplateName(t);
|
||||
if (freemarkerCaching) {
|
||||
if (!isTemplateMissing(templateName)) {
|
||||
@@ -202,14 +197,14 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine {
|
||||
|
||||
protected freemarker.template.Template findInCache(String templateName) {
|
||||
synchronized(templates) {
|
||||
return (freemarker.template.Template) templates.get(templateName);
|
||||
return templates.get(templateName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables Struts caching of Freemarker templates. By default disabled.
|
||||
* Set struts.freemarker.templatesCache=true to enable cache
|
||||
* @param caching true if the template engine should cache freemarker template
|
||||
* @param cacheTemplates "true" if the template engine should cache freemarker template
|
||||
* internally
|
||||
*/
|
||||
@Inject(StrutsConstants.STRUTS_FREEMARKER_TEMPLATES_CACHE)
|
||||
|
||||
@@ -20,19 +20,16 @@
|
||||
*/
|
||||
package org.apache.struts2.components.template;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.components.Include;
|
||||
import org.apache.struts2.components.UIBean;
|
||||
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.jsp.PageContext;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JSP based template engine.
|
||||
@@ -50,11 +47,10 @@ public class JspTemplateEngine extends BaseTemplateEngine {
|
||||
ValueStack stack = templateContext.getStack();
|
||||
stack.push(tag);
|
||||
PageContext pageContext = (PageContext) stack.getContext().get(ServletActionContext.PAGE_CONTEXT);
|
||||
List templates = template.getPossibleTemplates(this);
|
||||
List<Template> templates = template.getPossibleTemplates(this);
|
||||
Exception exception = null;
|
||||
boolean success = false;
|
||||
for (Iterator iterator = templates.iterator(); iterator.hasNext();) {
|
||||
Template t = (Template) iterator.next();
|
||||
for (Template t : templates) {
|
||||
try {
|
||||
Include.include(getFinalTemplateName(t), pageContext.getOut(),
|
||||
pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse());
|
||||
|
||||
@@ -59,8 +59,8 @@ public class Template implements Cloneable {
|
||||
return name;
|
||||
}
|
||||
|
||||
public List getPossibleTemplates(TemplateEngine engine) {
|
||||
List list = new ArrayList(3);
|
||||
public List<Template> getPossibleTemplates(TemplateEngine engine) {
|
||||
List<Template> list = new ArrayList<Template>(3);
|
||||
Template template = this;
|
||||
String parentTheme;
|
||||
list.add(template);
|
||||
|
||||
+10
-14
@@ -20,16 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.components.template;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
@@ -37,7 +28,13 @@ import org.apache.struts2.views.velocity.VelocityManager;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.context.Context;
|
||||
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Velocity based template engine.
|
||||
@@ -64,14 +61,13 @@ public class VelocityTemplateEngine extends BaseTemplateEngine {
|
||||
VelocityEngine velocityEngine = velocityManager.getVelocityEngine();
|
||||
|
||||
// get the list of templates we can use
|
||||
List templates = templateContext.getTemplate().getPossibleTemplates(this);
|
||||
List<Template> templates = templateContext.getTemplate().getPossibleTemplates(this);
|
||||
|
||||
// find the right template
|
||||
org.apache.velocity.Template template = null;
|
||||
String templateName = null;
|
||||
Exception exception = null;
|
||||
for (Iterator iterator = templates.iterator(); iterator.hasNext();) {
|
||||
Template t = (Template) iterator.next();
|
||||
for (Template t : templates) {
|
||||
templateName = getFinalTemplateName(t);
|
||||
try {
|
||||
// try to load, and if it works, stop at the first one
|
||||
|
||||
@@ -38,6 +38,8 @@ import com.opensymphony.xwork2.TextProvider;
|
||||
import com.opensymphony.xwork2.config.Configuration;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
|
||||
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Context;
|
||||
@@ -45,8 +47,6 @@ import com.opensymphony.xwork2.inject.Factory;
|
||||
import com.opensymphony.xwork2.inject.Scope;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.ObjectTypeDeterminer;
|
||||
import com.opensymphony.xwork2.util.XWorkConverter;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
|
||||
/**
|
||||
@@ -172,6 +172,11 @@ public class BeanSelectionProvider implements ConfigurationProvider {
|
||||
props.setProperty("devMode", "false");
|
||||
}
|
||||
|
||||
String val = props.getProperty(StrutsConstants.STRUTS_ALLOW_STATIC_METHOD_ACCESS);
|
||||
if (val != null) {
|
||||
props.setProperty("allowStaticMethodAccess", val);
|
||||
}
|
||||
|
||||
// TODO: This should be moved to XWork after 2.0.4
|
||||
// struts.custom.i18n.resources
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.util.ResolverUtil;
|
||||
import com.opensymphony.xwork2.util.TextUtils;
|
||||
import com.opensymphony.xwork2.util.ResolverUtil.Test;
|
||||
import com.opensymphony.xwork2.util.ResolverUtil.ClassTest;
|
||||
import com.opensymphony.xwork2.util.location.LocatableProperties;
|
||||
|
||||
/**
|
||||
@@ -231,7 +231,7 @@ public class ClasspathConfigurationProvider implements ConfigurationProvider {
|
||||
protected void loadPackages(String[] pkgs) {
|
||||
|
||||
ResolverUtil<Class> resolver = new ResolverUtil<Class>();
|
||||
resolver.find(new Test() {
|
||||
resolver.find(new ClassTest() {
|
||||
// Match Action implementations and classes ending with "Action"
|
||||
public boolean matches(Class type) {
|
||||
// TODO: should also find annotated classes
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
<!--
|
||||
/*
|
||||
* $Id: Action.java 502296 2007-02-01 17:33:39Z niallp $
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<body>Classes for Struts configuration and property handling.</body>
|
||||
|
||||
@@ -59,12 +59,12 @@ import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.config.ConfigurationManager;
|
||||
import com.opensymphony.xwork2.config.ConfigurationProvider;
|
||||
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
|
||||
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
|
||||
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminerFactory;
|
||||
import com.opensymphony.xwork2.inject.Container;
|
||||
import com.opensymphony.xwork2.inject.ContainerBuilder;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import com.opensymphony.xwork2.util.LocalizedTextUtil;
|
||||
import com.opensymphony.xwork2.util.ObjectTypeDeterminer;
|
||||
import com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
import com.opensymphony.xwork2.util.location.Location;
|
||||
@@ -105,12 +105,6 @@ public class Dispatcher {
|
||||
*/
|
||||
private ConfigurationManager configurationManager;
|
||||
|
||||
/**
|
||||
* Store whether portlet support is active
|
||||
* (set to true by Jsr168Dispatcher).
|
||||
*/
|
||||
private static boolean portletSupportActive;
|
||||
|
||||
/**
|
||||
* Store state of StrutsConstants.STRUTS_DEVMODE setting.
|
||||
*/
|
||||
@@ -747,12 +741,15 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
// send a http error response to use the servlet defined error handler
|
||||
// make the exception availible to the web.xml defined error page
|
||||
request.setAttribute("javax.servlet.error.exception", e);
|
||||
// WW-1977: Only put errors in the request when code is a 500 error
|
||||
if (code == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) {
|
||||
// send a http error response to use the servlet defined error handler
|
||||
// make the exception availible to the web.xml defined error page
|
||||
request.setAttribute("javax.servlet.error.exception", e);
|
||||
|
||||
// for compatibility
|
||||
request.setAttribute("javax.servlet.jsp.jspException", e);
|
||||
// for compatibility
|
||||
request.setAttribute("javax.servlet.jsp.jspException", e);
|
||||
}
|
||||
|
||||
// send the error response
|
||||
response.sendError(code, e.getMessage());
|
||||
@@ -762,23 +759,6 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return <tt>true</tt>, if portlet support is active, <tt>false</tt> otherwise.
|
||||
*
|
||||
* @return <tt>true</tt>, if portlet support is active, <tt>false</tt> otherwise.
|
||||
*/
|
||||
public boolean isPortletSupportActive() {
|
||||
return portletSupportActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the portlet support mode.
|
||||
* @param portletSupportActive <tt>true</tt> or <tt>false</tt>
|
||||
*/
|
||||
public static void setPortletSupportActive(boolean portletSupportActive) {
|
||||
Dispatcher.portletSupportActive = portletSupportActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search classpath for a page.
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.opensymphony.xwork2.ActionInvocation;
|
||||
/**
|
||||
* <!-- START SNIPPET: description -->
|
||||
*
|
||||
* A custom Result type for send raw data (via an InputStream) directly to the
|
||||
* A custom Result type for sending raw data (via an InputStream) directly to the
|
||||
* HttpServletResponse. Very useful for allowing users to download content.
|
||||
*
|
||||
* <!-- END SNIPPET: description -->
|
||||
|
||||
@@ -137,6 +137,13 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics {
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location it was created with, mainly for testing
|
||||
*/
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last parsed and encoded location value
|
||||
|
||||
@@ -22,11 +22,14 @@ package org.apache.struts2.dispatcher.mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -162,25 +165,25 @@ import com.opensymphony.xwork2.inject.Container;
|
||||
*/
|
||||
public class DefaultActionMapper implements ActionMapper {
|
||||
|
||||
static final String METHOD_PREFIX = "method:";
|
||||
protected static final String METHOD_PREFIX = "method:";
|
||||
|
||||
static final String ACTION_PREFIX = "action:";
|
||||
protected static final String ACTION_PREFIX = "action:";
|
||||
|
||||
static final String REDIRECT_PREFIX = "redirect:";
|
||||
protected static final String REDIRECT_PREFIX = "redirect:";
|
||||
|
||||
static final String REDIRECT_ACTION_PREFIX = "redirect-action:";
|
||||
protected static final String REDIRECT_ACTION_PREFIX = "redirect-action:";
|
||||
|
||||
private boolean allowDynamicMethodCalls = true;
|
||||
protected boolean allowDynamicMethodCalls = true;
|
||||
|
||||
private boolean allowSlashesInActionNames = false;
|
||||
protected boolean allowSlashesInActionNames = false;
|
||||
|
||||
private boolean alwaysSelectFullNamespace = false;
|
||||
protected boolean alwaysSelectFullNamespace = false;
|
||||
|
||||
private PrefixTrie prefixTrie = null;
|
||||
protected PrefixTrie prefixTrie = null;
|
||||
|
||||
List extensions = new ArrayList() {{ add("action");}};
|
||||
protected List<String> extensions = new ArrayList<String>() {{ add("action"); add("");}};
|
||||
|
||||
private Container container;
|
||||
protected Container container;
|
||||
|
||||
public DefaultActionMapper() {
|
||||
prefixTrie = new PrefixTrie() {
|
||||
@@ -225,7 +228,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
ServletRedirectResult redirect = new ServletRedirectResult();
|
||||
container.inject(redirect);
|
||||
String extension = getDefaultExtension();
|
||||
if (extension != null) {
|
||||
if (extension != null && extension.length() > 0) {
|
||||
location += "." + extension;
|
||||
}
|
||||
redirect.setLocation(location);
|
||||
@@ -266,7 +269,21 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
public void setContainer(Container container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
|
||||
@Inject(StrutsConstants.STRUTS_ACTION_EXTENSION)
|
||||
public void setExtensions(String extensions) {
|
||||
if (!"".equals(extensions)) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Scanner scanner = new Scanner(extensions).useDelimiter(",");
|
||||
while (scanner.hasNext()) {
|
||||
list.add(scanner.next());
|
||||
}
|
||||
this.extensions = Collections.unmodifiableList(list);
|
||||
} else {
|
||||
this.extensions = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -347,7 +364,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
* @param mapping
|
||||
* The action mapping to populate
|
||||
*/
|
||||
void parseNameAndNamespace(String uri, ActionMapping mapping,
|
||||
protected void parseNameAndNamespace(String uri, ActionMapping mapping,
|
||||
ConfigurationManager configManager) {
|
||||
String namespace, name;
|
||||
int lastSlash = uri.lastIndexOf("/");
|
||||
@@ -401,17 +418,22 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
* The action name
|
||||
* @return The action name without its extension
|
||||
*/
|
||||
String dropExtension(String name) {
|
||||
protected String dropExtension(String name) {
|
||||
if (extensions == null) {
|
||||
return name;
|
||||
}
|
||||
Iterator it = extensions.iterator();
|
||||
while (it.hasNext()) {
|
||||
String extension = "." + (String) it.next();
|
||||
if (name.endsWith(extension)) {
|
||||
name = name.substring(0, name.length() - extension.length());
|
||||
return name;
|
||||
}
|
||||
for (String ext : extensions) {
|
||||
if ("".equals(ext)) {
|
||||
if (name.indexOf('.') == -1) {
|
||||
return name;
|
||||
}
|
||||
} else {
|
||||
String extension = "." + ext;
|
||||
if (name.endsWith(extension)) {
|
||||
name = name.substring(0, name.length() - extension.length());
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -419,7 +441,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
/**
|
||||
* Returns null if no extension is specified.
|
||||
*/
|
||||
String getDefaultExtension() {
|
||||
protected String getDefaultExtension() {
|
||||
if (extensions == null) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -427,15 +449,6 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(StrutsConstants.STRUTS_ACTION_EXTENSION)
|
||||
public void setExtensions(String extensions) {
|
||||
if (!"".equals(extensions)) {
|
||||
this.extensions = Arrays.asList(extensions.split(","));
|
||||
} else {
|
||||
this.extensions = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the uri from the request
|
||||
*
|
||||
@@ -443,7 +456,7 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
* The request
|
||||
* @return The uri
|
||||
*/
|
||||
String getUri(HttpServletRequest request) {
|
||||
protected String getUri(HttpServletRequest request) {
|
||||
// handle http dispatcher includes.
|
||||
String uri = (String) request
|
||||
.getAttribute("javax.servlet.include.servlet_path");
|
||||
@@ -486,8 +499,11 @@ public class DefaultActionMapper implements ActionMapper {
|
||||
|
||||
String extension = getDefaultExtension();
|
||||
if (extension != null) {
|
||||
if (uri.indexOf('.' + extension) == -1) {
|
||||
uri.append(".").append(extension);
|
||||
|
||||
if (extension.length() == 0 || (extension.length() > 0 && uri.indexOf('.' + extension) == -1)) {
|
||||
if (extension.length() > 0) {
|
||||
uri.append(".").append(extension);
|
||||
}
|
||||
if (params.length() > 0) {
|
||||
uri.append(params);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id: Action.java 502296 2007-02-01 17:33:39Z niallp $
|
||||
*
|
||||
* 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.dispatcher.mapper;
|
||||
|
||||
/**
|
||||
|
||||
+6
@@ -115,6 +115,12 @@ public class JakartaMultiPartRequest implements MultiPartRequest {
|
||||
} else {
|
||||
log.debug("Item is a file upload");
|
||||
|
||||
// Skip file uploads that don't have a file name - meaning that no file was selected.
|
||||
if (item.getName() == null || item.getName().trim().length() < 1) {
|
||||
log.debug("No file has been uploaded for the field: " + item.getFieldName());
|
||||
continue;
|
||||
}
|
||||
|
||||
List<FileItem> values;
|
||||
if (files.get(item.getFieldName()) != null) {
|
||||
values = files.get(item.getFieldName());
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<body>Classes to help dispatch multipart HTTP requests.</body>
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<body>Classes for action dispatching in Struts (the Controller part of MVC).</body>
|
||||
|
||||
@@ -137,16 +137,16 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str
|
||||
((ParameterAware) action).setParameters(context.getParameters());
|
||||
}
|
||||
|
||||
if (action instanceof RequestAware) {
|
||||
((RequestAware) action).setRequest((Map) context.get("request"));
|
||||
if (action instanceof ApplicationAware) {
|
||||
((ApplicationAware) action).setApplication(context.getApplication());
|
||||
}
|
||||
|
||||
|
||||
if (action instanceof SessionAware) {
|
||||
((SessionAware) action).setSession(context.getSession());
|
||||
}
|
||||
|
||||
if (action instanceof ApplicationAware) {
|
||||
((ApplicationAware) action).setApplication(context.getApplication());
|
||||
|
||||
if (action instanceof RequestAware) {
|
||||
((RequestAware) action).setRequest((Map) context.get("request"));
|
||||
}
|
||||
|
||||
if (action instanceof PrincipalAware) {
|
||||
|
||||
+53
-4
@@ -40,9 +40,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerResult;
|
||||
import org.apache.struts2.StrutsConstants;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
@@ -67,6 +67,10 @@ import com.opensymphony.xwork2.util.ValueStack;
|
||||
* the 'xml' mode is inserted at the top of the page.</li>
|
||||
* <li> <code>command</code> - Tests an OGNL expression and returns the
|
||||
* string result. Only used by the OGNL console.</li>
|
||||
* <li><code>browser</code> Shows field values of an object specified in the
|
||||
* <code>object<code> parameter (#context by default). When the <code>object<code>
|
||||
* parameters is set, the '#' character needs to be escaped to '%23'. Like
|
||||
* debug=browser&object=%23parameters</li>
|
||||
* </ul>
|
||||
* <!-- END SNIPPET: parameters -->
|
||||
* <p/>
|
||||
@@ -97,11 +101,14 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
private final static String XML_MODE = "xml";
|
||||
private final static String CONSOLE_MODE = "console";
|
||||
private final static String COMMAND_MODE = "command";
|
||||
private final static String BROWSER_MODE = "browser";
|
||||
|
||||
private final static String SESSION_KEY = "org.apache.struts2.interceptor.debugging.VALUE_STACK";
|
||||
|
||||
private final static String DEBUG_PARAM = "debug";
|
||||
private final static String OBJECT_PARAM = "object";
|
||||
private final static String EXPRESSION_PARAM = "expression";
|
||||
private final static String DECORATE_PARAM = "decorate";
|
||||
|
||||
private boolean enableXmlWithConsole = false;
|
||||
|
||||
@@ -140,7 +147,7 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
* @see com.opensymphony.xwork2.interceptor.Interceptor#invoke(com.opensymphony.xwork2.ActionInvocation)
|
||||
*/
|
||||
public String intercept(ActionInvocation inv) throws Exception {
|
||||
|
||||
boolean actionOnly = false;
|
||||
boolean cont = true;
|
||||
if (devMode) {
|
||||
final ActionContext ctx = ActionContext.getContext();
|
||||
@@ -204,11 +211,53 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
cont = false;
|
||||
} else if (BROWSER_MODE.equals(type)) {
|
||||
actionOnly = true;
|
||||
inv.addPreResultListener(
|
||||
new PreResultListener() {
|
||||
public void beforeResult(ActionInvocation inv, String actionResult) {
|
||||
String rootObjectExpression = getParameter(OBJECT_PARAM);
|
||||
if (rootObjectExpression == null)
|
||||
rootObjectExpression = "#context";
|
||||
String decorate = getParameter(DECORATE_PARAM);
|
||||
ValueStack stack = (ValueStack) ctx.get(ActionContext.VALUE_STACK);
|
||||
Object rootObject = stack.findValue(rootObjectExpression);
|
||||
|
||||
try {
|
||||
StringWriter writer = new StringWriter();
|
||||
ObjectToHTMLWriter htmlWriter = new ObjectToHTMLWriter(writer);
|
||||
htmlWriter.write(rootObject, rootObjectExpression);
|
||||
String html = writer.toString();
|
||||
writer.close();
|
||||
|
||||
stack.set("debugHtml", html);
|
||||
|
||||
//on the first request, response can be decorated
|
||||
//but we need plain text on the other ones
|
||||
if ("false".equals(decorate))
|
||||
ServletActionContext.getRequest().setAttribute("decorator", "none");
|
||||
|
||||
FreemarkerResult result = new FreemarkerResult();
|
||||
result.setFreemarkerManager(freemarkerManager);
|
||||
result.setContentType("text/html");
|
||||
result.setLocation("/org/apache/struts2/interceptor/debugging/browser.ftl");
|
||||
result.execute(inv);
|
||||
} catch (Exception ex) {
|
||||
log.error("Unable to create debugging console", ex);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cont) {
|
||||
try {
|
||||
return inv.invoke();
|
||||
if (actionOnly) {
|
||||
inv.invokeActionOnly();
|
||||
return null;
|
||||
} else {
|
||||
return inv.invoke();
|
||||
}
|
||||
} finally {
|
||||
if (devMode && consoleEnabled) {
|
||||
final ActionContext ctx = ActionContext.getContext();
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.interceptor.debugging;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.io.Writer;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import ognl.OgnlException;
|
||||
|
||||
import com.opensymphony.xwork2.util.OgnlUtil;
|
||||
|
||||
/**
|
||||
* Writes an object as a table, where each field can be expanded if it is an Object/Collection/Array
|
||||
*
|
||||
*/
|
||||
class ObjectToHTMLWriter {
|
||||
private PrettyPrintWriter prettyWriter;
|
||||
|
||||
ObjectToHTMLWriter(Writer writer) {
|
||||
this.prettyWriter = new PrettyPrintWriter(writer);
|
||||
this.prettyWriter.setEscape(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void write(Object root, String expr) throws IntrospectionException,
|
||||
OgnlException {
|
||||
prettyWriter.startNode("table");
|
||||
prettyWriter.addAttribute("class", "debugTable");
|
||||
|
||||
if (root instanceof Map) {
|
||||
for (Iterator iterator = ((Map) root).entrySet().iterator(); iterator
|
||||
.hasNext();) {
|
||||
Map.Entry property = (Map.Entry) iterator.next();
|
||||
String key = property.getKey().toString();
|
||||
Object value = property.getValue();
|
||||
writeProperty(key, value, expr);
|
||||
}
|
||||
} else if (root instanceof List) {
|
||||
List list = (List) root;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object element = list.get(i);
|
||||
writeProperty(String.valueOf(i), element, expr);
|
||||
}
|
||||
} else if (root instanceof Set) {
|
||||
Set set = (Set) root;
|
||||
for (Iterator iterator = set.iterator(); iterator.hasNext();) {
|
||||
writeProperty("", iterator.next(), expr);
|
||||
}
|
||||
} else if (root.getClass().isArray()) {
|
||||
Object[] objects = (Object[]) root;
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
writeProperty(String.valueOf(i), objects[i], expr);
|
||||
}
|
||||
} else {
|
||||
//print properties
|
||||
Map<String, Object> properties = OgnlUtil.getBeanMap(root);
|
||||
for (Map.Entry<String, Object> property : properties.entrySet()) {
|
||||
String name = property.getKey();
|
||||
Object value = property.getValue();
|
||||
|
||||
if ("class".equals(name))
|
||||
continue;
|
||||
|
||||
writeProperty(name, value, expr);
|
||||
}
|
||||
}
|
||||
|
||||
prettyWriter.endNode();
|
||||
}
|
||||
|
||||
private void writeProperty(String name, Object value, String expr) {
|
||||
prettyWriter.startNode("tr");
|
||||
|
||||
//name cell
|
||||
prettyWriter.startNode("td");
|
||||
prettyWriter.addAttribute("class", "nameColumn");
|
||||
prettyWriter.setValue(name);
|
||||
prettyWriter.endNode();
|
||||
|
||||
//value cell
|
||||
prettyWriter.startNode("td");
|
||||
if (value != null) {
|
||||
//if is is an empty collection or array, don't write a link
|
||||
if (value != null &&
|
||||
(isEmptyCollection(value) || isEmptyMap(value) || (value.getClass()
|
||||
.isArray() && ((Object[]) value).length == 0))) {
|
||||
prettyWriter.addAttribute("class", "emptyCollection");
|
||||
prettyWriter.setValue("empty");
|
||||
} else {
|
||||
prettyWriter.addAttribute("class", "valueColumn");
|
||||
writeValue(name, value, expr);
|
||||
}
|
||||
} else {
|
||||
prettyWriter.addAttribute("class", "nullValue");
|
||||
prettyWriter.setValue("null");
|
||||
}
|
||||
prettyWriter.endNode();
|
||||
|
||||
//type cell
|
||||
prettyWriter.startNode("td");
|
||||
if (value != null) {
|
||||
prettyWriter.addAttribute("class", "typeColumn");
|
||||
Class clazz = value.getClass();
|
||||
prettyWriter.setValue(clazz.getName());
|
||||
} else {
|
||||
prettyWriter.addAttribute("class", "nullValue");
|
||||
prettyWriter.setValue("unknown");
|
||||
}
|
||||
prettyWriter.endNode();
|
||||
|
||||
//close tr
|
||||
prettyWriter.endNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Some maps, like AttributeMap will throw an exception when isEmpty() is called
|
||||
*/
|
||||
private boolean isEmptyMap(Object value) {
|
||||
try {
|
||||
return value instanceof Map && ((Map) value).isEmpty();
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Some collections might throw an exception when isEmpty() is called
|
||||
*/
|
||||
private boolean isEmptyCollection(Object value) {
|
||||
try {
|
||||
return value instanceof Collection && ((Collection) value).isEmpty();
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeValue(String name, Object value, String expr) {
|
||||
Class clazz = value.getClass();
|
||||
if (clazz.isPrimitive() || Number.class.isAssignableFrom(clazz) ||
|
||||
clazz.equals(String.class) || Boolean.class.equals(clazz)) {
|
||||
prettyWriter.setValue(String.valueOf(value));
|
||||
} else {
|
||||
prettyWriter.startNode("a");
|
||||
String path = expr.replaceAll("#", "%23") + "[\"" +
|
||||
name.replaceAll("#", "%23") + "\"]";
|
||||
prettyWriter.addAttribute("onclick", "expand(this, '" + path + "')");
|
||||
prettyWriter.addAttribute("href", "javascript://nop/");
|
||||
prettyWriter.setValue("Expand");
|
||||
prettyWriter.endNode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class PrettyPrintWriter {
|
||||
private boolean readyForNewLine;
|
||||
private boolean tagIsEmpty;
|
||||
private String newLine;
|
||||
private boolean escape = true;
|
||||
|
||||
private static final char[] NULL = "�".toCharArray();
|
||||
private static final char[] AMP = "&".toCharArray();
|
||||
@@ -125,7 +126,12 @@ public class PrettyPrintWriter {
|
||||
this.writer.write(QUOT);
|
||||
break;
|
||||
case '\'':
|
||||
this.writer.write(APOS);
|
||||
//for some reason IE just doesn't like this when we use it from ObjectToHtmlWriter
|
||||
//it works on FF and Opera
|
||||
if (escape)
|
||||
this.writer.write(APOS);
|
||||
else
|
||||
this.writer.write(c);
|
||||
break;
|
||||
case '\r':
|
||||
this.writer.write(SLASH_R);
|
||||
@@ -181,4 +187,12 @@ public class PrettyPrintWriter {
|
||||
public void close() {
|
||||
writer.close();
|
||||
}
|
||||
|
||||
public boolean isEscape() {
|
||||
return escape;
|
||||
}
|
||||
|
||||
public void setEscape(boolean escape) {
|
||||
this.escape = escape;
|
||||
}
|
||||
}
|
||||
|
||||
+44
-23
@@ -36,21 +36,41 @@ import org.apache.struts2.ServletActionContext;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.ValidationAware;
|
||||
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
|
||||
|
||||
/**
|
||||
* <p>Extends the annotations validator and returns a JSON string with the
|
||||
* validation errors. If validation succeeds the action is invoked.</p>
|
||||
* <p>Serializes validation and action errors into JSON. This interceptor does not
|
||||
* perform any validation, so it must follow the 'validation' interceptor on the stack.
|
||||
* </p>
|
||||
*
|
||||
* <p>This stack (defined in struts-default.xml) shows how to use this interceptor with the
|
||||
* 'validation' interceptor</p>
|
||||
* <pre>
|
||||
* <interceptor-stack name="jsonValidationWorkflowStack">
|
||||
* <interceptor-ref name="basicStack"/>
|
||||
* <interceptor-ref name="validation">
|
||||
* <param name="excludeMethods">input,back,cancel</param>
|
||||
* </interceptor-ref>
|
||||
* <interceptor-ref name="jsonValidation"/>
|
||||
* <interceptor-ref name="workflow"/>
|
||||
* </interceptor-stack>
|
||||
* </pre>
|
||||
* <p>If 'validationFailedStatus' is set it will be used as the Response status
|
||||
* when validation fails.</p>
|
||||
*
|
||||
* <p>If the request has a parameter 'struts.validateOnly' execution will return after
|
||||
* validation (action won't be executed).</p>
|
||||
*
|
||||
* <p>A request parameter named 'enableJSONValidation' must be set to 'true' to
|
||||
* use this interceptor</p>
|
||||
*/
|
||||
public class JSONValidationInterceptor extends AnnotationValidationInterceptor {
|
||||
public class JSONValidationInterceptor extends MethodFilterInterceptor {
|
||||
private static final Log LOG = LogFactory
|
||||
.getLog(JSONValidationInterceptor.class);
|
||||
|
||||
private static final String VALIDATE_ONLY_PARAM = "struts.validateOnly";
|
||||
private static final String VALIDATE_JSON_PARAM = "struts.enableJSONValidation";
|
||||
|
||||
static char[] hex = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
private int validationFailedStatus = -1;
|
||||
@@ -65,33 +85,34 @@ public class JSONValidationInterceptor extends AnnotationValidationInterceptor {
|
||||
|
||||
@Override
|
||||
protected String doIntercept(ActionInvocation invocation) throws Exception {
|
||||
//validate
|
||||
doBeforeInvocation(invocation);
|
||||
|
||||
HttpServletResponse response = ServletActionContext.getResponse();
|
||||
HttpServletRequest request = ServletActionContext.getRequest();
|
||||
|
||||
Object action = invocation.getAction();
|
||||
String jsonEnabled = request.getParameter(VALIDATE_JSON_PARAM);
|
||||
|
||||
if (jsonEnabled != null && "true".equals(jsonEnabled)) {
|
||||
if (action instanceof ValidationAware) {
|
||||
// generate json
|
||||
ValidationAware validationAware = (ValidationAware) action;
|
||||
if (validationAware.hasErrors()) {
|
||||
if (validationFailedStatus >= 0)
|
||||
response.setStatus(validationFailedStatus);
|
||||
response.getWriter().print(buildResponse(validationAware));
|
||||
return Action.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (action instanceof ValidationAware) {
|
||||
// generate json
|
||||
ValidationAware validationAware = (ValidationAware) action;
|
||||
if (validationAware.hasErrors()) {
|
||||
if (validationFailedStatus >= 0)
|
||||
response.setStatus(validationFailedStatus);
|
||||
response.getWriter().print(buildResponse(validationAware));
|
||||
String validateOnly = request.getParameter(VALIDATE_ONLY_PARAM);
|
||||
if (validateOnly != null && "true".equals(validateOnly)) {
|
||||
//there were no errors
|
||||
response.getWriter().print("/* {} */");
|
||||
return Action.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
String validateOnly = request.getParameter(VALIDATE_ONLY_PARAM);
|
||||
if (validateOnly != null && "true".equals(validateOnly)) {
|
||||
//there were no errors
|
||||
response.getWriter().print("/* {} */");
|
||||
return Action.NONE;
|
||||
} else {
|
||||
} else {
|
||||
return invocation.invoke();
|
||||
}
|
||||
} else
|
||||
return invocation.invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.servlet.interceptor;
|
||||
|
||||
import org.apache.struts2.interceptor.PrincipalProxy;
|
||||
|
||||
@@ -22,7 +22,7 @@ package org.apache.struts2.util;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import ognl.DefaultTypeConverter;
|
||||
import com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter;
|
||||
|
||||
/**
|
||||
* <!-- START SNIPPET: javadoc -->
|
||||
|
||||
@@ -39,4 +39,6 @@ public @interface StrutsTag {
|
||||
String tldTagClass();
|
||||
|
||||
String description();
|
||||
|
||||
boolean allowDynamicAttributes() default false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public @interface StrutsTagAttribute {
|
||||
|
||||
boolean required() default false;
|
||||
|
||||
boolean rtexprvalue() default true;
|
||||
boolean rtexprvalue() default false;
|
||||
|
||||
String description();
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ import freemarker.template.TemplateModel;
|
||||
*/
|
||||
public class FreemarkerManager {
|
||||
|
||||
private static final Log log = LogFactory.getLog(FreemarkerManager.class);
|
||||
private static final Log LOG = LogFactory.getLog(FreemarkerManager.class);
|
||||
public static final String CONFIG_SERVLET_CONTEXT_KEY = "freemarker.Configuration";
|
||||
public static final String KEY_EXCEPTION = "exception";
|
||||
|
||||
@@ -270,7 +270,7 @@ public class FreemarkerManager {
|
||||
try {
|
||||
templatePathLoader = new FileTemplateLoader(new File(templatePath));
|
||||
} catch (IOException e) {
|
||||
log.error("Invalid template path specified: " + e.getMessage(), e);
|
||||
LOG.error("Invalid template path specified: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,8 +325,10 @@ public class FreemarkerManager {
|
||||
* @see freemarker.template.Configuration#setSettings for the definition of valid settings
|
||||
*/
|
||||
protected void loadSettings(ServletContext servletContext, freemarker.template.Configuration configuration) {
|
||||
InputStream in = null;
|
||||
|
||||
try {
|
||||
InputStream in = FileManager.loadFile("freemarker.properties", FreemarkerManager.class);
|
||||
in = FileManager.loadFile("freemarker.properties", FreemarkerManager.class);
|
||||
|
||||
if (in != null) {
|
||||
Properties p = new Properties();
|
||||
@@ -334,9 +336,17 @@ public class FreemarkerManager {
|
||||
configuration.setSettings(p);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error while loading freemarker settings from /freemarker.properties", e);
|
||||
LOG.error("Error while loading freemarker settings from /freemarker.properties", e);
|
||||
} catch (TemplateException e) {
|
||||
log.error("Error while loading freemarker settings from /freemarker.properties", e);
|
||||
LOG.error("Error while loading freemarker settings from /freemarker.properties", e);
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch(IOException io) {
|
||||
LOG.warn("Unable to close input stream", io);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.apache.struts2.util.AttributeMap;
|
||||
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.config.ConfigurationException;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStackFactory;
|
||||
|
||||
@@ -55,6 +56,11 @@ public class TagUtils {
|
||||
|
||||
HttpServletResponse res = (HttpServletResponse) pageContext.getResponse();
|
||||
Dispatcher du = Dispatcher.getInstance();
|
||||
if (du == null) {
|
||||
throw new ConfigurationException("The Struts dispatcher cannot be found. This is usually caused by "+
|
||||
"using Struts tags without the associated filter. Struts tags are only usable when the request "+
|
||||
"has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.");
|
||||
}
|
||||
Map extraContext = du.createContextMap(new RequestMap(req),
|
||||
req.getParameterMap(),
|
||||
new SessionMap(req),
|
||||
|
||||
@@ -44,10 +44,12 @@ public class URLTag extends ContextBeanTag {
|
||||
protected String method;
|
||||
protected String encode;
|
||||
protected String includeContext;
|
||||
protected String escapeAmp;
|
||||
protected String portletMode;
|
||||
protected String windowState;
|
||||
protected String portletUrlType;
|
||||
protected String anchor;
|
||||
protected String forceAddSchemeHostAndPort;
|
||||
|
||||
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
|
||||
return new URL(stack, req, res);
|
||||
@@ -74,6 +76,12 @@ public class URLTag extends ContextBeanTag {
|
||||
if (includeContext != null) {
|
||||
url.setIncludeContext(Boolean.valueOf(includeContext).booleanValue());
|
||||
}
|
||||
if (escapeAmp != null) {
|
||||
url.setEscapeAmp(Boolean.valueOf(escapeAmp).booleanValue());
|
||||
}
|
||||
if (forceAddSchemeHostAndPort != null) {
|
||||
url.setForceAddSchemeHostAndPort(Boolean.valueOf(forceAddSchemeHostAndPort).booleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void setEncode(String encode) {
|
||||
@@ -83,6 +91,10 @@ public class URLTag extends ContextBeanTag {
|
||||
public void setIncludeContext(String includeContext) {
|
||||
this.includeContext = includeContext;
|
||||
}
|
||||
|
||||
public void setEscapeAmp(String escapeAmp) {
|
||||
this.escapeAmp = escapeAmp;
|
||||
}
|
||||
|
||||
public void setIncludeParams(String name) {
|
||||
includeParams = name;
|
||||
@@ -107,12 +119,15 @@ public class URLTag extends ContextBeanTag {
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setPortletMode(String portletMode) {
|
||||
this.portletMode = portletMode;
|
||||
}
|
||||
|
||||
public void setPortletUrlType(String portletUrlType) {
|
||||
this.portletUrlType = portletUrlType;
|
||||
}
|
||||
|
||||
public void setWindowState(String windowState) {
|
||||
this.windowState = windowState;
|
||||
}
|
||||
@@ -120,4 +135,8 @@ public class URLTag extends ContextBeanTag {
|
||||
public void setAnchor(String anchor) {
|
||||
this.anchor = anchor;
|
||||
}
|
||||
|
||||
public void setForceAddSchemeHostAndPort(String forceAddSchemeHostAndPort) {
|
||||
this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<body>Struts's JSP tag library.</body>
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
*/
|
||||
package org.apache.struts2.views.jsp.ui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.tagext.DynamicAttributes;
|
||||
|
||||
import org.apache.struts2.components.UIBean;
|
||||
import org.apache.struts2.views.jsp.ComponentTagSupport;
|
||||
|
||||
@@ -28,7 +34,7 @@ import org.apache.struts2.views.jsp.ComponentTagSupport;
|
||||
* Abstract base class for all UI tags.
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractUITag extends ComponentTagSupport {
|
||||
public abstract class AbstractUITag extends ComponentTagSupport implements DynamicAttributes {
|
||||
protected String cssClass;
|
||||
protected String cssStyle;
|
||||
protected String title;
|
||||
@@ -71,6 +77,9 @@ public abstract class AbstractUITag extends ComponentTagSupport {
|
||||
protected String tooltipCssClass;
|
||||
protected String tooltipIconPath;
|
||||
|
||||
// dynamic attributes.
|
||||
protected Map<String,Object> dynamicAttributes = new HashMap<String,Object>();
|
||||
|
||||
protected void populateParams() {
|
||||
super.populateParams();
|
||||
|
||||
@@ -114,6 +123,8 @@ public abstract class AbstractUITag extends ComponentTagSupport {
|
||||
uiBean.setAccesskey(accesskey);
|
||||
uiBean.setKey(key);
|
||||
uiBean.setId(id);
|
||||
|
||||
uiBean.setDynamicAttributes(dynamicAttributes);
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
@@ -266,5 +277,9 @@ public abstract class AbstractUITag extends ComponentTagSupport {
|
||||
|
||||
public void setLabelSeparator(String labelSeparator) {
|
||||
this.labelSeparator = labelSeparator;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDynamicAttribute(String uri, String localName, Object value) throws JspException {
|
||||
dynamicAttributes.put(localName, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.struts2.views.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -91,6 +90,10 @@ public class UrlHelper {
|
||||
}
|
||||
|
||||
public static String buildUrl(String action, HttpServletRequest request, HttpServletResponse response, Map params, String scheme, boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort) {
|
||||
return buildUrl(action, request, response, params, scheme, includeContext, encodeResult, forceAddSchemeHostAndPort, true);
|
||||
}
|
||||
|
||||
public static String buildUrl(String action, HttpServletRequest request, HttpServletResponse response, Map params, String scheme, boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort, boolean escapeAmp) {
|
||||
StringBuffer link = new StringBuffer();
|
||||
|
||||
boolean changedScheme = false;
|
||||
@@ -105,15 +108,24 @@ public class UrlHelper {
|
||||
link.append(request.getServerName());
|
||||
|
||||
if (scheme != null) {
|
||||
if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT))
|
||||
{
|
||||
link.append(":");
|
||||
link.append(scheme.equals("http") ? httpPort : httpsPort);
|
||||
// If switching schemes, use the configured port for the particular scheme.
|
||||
if (!scheme.equals(reqScheme)) {
|
||||
if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) {
|
||||
link.append(":");
|
||||
link.append(scheme.equals("http") ? httpPort : httpsPort);
|
||||
}
|
||||
// Else use the port from the current request.
|
||||
} else {
|
||||
int reqPort = request.getServerPort();
|
||||
|
||||
if ((scheme.equals("http") && (reqPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && reqPort != DEFAULT_HTTPS_PORT)) {
|
||||
link.append(":");
|
||||
link.append(reqPort);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (
|
||||
(scheme != null) && !scheme.equals(request.getScheme())) {
|
||||
else if ((scheme != null) && !scheme.equals(request.getScheme())) {
|
||||
changedScheme = true;
|
||||
link.append(scheme);
|
||||
link.append("://");
|
||||
@@ -169,7 +181,11 @@ public class UrlHelper {
|
||||
}
|
||||
|
||||
//if the action was not explicitly set grab the params from the request
|
||||
buildParametersString(params, link);
|
||||
if (escapeAmp) {
|
||||
buildParametersString(params, link);
|
||||
} else {
|
||||
buildParametersString(params, link, "&");
|
||||
}
|
||||
|
||||
String result;
|
||||
|
||||
|
||||
@@ -1 +1,23 @@
|
||||
<!--
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
-->
|
||||
<body>Miscellaneous helper classes for all views.</body>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user