Compare commits

...

119 Commits

Author SHA1 Message Date
René Gielen 10479d7f6e WW-2870:
Fix wrong tag

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_X@718146 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 23:55:15 +00:00
René Gielen e44b55c667 WW-2870:
Tag r718077 as Struts 2.0.14

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/STRUTS_2_0_X@718080 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 18:49:35 +00:00
René Gielen 5a7d6b4e3a WW-2872:
- Fix broken SCM links

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718077 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 18:40:09 +00:00
René Gielen 8df7b12669 [maven-release-plugin] prepare release STRUTS_2_0_14
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718050 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 15:56:25 +00:00
René Gielen 4fa6868d1d WW-2872:
Fix wrong SCM info for 2.0.X branch poms

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718047 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 15:39:47 +00:00
René Gielen 49f219dce6 WW-2872:
Fix wrong SCM info for 2.0.X branch poms

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718046 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 15:28:05 +00:00
René Gielen 41c7c5d1cf WW-2872:
Trying to fix release process

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718045 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 15:16:45 +00:00
René Gielen 7cca7b97cb WW-2872:
Moving gpg plugin to release profile

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718040 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 14:39:15 +00:00
René Gielen 220570ecba WW-2870:
Prepare 2.0.14 release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718029 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 13:40:41 +00:00
René Gielen 2b36c400e2 WW-2872:
- retrotranslator plugin seems to cause troubles, deactivating for now

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718013 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 12:34:03 +00:00
René Gielen a19a055786 WW-2872:
- activating releaseProfile

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@718006 13f79535-47bb-0310-9956-ffa450edef68
2008-11-16 11:35:00 +00:00
René Gielen 4fea4d6a5e WW-2872:
- Try to fix retrotranslator assembly
- move gpg invokation phase to deploy

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@717918 13f79535-47bb-0310-9956-ffa450edef68
2008-11-15 19:41:41 +00:00
René Gielen 1b09c6fb78 WW-2872:
Fix annotations dependency

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@717888 13f79535-47bb-0310-9956-ffa450edef68
2008-11-15 17:36:04 +00:00
René Gielen 36844a708d WW-2872:
Fix scm urls for 2.0.x branch

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@717885 13f79535-47bb-0310-9956-ffa450edef68
2008-11-15 17:27:54 +00:00
René Gielen 8b6b326f6e WW-2872:
Release Process Enhancements

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@717880 13f79535-47bb-0310-9956-ffa450edef68
2008-11-15 17:05:40 +00:00
Rainer Hermanns e574036f28 WW-2870
Updated xwork dep to latest release 2.0.7

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@714266 13f79535-47bb-0310-9956-ffa450edef68
2008-11-15 14:06:32 +00:00
René Gielen 711028d90c WW-2852:
Switch to 2.0.14-SNAPSHOT version

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@708409 13f79535-47bb-0310-9956-ffa450edef68
2008-10-28 00:40:56 +00:00
René Gielen 59d0cc5e56 WW-2852:
Prepare 2.0.13 release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@708360 13f79535-47bb-0310-9956-ffa450edef68
2008-10-27 22:36:20 +00:00
René Gielen a30b723c0c WW-2849:
Refatoring to provide better testability for static resource resolution

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@708334 13f79535-47bb-0310-9956-ffa450edef68
2008-10-27 21:46:04 +00:00
Musachy Barroso 6110e4d303 Fix merge from trunk. WW-2849
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@708200 13f79535-47bb-0310-9956-ffa450edef68
2008-10-27 14:37:53 +00:00
René Gielen 431b3531f0 WW-2836
Switching to 2.0.13-SNAPSHOT

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@705148 13f79535-47bb-0310-9956-ffa450edef68
2008-10-16 07:11:02 +00:00
René Gielen fd687de750 WW-2836:
Preparing Struts 2.0.12 release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@705105 13f79535-47bb-0310-9956-ffa450edef68
2008-10-16 00:19:37 +00:00
Rainer Hermanns 9438281e6a WW-2836
Updated xwork dep to latest bugfix/security fix release 2.0.6

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@704626 13f79535-47bb-0310-9956-ffa450edef68
2008-10-14 19:17:32 +00:00
René Gielen 34521fb906 XW-623:
Change MULTI_TEXTVALUE_SPARATOR into a property configurable by injection of constant named xwork.validatorfileparser.multi_textvalue_separator

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@694960 13f79535-47bb-0310-9956-ffa450edef68
2008-09-13 15:01:00 +00:00
David Newton 8ab8bfeb04 Backing out premature change :(
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@692669 13f79535-47bb-0310-9956-ffa450edef68
2008-09-06 15:46:52 +00:00
David Newton 2d3a1a8b88 Changed includeParams default to "none".
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@692661 13f79535-47bb-0310-9956-ffa450edef68
2008-09-06 15:26:29 +00:00
René Gielen ff8b655c4b WW-2779:
Applying Musachy's fix to 2.0.x branch

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@687874 13f79535-47bb-0310-9956-ffa450edef68
2008-08-21 21:56:46 +00:00
Wendy Smoak 9ee344feca Avoid overwriting the 2.x website where we publish 2.1.x snapshot docs.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@680226 13f79535-47bb-0310-9956-ffa450edef68
2008-07-28 02:37:07 +00:00
Wendy Smoak f382908469 [WW-2734] Fix impossible casts, reported by FindBugs.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@680067 13f79535-47bb-0310-9956-ffa450edef68
2008-07-27 06:25:58 +00:00
Wendy Smoak 6cda019a6c [WW-2734] Fix an impossible cast, reported by FindBugs.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@680066 13f79535-47bb-0310-9956-ffa450edef68
2008-07-27 06:00:31 +00:00
René Gielen 061d23071a Fix broken jar signing with maven
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@678133 13f79535-47bb-0310-9956-ffa450edef68
2008-07-19 11:25:19 +00:00
René Gielen 94dfae3ef1 Back to 2.0.12-SNAPSHOT
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@670494 13f79535-47bb-0310-9956-ffa450edef68
2008-06-23 09:31:49 +00:00
René Gielen 52b6a00e37 WW-2693:
Preparing security fix release 2.0.11.2

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@670383 13f79535-47bb-0310-9956-ffa450edef68
2008-06-22 16:55:23 +00:00
Antonio Petrelli ee2d3371e1 WW-2538
Removed the "close" call of the writer of the response.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@668256 13f79535-47bb-0310-9956-ffa450edef68
2008-06-16 18:27:18 +00:00
Rainer Hermanns 1470efd592 WW-2541 Backport WW-1951 to struts stable
o patch by Jelmer Kuperus applied

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@667583 13f79535-47bb-0310-9956-ffa450edef68
2008-06-13 16:19:32 +00:00
Rainer Hermanns 190c97eb71 updated to use xwork 2.0.5 security fix release
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@667582 13f79535-47bb-0310-9956-ffa450edef68
2008-06-13 16:15:54 +00:00
James Mitchell da6a6df41c WW-2567 Backported DateTimePicker thread safety issues.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@658363 13f79535-47bb-0310-9956-ffa450edef68
2008-05-20 17:59:18 +00:00
Donald J. Brown 90083b4255 Adding cargo version to fix tests
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@649044 13f79535-47bb-0310-9956-ffa450edef68
2008-04-17 10:34:27 +00:00
René Gielen 6294ee38c1 WW-2524,WW-2482:
Re-applying fix after doing the 2.0.11.1 security fix release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@632856 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 21:54:46 +00:00
René Gielen 9bda39bc2f WW-2524:
Switching back to 2.0.12-SNAPSHOT for 2.0.x branch HEAD

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@632851 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 21:41:37 +00:00
René Gielen 20f933e780 WW-2524:
setting 2.0.11.1 version labels for upcoming release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@632761 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 14:07:28 +00:00
René Gielen 9f556fdbac WW-2524:
setting 2.0.11.1 version labels for upcoming release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@632759 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 14:01:14 +00:00
René Gielen b24d376038 WW-2524:
Temporarily disabling patch for a clean 2.0.11.1 fast track security fix release

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@632754 13f79535-47bb-0310-9956-ffa450edef68
2008-03-02 13:15:57 +00:00
René Gielen 93866341ec WW-2427:
Applied Don Brown's fix for escaping double quote in href to 2.0.x tree

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@630742 13f79535-47bb-0310-9956-ffa450edef68
2008-02-25 06:26:12 +00:00
René Gielen dbc620f84f WW-2414:
Applied James Mitchell's patch for critical XSS bug to 2.0.x tree

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@630740 13f79535-47bb-0310-9956-ffa450edef68
2008-02-25 06:09:14 +00:00
René Gielen f88805221f WW-2482:
Fix Freemarker exception when model list entry has null value field

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@620838 13f79535-47bb-0310-9956-ffa450edef68
2008-02-12 16:05:59 +00:00
James Holmes a784fd662c Update Struts 2 version.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@579250 13f79535-47bb-0310-9956-ffa450edef68
2007-09-25 13:59:01 +00:00
Ted Nathan Husted 9e468f66ec WW-2054 Update poms for 2.0.12-SNAPSHOT.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@578352 13f79535-47bb-0310-9956-ffa450edef68
2007-09-22 01:49:24 +00:00
Ted Nathan Husted d347672f8f WW-2054 Update poms for 2.0.11 tag.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@578325 13f79535-47bb-0310-9956-ffa450edef68
2007-09-21 23:58:16 +00:00
James Holmes 9118148e08 WW-2181 SessionAware documentation is misleading about unit testing
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@576956 13f79535-47bb-0310-9956-ffa450edef68
2007-09-18 15:52:26 +00:00
James Holmes 564cff6a13 WW-2188 Incompatible API Change in Component.java
Deprecate the old method.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@576454 13f79535-47bb-0310-9956-ffa450edef68
2007-09-17 14:35:17 +00:00
James Holmes 0dd1925b4d WW-2188 Incompatible API Change in Component.java
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@576442 13f79535-47bb-0310-9956-ffa450edef68
2007-09-17 13:57:39 +00:00
James Holmes 155b9120cf WW-2183 XSLT result type is extremely slow for actions that produce a large xml document
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@575840 13f79535-47bb-0310-9956-ffa450edef68
2007-09-15 01:05:16 +00:00
Ted Nathan Husted 48c056c3ec ww-2054 Update POMs for Struts 2.0.11-SNAPSHOT.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@575137 13f79535-47bb-0310-9956-ffa450edef68
2007-09-13 01:41:55 +00:00
Ted Nathan Husted 07e24cccbf ww-2054 Update POMs for second 2.0.10 run. Fix portlet artifact name.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@575121 13f79535-47bb-0310-9956-ffa450edef68
2007-09-12 23:34:52 +00:00
Ted Nathan Husted a81e5db09d [maven-release-plugin] prepare for next development iteration
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@574412 13f79535-47bb-0310-9956-ffa450edef68
2007-09-10 23:56:19 +00:00
Ted Nathan Husted 93948e3287 [maven-release-plugin] prepare release struts2-parent-2.0.10
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@574410 13f79535-47bb-0310-9956-ffa450edef68
2007-09-10 23:55:54 +00:00
Nils-Helge Garli 6793ca3737 WW-2164 Backport to 2.0.x branch for error in url when namespace is blank.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@574349 13f79535-47bb-0310-9956-ffa450edef68
2007-09-10 19:55:07 +00:00
Antonio Petrelli b2dc2d3e0e WW-2075
Merge from trunk to STRUTS_2_0_X.
Added configuration to "struts-parent".

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@574268 13f79535-47bb-0310-9956-ffa450edef68
2007-09-10 14:49:47 +00:00
James Holmes f69f5bd22f Fix typo.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@572864 13f79535-47bb-0310-9956-ffa450edef68
2007-09-05 02:42:24 +00:00
Donald J. Brown afe66729d2 Added better error message when a Struts tag is used w/o its filter
WW-1969


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@572226 13f79535-47bb-0310-9956-ffa450edef68
2007-09-03 03:25:47 +00:00
Donald J. Brown 6d7038d9ee Fixing j5-j6 bug in test WW-2045
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@572220 13f79535-47bb-0310-9956-ffa450edef68
2007-09-03 02:46:43 +00:00
James Holmes 7705a823d0 WW-2135 The FreeMarker tag name for the DateTimePicker doesn't match TLD
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@570529 13f79535-47bb-0310-9956-ffa450edef68
2007-08-28 19:04:52 +00:00
James Holmes 7e52314ff9 WW-2142 input streams need to be explicitly closed
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@570513 13f79535-47bb-0310-9956-ffa450edef68
2007-08-28 18:14:00 +00:00
Nils-Helge Garli 16cf6524e4 WW-2105 Added redirectAction-example
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@569333 13f79535-47bb-0310-9956-ffa450edef68
2007-08-24 10:30:27 +00:00
Nils-Helge Garli 76e76ffe95 Backported changes to portlet sample application from 2.1
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@569307 13f79535-47bb-0310-9956-ffa450edef68
2007-08-24 09:16:30 +00:00
Nils-Helge Garli 21ae89b1a8 WW-2013 Backport to 2.0.x
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@569305 13f79535-47bb-0310-9956-ffa450edef68
2007-08-24 09:13:29 +00:00
Nils-Helge Garli da14faef1e WW-1713 Backport to 2.0.x
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@569304 13f79535-47bb-0310-9956-ffa450edef68
2007-08-24 09:12:20 +00:00
René Gielen accd8b1761 WW-1989, WW-2052, WW-2053, WW-2101, WW-2105:
Backporting portlet servlet wrapping, portlet redirect/redirectAction result and related issues to 2.0.x

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@568896 13f79535-47bb-0310-9956-ffa450edef68
2007-08-23 09:05:56 +00:00
René Gielen a794a46e37 WW-1989, WW-2052, WW-2053, WW-2101, WW-2105:
Backporting portlet servlet wrapping, portlet redirect/redirectAction result and related issues to 2.0.x

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@568895 13f79535-47bb-0310-9956-ffa450edef68
2007-08-23 08:57:36 +00:00
René Gielen 34591eb73a WW-1989, WW-2052, WW-2053, WW-2101, WW-2105:
Backporting portlet servlet wrapping, portlet redirect/redirectAction result and related issues to 2.0.x

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@568894 13f79535-47bb-0310-9956-ffa450edef68
2007-08-23 08:54:10 +00:00
René Gielen e87f7868c1 WW-1989, WW-2052, WW-2053, WW-2101, WW-2105:
Backporting portlet servlet wrapping, portlet redirect/redirectAction result and related issues to 2.0.x

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@568892 13f79535-47bb-0310-9956-ffa450edef68
2007-08-23 08:51:20 +00:00
René Gielen 87f408fd81 WW-1989, WW-2052, WW-2053, WW-2101, WW-2105:
Backporting portlet servlet wrapping, portlet redirect/redirectAction result and related issues to 2.0.x

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@568888 13f79535-47bb-0310-9956-ffa450edef68
2007-08-23 08:48:28 +00:00
James Holmes 4c851bb36c WW-2015 url tag, method attribute not evaluating expressions (ognl)
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@566730 13f79535-47bb-0310-9956-ffa450edef68
2007-08-16 14:32:53 +00:00
James Holmes 67066e0ded WW-1977 Struts throws stack trace instead of 404 when an action doesn't exist
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@566474 13f79535-47bb-0310-9956-ffa450edef68
2007-08-16 02:55:44 +00:00
James Holmes bd2eb6b8f8 WW-2115 Add Portuguese translation of struts-messages.properties
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@566417 13f79535-47bb-0310-9956-ffa450edef68
2007-08-15 23:59:21 +00:00
James Holmes e89e5934da WW-2115 Add Portuguese translation of struts-messages.properties
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@566414 13f79535-47bb-0310-9956-ffa450edef68
2007-08-15 23:58:15 +00:00
James Holmes 53d1d54536 WW-2103 Invalid Javascript generated for StringLength validator
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@566209 13f79535-47bb-0310-9956-ffa450edef68
2007-08-15 14:55:54 +00:00
James Holmes 6a2daa73cf WW-2058 Client side validation in xhtml template and clearErrorMessages not working in firefox with hidden fields
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@566190 13f79535-47bb-0310-9956-ffa450edef68
2007-08-15 14:35:19 +00:00
James Mitchell 91bbaf81cb WW-2089 align jetty config as to what is in trunk
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565854 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 18:50:57 +00:00
James Holmes 7323b8176e WW-2110 css_xhtml checkbox.ftl renders one </div> to many when no label exists
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565842 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 17:25:15 +00:00
James Holmes 09628422b9 WW-1761 templates don't specify type="text/javascript"; break W3C validation
Fixed issue of extra type="text/javascript" that was added during the fix for the original opening of the WW-1761 ticket.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565752 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 13:45:49 +00:00
René Gielen 4717110ea2 WW-2109:
id resolution for <s:form> - minor cleanups

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565746 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 13:40:12 +00:00
René Gielen 065844e9bf WW-2109:
- "Intelligent" id resolution for <s:form> does not work as documented
- minor cleanups

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565697 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 10:28:35 +00:00
René Gielen 28d5931300 WW-2109:
"Intelligent" id resolution for <s:form> does not work as documented

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565695 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 10:21:53 +00:00
René Gielen 2fa6e12b41 WW-1993:
Clarification about XWorks's new DefaultObjectDeterminer which includes the generics funtionailty of deprecated GenericsObjectDeterminer

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565686 13f79535-47bb-0310-9956-ffa450edef68
2007-08-14 10:02:21 +00:00
James Holmes a96e4bc920 WW-1950 UrlHelper.buildUrl does not output port even if forceAddSchemeHostAndPort turned on (TestCase included)
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565492 13f79535-47bb-0310-9956-ffa450edef68
2007-08-13 20:00:08 +00:00
James Holmes 1dcfb715c7 WW-1948 s:url tag does not provide forceAddSchemeHostAndPort parameter
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565422 13f79535-47bb-0310-9956-ffa450edef68
2007-08-13 17:09:16 +00:00
René Gielen 02c7107516 WW-2108:
Make <s:tabbedpanel> being able to remember last selected tab using a cookie

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565265 13f79535-47bb-0310-9956-ffa450edef68
2007-08-13 08:18:07 +00:00
Donald J. Brown 00cf94d8e5 Turning off JSP EL for all Struts 2 tag attributes, as they are all processed for OGNL
expressions
WW-2107


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@565259 13f79535-47bb-0310-9956-ffa450edef68
2007-08-13 07:55:18 +00:00
James Mitchell df634942e5 WW-2060 remove exclusion reference to domTT.js, which is not even in svn
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@563502 13f79535-47bb-0310-9956-ffa450edef68
2007-08-07 13:58:00 +00:00
James Mitchell 2b96ceaaa1 WW-2054 fix simple typos
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@563491 13f79535-47bb-0310-9956-ffa450edef68
2007-08-07 13:05:43 +00:00
James Mitchell 3e6d92462c WW-2060 add credit where credit is due
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@563483 13f79535-47bb-0310-9956-ffa450edef68
2007-08-07 13:00:08 +00:00
James Holmes 8f18766de8 Fix typos.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@562019 13f79535-47bb-0310-9956-ffa450edef68
2007-08-02 05:28:56 +00:00
James Holmes 57b5229afd Fix typos.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@562016 13f79535-47bb-0310-9956-ffa450edef68
2007-08-02 05:15:23 +00:00
James Holmes 24940124fc WW-2080 actionError, actionMessage and fieldError Freemarker templates do not honor the cssClass and cssStyle attributes
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561850 13f79535-47bb-0310-9956-ffa450edef68
2007-08-01 16:02:23 +00:00
James Holmes 13bd5c8b3e Fix typo.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561842 13f79535-47bb-0310-9956-ffa450edef68
2007-08-01 15:32:30 +00:00
James Holmes 011021a77f Fix typo.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561837 13f79535-47bb-0310-9956-ffa450edef68
2007-08-01 15:19:22 +00:00
James Holmes ab035f743d Fix typo.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561831 13f79535-47bb-0310-9956-ffa450edef68
2007-08-01 15:16:04 +00:00
James Holmes 2735f31349 Log a warning if user specifies a namespace and action with the <s:form> tag and the action is not found in the namespace. Right now this fails silently and the user gets an HTTP 404 typically. I've had this happen to me and it took a little while to realize I had the wrong namespace or action name. This warning should help users figure out the issue faster by giving them a heads up.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561617 13f79535-47bb-0310-9956-ffa450edef68
2007-08-01 01:08:36 +00:00
James Holmes 01705e68ec Fix typos.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561601 13f79535-47bb-0310-9956-ffa450edef68
2007-07-31 23:54:34 +00:00
James Holmes 9ed9973e1f Fix formatting to be all spaces instead of a mix of spaces and tabs.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561222 13f79535-47bb-0310-9956-ffa450edef68
2007-07-31 02:57:33 +00:00
James Holmes f11cc5c69c Specify XML version and encoding.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561220 13f79535-47bb-0310-9956-ffa450edef68
2007-07-31 02:45:40 +00:00
James Holmes db3b2c6b4b Fix formatting to be all spaces instead of a mix of spaces and tabs. Also fix init param comments that were incorrect.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@561217 13f79535-47bb-0310-9956-ffa450edef68
2007-07-31 02:35:32 +00:00
René Gielen 7b5a6d4b38 Code cleanups / generification
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560894 13f79535-47bb-0310-9956-ffa450edef68
2007-07-30 09:05:32 +00:00
René Gielen acc7495fe9 WW-1661:
Backporting Freemarker template caching to 2.0.x tree

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560881 13f79535-47bb-0310-9956-ffa450edef68
2007-07-30 07:05:55 +00:00
Antonio Petrelli 7b2fb236fc WW-2049
Merge from trunk to STRUTS_2_0_X branch.
Added licenses to plugins code.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560753 13f79535-47bb-0310-9956-ffa450edef68
2007-07-29 16:18:28 +00:00
Antonio Petrelli 5b5ac79c76 WW-2049
Added licenses specific of STRUTS_2_0_X branch.
Added configuration of RAT plugin in core/pom.xml to exclude some third-party files.


git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560697 13f79535-47bb-0310-9956-ffa450edef68
2007-07-29 08:58:03 +00:00
Antonio Petrelli c6e94237f9 WW-2049
Merge from trunk to STRUTS_2_0_X branch.
Added license to core/pom.xml.
Added configuration of RAT plugin in core/pom.xml to exclude some testing and generated files.
Third bunch of added licenses.
The STRUTS_2_0_X branch has special files that need to be license-fixed.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560558 13f79535-47bb-0310-9956-ffa450edef68
2007-07-28 15:47:10 +00:00
Musachy Barroso e6a0b64097 WW-2048 AnchorTag has no setter method corresponding to TLD declared attribute 'onLoadJS'
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560385 13f79535-47bb-0310-9956-ffa450edef68
2007-07-27 21:13:04 +00:00
René Gielen 29cf30f7ed WW-2007:
Fixing problems with generated javascript idetitifiers containing unescaped id parameter value

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@560260 13f79535-47bb-0310-9956-ffa450edef68
2007-07-27 14:57:26 +00:00
James Holmes 1d5b8d05a7 WW-2064 XHTML checkbox template does not include tooltip consistently
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@559846 13f79535-47bb-0310-9956-ffa450edef68
2007-07-26 15:12:01 +00:00
Antonio Petrelli 5101ea1019 WW-2049
Merge from trunk to STRUTS_2_0_X branch.
Second bunch of added licenses.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@559615 13f79535-47bb-0310-9956-ffa450edef68
2007-07-25 21:25:25 +00:00
Antonio Petrelli df8e7346c2 WW-2049
Merge from trunk to STRUTS_2_0_X branch.
Added RAT report to the site.
First bunch of corrected licenses.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@559543 13f79535-47bb-0310-9956-ffa450edef68
2007-07-25 18:05:51 +00:00
James Holmes 5bbc080605 WW-1911 File Upload: content-type validation fails when no file is uploaded
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@559304 13f79535-47bb-0310-9956-ffa450edef68
2007-07-25 03:39:12 +00:00
James Holmes aa17d06e76 WW-1938 Bug with multiple s:param tags inside s:url tag
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@559146 13f79535-47bb-0310-9956-ffa450edef68
2007-07-24 18:15:13 +00:00
James Holmes 8c11875991 WW-2038 Extra carriage returns in simple theme templates
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@558925 13f79535-47bb-0310-9956-ffa450edef68
2007-07-24 04:29:25 +00:00
Ted Nathan Husted 0364dfa037 WW-2054 Update POM for Struts 2.0.10-SNAPSHOT.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/branches/STRUTS_2_0_X@558852 13f79535-47bb-0310-9956-ffa450edef68
2007-07-23 20:18:39 +00:00
Ted Nathan Husted 047226193e WW-1705 Branching at 2_0_5 tag
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_X@506170 13f79535-47bb-0310-9956-ffa450edef68
2007-02-11 23:25:53 +00:00
483 changed files with 12609 additions and 3396 deletions
+6 -14
View File
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-blank</artifactId>
@@ -13,9 +12,9 @@
<name>Blank Webapp</name>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/blank/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/blank/</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/blank/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/blank</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/blank</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/apps/blank</url>
</scm>
<dependencies>
@@ -48,17 +47,10 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.0.1</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-j2ee_1.4_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
+5 -6
View File
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-mailreader</artifactId>
@@ -13,9 +12,9 @@
<name>Starter Webapp</name>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/mailreader/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/mailreader/</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/mailreader/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/mailreader</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/mailreader</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/apps/mailreader</url>
</scm>
<dependencies>
+1 -1
View File
@@ -6,7 +6,7 @@
<struts>
<constant name="struts.action.extension" value="do" />
<constant name="struts.devMode" value="false" />
<constant name="struts.devMode" value="true" />
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<include file="mailreader-default.xml"/>
+4 -1
View File
@@ -9,14 +9,17 @@
type="text/css"/>
</head>
<body onLoad="self.focus();document.Login.username.focus()">
<body onload="self.focus();document.Login.username.focus()">
<s:actionerror />
<s:text name="doesntexist" />
<s:form action="Login" validate="true">
<s:textfield key="username" />
<s:password key="password" showPassword="true"/>
<s:textfield name="doesntexist" />
<s:submit key="button.save"/>
<s:reset key="button.reset"/>
@@ -20,6 +20,7 @@
<li><a href="<s:url action="Logout"/>">
<s:text name="mainMenu.logout"/>
</a>
</li>
</ul>
</body>
</html>
@@ -14,7 +14,7 @@
type="text/css"/>
</head>
<body onLoad="self.focus();document.Registration_save_username.focus()">
<body onload="self.focus();document.Registration_save_username.focus()">
<s:actionerror/>
<s:form action="Registration_save" validate="false">
@@ -17,7 +17,7 @@
type="text/css"/>
</head>
<body onLoad="self.focus();document.Subscription.username.focus()">
<body onload="self.focus();document.Subscription.username.focus()">
<s:actionerror/>
<s:form action="Subscription_save" validate="true">
+29 -29
View File
@@ -182,36 +182,36 @@
&lt;display-name>Struts 2 MailReader&lt;/display-name>
<strong>&lt;filter>
&lt;filter-name>struts2&lt;/filter-name>
&lt;filter-class>
<strong>&lt;filter&gt;
&lt;filter-name&gt;struts2&lt;/filter-name&gt;
&lt;filter-class&gt;
org.apache.struts2.dispatcher.FilterDispatcher
&lt;/filter-class>
&lt;/filter></strong>
&lt;/filter-class&gt;
&lt;/filter&gt;</strong>
&lt;filter-mapping>
&lt;filter-name><strong>struts2</strong>&lt;/filter-name>
&lt;url-pattern>/*&lt;/url-pattern>
&lt;/filter-mapping>
&lt;filter-mapping&gt;
&lt;filter-name&gt;<strong>struts2</strong>&lt;/filter-name&gt;
&lt;url-pattern&gt;/*&lt;/url-pattern&gt;
&lt;/filter-mapping&gt;
&lt;listener>
&lt;listener-class>
&lt;listener&gt;
&lt;listener-class&gt;
org.springframework.web.context.ContextLoaderListener
&lt;/listener-class>
&lt;/listener>
&lt;/listener-class&gt;
&lt;/listener&gt;
&lt;!-- Application Listener for MailReader database -->
&lt;listener>
&lt;listener-class>
&lt;!-- Application Listener for MailReader database --&gt;
&lt;listener&gt;
&lt;listener-class&gt;
mailreader2.ApplicationListener
&lt;/listener-class>
&lt;/listener>
&lt;/listener-class&gt;
&lt;/listener&gt;
&lt;welcome-file-list>
&lt;welcome-file>index.html&lt;/welcome-file>
&lt;/welcome-file-list>
&lt;welcome-file-list&gt;
&lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
&lt;/welcome-file-list&gt;
&lt;/web-app></code></pre>
&lt;/web-app&gt;</code></pre>
<hr/>
<p>
@@ -281,13 +281,13 @@
<hr/>
<h5>MailReader's index.html</h5>
<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&lt;html>&lt;head>
&lt;META HTTP-EQUIV="Refresh" CONTENT="0;<strong>URL=Welcome.do</strong>">
&lt;/head>
&lt;body>
&lt;p>Loading ...&lt;/p>
&lt;/body>&lt;/html></code></pre>
<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;html&gt;&lt;head&gt;
&lt;META HTTP-EQUIV="Refresh" CONTENT="0;<strong>URL=Welcome.do</strong>"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Loading ...&lt;/p&gt;
&lt;/body&gt;&lt;/html&gt;</code></pre>
<hr/>
<p>
+13 -40
View File
@@ -1,31 +1,9 @@
<?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$
*/
-->
<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">
<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>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
@@ -39,9 +17,9 @@
</modules>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/apps</url>
</scm>
<distributionManagement>
@@ -105,14 +83,10 @@
</goals>
<configuration>
<tasks>
<taskdef resource="hostedqatasks" classpathref="maven.plugin.classpath"/>
<upload file="${project.build.directory}/${project.build.finalName}.war"
account="struts" email="${email}"
password="${password}" resourceId="${resourceId}"/>
<taskdef resource="hostedqatasks" classpathref="maven.plugin.classpath" />
<upload file="${project.build.directory}/${project.build.finalName}.war" account="struts" email="${email}" password="${password}" resourceId="${resourceId}" />
<playsuite suiteId="${suiteId}" clientConfigs="${clientConfigs}" appConfigs="${appConfigs}" account="struts"
email="${email}"
password="${password}"/>
<playsuite suiteId="${suiteId}" clientConfigs="${clientConfigs}" appConfigs="${appConfigs}" account="struts" email="${email}" password="${password}" />
</tasks>
</configuration>
</execution>
@@ -135,6 +109,7 @@
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>0.3.1</version>
<configuration>
<container>
<containerId>tomcat5x</containerId>
@@ -156,13 +131,11 @@
<phase>process-sources</phase>
<configuration>
<tasks>
<copy todir="${project.build.directory}/${pom.artifactId}/WEB-INF/src/java"
failonerror="false">
<fileset dir="${basedir}/src/main/java"/>
<copy todir="${project.build.directory}/${pom.artifactId}/WEB-INF/src/java" failonerror="false">
<fileset dir="${basedir}/src/main/java" />
</copy>
<copy todir="${project.build.directory}/${pom.artifactId}/WEB-INF/src/java"
failonerror="false">
<fileset dir="${basedir}/src/main/resources"/>
<copy todir="${project.build.directory}/${pom.artifactId}/WEB-INF/src/java" failonerror="false">
<fileset dir="${basedir}/src/main/resources" />
</copy>
</tasks>
</configuration>
+27 -17
View File
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-portlet</artifactId>
@@ -13,9 +12,9 @@
<name>Portlet Webapp</name>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/portlet/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/portlet/</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/portlet/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/portlet</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/portlet</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/apps/portlet</url>
</scm>
<dependencies>
@@ -29,6 +28,12 @@
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${pom.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
@@ -51,20 +56,25 @@
<artifactId>commons-digester</artifactId>
<version>1.8</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>
<version>2.0</version>
<version>2.1</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.12</version>
</dependency>
</dependencies>
</project>
@@ -44,4 +44,7 @@ public class FormExample extends ActionSupport {
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String displayResult() {
return "displayResult";
}
}
@@ -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;
}
}
@@ -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}&amp;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,130 @@
<?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="formExamplePrg" class="org.apache.struts2.portlet.example.FormExample">
<result name="input">
/WEB-INF/view/formExampleInputPrg.jsp
</result>
<result name="success" type="redirectAction">
<param name="actionName">formExamplePrg</param>
<param name="method">displayResult</param>
<param name="firstName">${firstName}</param>
<param name="lastName">${lastName}</param>
</result>
<result name="displayResult">
/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}&amp;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>
+4 -155
View File
@@ -4,159 +4,8 @@
"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}&amp;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}&amp;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-portlet-default.xml"/>
<include file="struts-view.xml"/>
<include file="struts-edit.xml"/>
<include file="struts-help.xml"/>
</struts>
+117 -103
View File
@@ -1,118 +1,132 @@
<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>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
<portlet-mode>view</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>
<portlet-mode>view</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>
@@ -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>
@@ -0,0 +1,8 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<H2>Input your name</H2>
<s:form action="formExamplePrg" 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,12 @@
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="formExamplePrg" method="input"/>">Form example with proper PRG</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>
+23 -42
View File
@@ -1,49 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app id="StrutsPortlet">
<!-- 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>
</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>
<!-- 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>
</context-param>
<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.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.apache.struts2.portlet.context.ServletContextHolderListener
</listener-class>
</listener>
<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>
</web-app>
+5 -6
View File
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-apps</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-showcase</artifactId>
@@ -13,9 +12,9 @@
<name>Showcase Webapp</name>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/apps/showcase/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/apps/showcase/</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/apps/showcase/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/showcase</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/apps/showcase</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/apps/showcase</url>
</scm>
@@ -70,15 +70,23 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
}
}
pageLines = read(in, -1);
if (in != null) {
in.close();
}
}
if (className != null && className.trim().length() > 0) {
className = "/"+className.replace('.', '/') + ".java";
className = "/" + className.replace('.', '/') + ".java";
InputStream in = getClass().getResourceAsStream(className);
if (in == null) {
in = servletContext.getResourceAsStream("/WEB-INF/src"+className);
}
classLines = read(in, -1);
if (in != null) {
in.close();
}
}
if (config != null && config.trim().length() > 0) {
@@ -118,8 +126,6 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
this.padding = padding;
}
/**
* @return the classLines
*/
@@ -215,6 +221,4 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
public void setServletContext(ServletContext arg0) {
this.servletContext = arg0;
}
}
+2 -1
View File
@@ -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).
@@ -30,7 +30,7 @@
<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>
<result>modelDriven.jsp</result>
+24 -37
View File
@@ -1,26 +1,4 @@
<?xml version="1.0"?>
<!--
/*
* 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$
*/
-->
<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">
<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>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-assembly</artifactId>
@@ -33,14 +11,13 @@
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/assembly</connection>
<developerConnection>
scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/assembly</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/assembly</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/assembly</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/assembly</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/assembly</url>
</scm>
<build>
@@ -103,7 +80,7 @@
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<classifier>javadoc</classifier>
<version>2.0.4</version>
<version>2.0.7</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/xwork-apidocs</outputDirectory>
@@ -119,12 +96,9 @@
<phase>process-resources</phase>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/cwiki"/>
<get src="http://struts.apache.org/2.x/docs.zip"
dest="${project.build.directory}/docs.zip"
ignoreerrors="false"/>
<unzip src="${project.build.directory}/docs.zip"
dest="${project.build.directory}/cwiki"/>
<mkdir dir="${project.build.directory}/cwiki" />
<get src="http://struts.apache.org/2.x/docs.zip" dest="${project.build.directory}/docs.zip" ignoreerrors="false" />
<unzip src="${project.build.directory}/docs.zip" dest="${project.build.directory}/cwiki" />
</tasks>
</configuration>
<goals>
@@ -135,13 +109,26 @@
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.0.1</version>
<version>2.2-beta-1</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptors>
<descriptor>src/main/assembly/all.xml</descriptor>
<descriptor>src/main/assembly/lib.xml</descriptor>
<!--
<descriptor>src/main/assembly/lib-jdk14.xml</descriptor>
-->
<descriptor>src/main/assembly/apps.xml</descriptor>
<descriptor>src/main/assembly/src.xml</descriptor>
<descriptor>src/main/assembly/docs.xml</descriptor>
</descriptors>
<finalName>struts-${version}</finalName>
<outputDirectory>target/assembly/out</outputDirectory>
@@ -448,4 +435,4 @@
</dependencies>
</project>
</project>
+22
View File
@@ -27,6 +27,12 @@
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>net.sf.retrotranslator:retrotranslator-runtime</exclude>
<exclude>backport-util-concurrent:backport-util-concurrent</exclude>
<exclude>junit:junit</exclude>
<exclude>*:jdk14</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
@@ -80,6 +86,10 @@
<outputDirectory>docs/struts2-plugins/struts2-$plugin-plugin</outputDirectory>
</fileSet>
-->
<fileSet>
<directory>../plugins/codebehind/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-codebehind-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/config-browser/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-config-browser-plugin</outputDirectory>
@@ -112,6 +122,10 @@
<directory>../plugins/sitegraph/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-sitegraph-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/spring/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-spring-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/sitemesh/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-sitemesh-plugin</outputDirectory>
@@ -186,5 +200,13 @@
<include>src/</include>
</includes>
</fileSet>
<fileSet>
<directory>../plugins</directory>
<outputDirectory>src/plugins</outputDirectory>
<excludes>
<exclude>*/target/**</exclude>
<exclude>target/**</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
+116
View File
@@ -0,0 +1,116 @@
<!--
/*
* $Id: docs.xml 651587 2008-04-25 12:15:09Z hermanns $
*
* 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.
*/
-->
<assembly>
<id>docs</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<!-- Include the XWork Javadoc in the assembly -->
<fileSet>
<directory>target/xwork-apidocs</directory>
<outputDirectory>docs/xwork-apidocs</outputDirectory>
</fileSet>
<!-- Include the website in the assembly -->
<fileSet>
<directory>../target/site</directory>
<outputDirectory>docs</outputDirectory>
</fileSet>
<fileSet>
<directory>../api/target/site</directory>
<outputDirectory>docs/struts2-api</outputDirectory>
</fileSet>
<fileSet>
<directory>../core/target/site</directory>
<outputDirectory>docs/struts2-core</outputDirectory>
</fileSet>
<!-- Include the Confluence docs in the assembly -->
<fileSet>
<directory>target/cwiki</directory>
<outputDirectory>docs</outputDirectory>
</fileSet>
<!-- Plugins -->
<fileSet>
<directory>../plugins/codebehind/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-codebehind-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/config-browser/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-config-browser-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jasperreports/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-jasperreports-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jfreechart/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-jfreechart-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jsf/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-jsf-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/jsf/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-junit-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/pell-multipart/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-pell-multipart-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/plexus/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-plexus-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/sitegraph/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-sitegraph-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/sitemesh/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-sitemesh-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/spring/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-spring-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/struts1/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-struts1-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/tiles/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-testng-plugin</outputDirectory>
</fileSet>
<fileSet>
<directory>../plugins/tiles/target/site</directory>
<outputDirectory>docs/struts2-plugins/struts2-tiles-plugin</outputDirectory>
</fileSet>
</fileSets>
</assembly>
+58
View File
@@ -0,0 +1,58 @@
<!--
/*
* $Id: lib-jdk14.xml 615299 2008-01-25 18:26:44Z 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.
*/
-->
<assembly>
<id>lib-jdk14</id>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet useTransitiveFiltering="true">
<outputDirectory>jdk14</outputDirectory>
<outputFileNameMapping>${artifactId}-${version}.${extension}</outputFileNameMapping>
<includes>
<include>net.sf.retrotranslator:retrotranslator-runtime</include>
<include>backport-util-concurrent:backport-util-concurrent</include>
</includes>
</dependencySet>
<dependencySet>
<useTransitiveFiltering>true</useTransitiveFiltering>
<outputDirectory>jdk14</outputDirectory>
<outputFileNameMapping>${artifactId}-${version}-jdk14.${extension}</outputFileNameMapping>
<includes>
<include>org.apache.struts:*:jar:jdk14</include>
<include>com.opensymphony:xwork:jar:jdk14</include>
</includes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>src/main/resources/backport</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
+6
View File
@@ -27,6 +27,12 @@
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
<excludes>
<exclude>net.sf.retrotranslator:retrotranslator-runtime</exclude>
<exclude>backport-util-concurrent:backport-util-concurrent</exclude>
<exclude>junit:junit</exclude>
<exclude>*:jdk14</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
-1
View File
@@ -47,7 +47,6 @@
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
<include>build.xml</include>
</includes>
</fileSet>
@@ -0,0 +1,7 @@
Apache Struts
Copyright 2000-2007 The Apache Software Foundation
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
Retrotranslator (http://retrotranslator.sourceforge.net/).
@@ -0,0 +1,29 @@
Retrotranslator: a Java bytecode transformer that translates Java classes
compiled with JDK 5.0 into classes that can be run on JVM 1.4.
Copyright (c) 2005, 2006 Taras Puchko
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
+2 -2
View File
@@ -1,2 +1,2 @@
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/struts2-core-2.0.9.jar -destjar struts2-core-j4-2.0.9.jar
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/xwork-2.0.4.jar -destjar xwork-j4-2.0.4.jar
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/struts2-core-2.0.14.jar -destjar struts2-core-j4-2.0.14.jar
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/xwork-2.0.7.jar -destjar xwork-j4-2.0.7.jar
+2 -2
View File
@@ -1,3 +1,3 @@
#!/bin/sh
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/struts2-core-2.0.9.jar -destjar struts2-core-j4-2.0.9.jar
java -jar retrotranslator-transformer-1.2.0.jar -advanced -srcjar ../lib/xwork-2.0.4.jar -destjar xwork-j4-2.0.4.jar
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/struts2-core-2.0.14.jar -destjar struts2-core-j4-2.0.14.jar
java -jar retrotranslator-transformer-1.2.2.jar -advanced -srcjar ../lib/xwork-2.0.7.jar -destjar xwork-j4-2.0.7.jar
+50 -72
View File
@@ -1,11 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!--
/*
* $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>
<parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-parent</artifactId>
<version>2.0.9</version>
<version>2.0.14</version>
</parent>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
@@ -13,9 +34,9 @@
<name>Struts 2 Core</name>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/core/</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/core/</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/core/</url>
<connection>scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/core</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_0_14/core</developerConnection>
<url>http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_0_14/core</url>
</scm>
<build>
@@ -35,7 +56,7 @@
<artifactItem>
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<version>2.0.4</version>
<version>2.0.7</version>
<classifier>sources</classifier>
</artifactItem>
</artifactItems>
@@ -107,74 +128,30 @@
</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/etc/**</exclude>
<exclude>src/main/resources/org/apache/struts2/static/dojo/src/**</exclude>
<exclude>src/main/resources/org/apache/struts2/static/dojo/*</exclude>
<exclude>src/main/resources/org/apache/struts2/static/niftycorners/**</exclude>
<exclude>src/test/resources/org/apache/struts2/interceptor/validation/*</exclude>
<exclude>src/site/resources/tags/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<!--
Run the translator for Java 1.4 compatiblity
Samples:
$ cd struts/struts2/
$ mvn clean install -Papps,j4 -Djava14.jar=$JAVA_HOME/../Classes/classes.jar
$ mvn clean install -Papps,j4 -Djava14.jar="$JAVA_HOME/jre/lib/rt.jar"
-->
<id>j4</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>retrotranslator-maven-plugin</artifactId>
<executions>
<execution>
<id>retrotranslate</id>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>create-j4-jar</id>
<goals><goal>jar</goal></goals>
<configuration>
<classesDirectory>${project.build.directory}/classes-retro</classesDirectory>
<classifier>j4</classifier>
<archive>
<manifestEntries>
<Extension-Name>${project.artifactId}-j4</Extension-Name>
<Specification-Vendor>${project.organization.name}</Specification-Vendor>
<Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
<Implementation-Title>${project.description}</Implementation-Title>
<Implementation-Version>${project.version}</Implementation-Version>
<Revision>${scm.revision}</Revision>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>rt</artifactId>
<version>1.4.0</version>
<scope>system</scope>
<!-- path to rt.jar (on OSX, it's classes.jar) -->
<systemPath>${java14.jar}</systemPath>
</dependency>
<dependency>
<groupId>net.sf.retrotranslator</groupId>
<artifactId>retrotranslator-runtime</artifactId>
<version>1.0.8</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>alljars</id>
<build>
@@ -253,7 +230,7 @@
<dependency>
<groupId>com.opensymphony</groupId>
<artifactId>xwork</artifactId>
<version>2.0.4</version>
<version>2.0.7</version>
</dependency>
<dependency>
@@ -462,6 +439,7 @@
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts-annotations</artifactId>
<scope>compile</scope>
<version>1.0.2</version>
<optional>true</optional>
</dependency>
@@ -76,6 +76,9 @@ public final class StrutsConstants {
/** The org.apache.struts2.views.freemarker.FreemarkerManager implementation class */
public static final String STRUTS_FREEMARKER_MANAGER_CLASSNAME = "struts.freemarker.manager.classname";
/** Cache Freemarker templates */
public static final String STRUTS_FREEMARKER_TEMPLATES_CACHE = "struts.freemarker.templatesCache";
/** org.apache.struts2.views.velocity.VelocityManager implementation class */
public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = "struts.velocity.manager.classname";
@@ -60,7 +60,7 @@ public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements
super.evaluateExtraParams();
if (href != null)
addParameter("href", findString(href));
addParameter("href", ensureAttributeSafelyNotEscaped(findString(href)));
if (errorText != null)
addParameter("errorText", findString(errorText));
if (loadingText != null)
@@ -41,7 +41,7 @@ import com.opensymphony.xwork2.util.ValueStack;
* <!-- START SNIPPET: example -->
*
* &lt;s:actionerror /&gt;
* &lt;s:form .... &gt;>
* &lt;s:form .... &gt;
* ....
* &lt;/s:form&gt;
*
@@ -70,7 +70,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() {
@@ -87,7 +87,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() {
@@ -95,7 +95,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() {
@@ -215,7 +215,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>.
@@ -323,7 +323,7 @@ public class Component {
}
}
/**
/**
* Renders an action URL by consulting the {@link org.apache.struts2.dispatcher.mapper.ActionMapper}.
* @param action the action
* @param namespace the namespace
@@ -336,14 +336,38 @@ public class Component {
* @param encodeResult should the url be encoded
* @return the action url.
*/
@Deprecated
protected String determineActionURL(String action, String namespace, String method,
HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme,
boolean includeContext, boolean encodeResult) {
return determineActionURL(action, namespace, method, req, res, parameters, scheme, includeContext, encodeResult, false, true);
}
/**
* Renders an action URL by consulting the {@link org.apache.struts2.dispatcher.mapper.ActionMapper}.
* @param action the action
* @param namespace the namespace
* @param method the method
* @param req HTTP request
* @param res HTTP response
* @param parameters parameters
* @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 added to the url no matter what
* @param escapeAmp should the ampersands used separate parameters be escaped or not
* @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 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);
}
/**
@@ -407,7 +431,7 @@ public class Component {
}
/**
* Get's the parameters.
* Gets the parameters.
* @return the parameters. Is never <tt>null</tt>.
*/
public Map getParameters() {
@@ -415,7 +439,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) {
@@ -423,9 +447,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.
@@ -444,7 +468,7 @@ public class Component {
}
/**
* Get's the id for referencing element.
* Gets the id for referencing element.
* @return the id for referencing element.
*/
public String getId() {
@@ -465,5 +489,4 @@ public class Component {
public boolean usesBody() {
return false;
}
}
@@ -21,7 +21,9 @@
package org.apache.struts2.components;
import java.text.ParseException;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
@@ -129,8 +131,10 @@ import com.opensymphony.xwork2.util.ValueStack;
public class DateTimePicker extends UIBean {
final public static String TEMPLATE = "datetimepicker";
final private static SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ss");
// Backported changes from s2 trunk (r657936)
// final private static SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
final private static String RFC3339_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
final private static String RFC3339_PATTERN = "{0,date," + RFC3339_FORMAT + "}";
final protected static Log LOG = LogFactory.getLog(DateTimePicker.class);
protected String iconPath;
@@ -294,12 +298,14 @@ public class DateTimePicker extends UIBean {
return null;
if(obj instanceof Date) {
return RFC3339_FORMAT.format((Date) obj);
return MessageFormat.format(RFC3339_PATTERN, (Date) obj);
} else if(obj instanceof Calendar) {
return MessageFormat.format(RFC3339_PATTERN, ((Calendar) obj).getTime());
} else {
// try to parse a date
String dateStr = obj.toString();
if(dateStr.equalsIgnoreCase("today"))
return RFC3339_FORMAT.format(new Date());
return MessageFormat.format(RFC3339_PATTERN, new Date());
try {
Date date = null;
@@ -307,7 +313,7 @@ public class DateTimePicker extends UIBean {
SimpleDateFormat format = new SimpleDateFormat(
(String) getParameters().get("displayFormat"));
date = format.parse(dateStr);
return RFC3339_FORMAT.format(date);
return MessageFormat.format(RFC3339_PATTERN, date);
} else {
// last resource to assume already in correct/default format
return dateStr;
@@ -51,7 +51,7 @@ import com.opensymphony.xwork2.util.ValueStack;
* &lt;s:param&gt;field1&lt;/s:param&gt;
* &lt;s:param&gt;field2&lt;/s:param&gt;
* &lt;/s:fielderror&gt;
* &lt;s:form .... &gt;>
* &lt;s:form .... &gt;
* ....
* &lt;/s:form&gt;
*
@@ -61,7 +61,7 @@ import com.opensymphony.xwork2.util.ValueStack;
* &lt;s:param value="%{'field1'}" /&gt;
* &lt;s:param value="%{'field2'}" /&gt;
* &lt;/s:fielderror&gt;
* &lt;s:form .... &gt;>
* &lt;s:form .... &gt;
* ....
* &lt;/s:form&gt;
*
@@ -20,24 +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;
@@ -47,12 +29,29 @@ import com.opensymphony.xwork2.config.entities.ActionConfig;
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.util.ValueStack;
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.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import org.apache.struts2.views.util.UrlHelper;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* <!-- START SNIPPET: javadoc -->
@@ -95,6 +94,11 @@ import com.opensymphony.xwork2.validator.Validator;
*/
@StrutsTag(name="form", tldTagClass="org.apache.struts2.views.jsp.ui.FormTag", description="Renders an input form")
public class Form extends ClosingUIBean {
/**
* Provide a logging instance.
*/
private static final Log LOG = LogFactory.getLog(Form.class);
public static final String OPEN_TEMPLATE = "form";
public static final String TEMPLATE = "form-close";
@@ -204,7 +208,7 @@ public class Form extends ClosingUIBean {
}
/**
* Form component determine the its HTML element id as follows:-
* The Form component determines its HTML element id as follows:-
* <ol>
* <li>if an 'id' attribute is specified.</li>
* <li>if an 'action' attribute is specified, it will be used as the id.</li>
@@ -222,6 +226,9 @@ public class Form extends ClosingUIBean {
if (id != null) {
addParameter("id", escape(id));
}
// if no id given, it will be tried to generate it from the action attribute in the
// corresponding evaluateExtraParams method
if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
evaluateExtraParamsPortletRequest(namespace, action);
} else {
@@ -287,14 +294,20 @@ public class Form extends ClosingUIBean {
}
// if the id isn't specified, use the action name
if (id == null) {
addParameter("id", action);
if (id == null && action!=null) {
addParameter("id", 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
// 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, request, response, null);
addParameter("action", result);
@@ -329,7 +342,7 @@ public class Form extends ClosingUIBean {
// 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);
@@ -337,9 +350,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();
@@ -363,11 +375,6 @@ public class Form extends ClosingUIBean {
*/
private void evaluateExtraParamsPortletRequest(String namespace, String action) {
if (this.action != null) {
// if it isn't specified, we'll make somethig up
action = findString(this.action);
}
String type = "action";
if (TextUtils.stringSet(method)) {
if ("GET".equalsIgnoreCase(method.trim())) {
@@ -375,7 +382,7 @@ public class Form extends ClosingUIBean {
}
}
if (action != null) {
String result = PortletUrlHelper.buildUrl(action, namespace,
String result = PortletUrlHelper.buildUrl(action, namespace, null,
getParameters(), type, portletMode, windowState);
addParameter("action", result);
@@ -409,10 +416,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)) {
@@ -440,7 +446,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;
}
@@ -471,7 +477,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;
}
@@ -32,6 +32,11 @@ import com.opensymphony.xwork2.util.ValueStack;
* <!-- START SNIPPET: javadoc -->
* The tabbedpanel widget is primarily an AJAX component, where each tab can either be local content or remote
* content (refreshed each time the user selects that tab).</p>
* If the useSelectedTabCookie attribute is set to true, the id of the selected tab is saved in a cookie on activation.
* When coming back to this view, the cookie is read and the tab will be activated again, unless an actual value for the
* selectedTab attribute is specified.</p>
* If you want to use the cookie feature, please be sure that you provide a unique id for your tabbedpanel component,
* since this will also be the identifying name component of the stored cookie.</p>
* <!-- END SNIPPET: javadoc -->
*
* <p/> <b>Examples</b>
@@ -67,6 +72,7 @@ public class TabbedPanel extends ClosingUIBean {
protected String closeButton;
protected String doLayout ;
protected String templateCssPath;
protected String useSelectedTabCookie;
public TabbedPanel(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
super(stack, request, response);
@@ -92,6 +98,9 @@ public class TabbedPanel extends ClosingUIBean {
}
if(templateCssPath != null)
addParameter("templateCssPath", findString(templateCssPath));
if(useSelectedTabCookie != null) {
addParameter("useSelectedTabCookie", findString(useSelectedTabCookie));
}
}
public String getDefaultOpenTemplate() {
@@ -132,4 +141,11 @@ public class TabbedPanel extends ClosingUIBean {
public void setTemplateCssPath(String templateCssPath) {
this.templateCssPath = templateCssPath;
}
@StrutsTagAttribute(required = false, defaultValue = "false", description = "If set to true, the id of the last selected " +
"tab will be stored in cookie. If the view is rendered, it will be tried to read this cookie and activate " +
"the corresponding tab on success, unless overridden by the selectedTab attribute. The cookie name is \"Struts2TabbedPanel_selectedTab_\"+id.")
public void setUseSelectedTabCookie( String useSelectedTabCookie ) {
this.useSelectedTabCookie = useSelectedTabCookie;
}
}
@@ -790,6 +790,20 @@ public abstract class UIBean extends Component {
}
}
/**
* Ensures an unescaped attribute value cannot be vulnerable to XSS attacks
*
* @param val The value to check
* @return The escaped value
*/
protected String ensureAttributeSafelyNotEscaped(String val) {
if (val != null) {
return val.replaceAll("\"", "&#34;");
} else {
return "";
}
}
protected void evaluateExtraParams() {
}
@@ -852,7 +866,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>
@@ -864,19 +879,22 @@ 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));
}
@StrutsTagAttribute(description="The template directory.")
@@ -903,7 +921,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;
}
@@ -53,6 +53,12 @@ import com.opensymphony.xwork2.util.ValueStack;
* additional request parameters.</p>
*
* <b>NOTE:</b>
* <p>By default request parameters will be separated using escaped ampersands (i.e., &amp;amp;).
* This is necessary for XHTML compliance, however, when using the URL generated by this tag
* with the &lt;s:property&gt; 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
@@ -68,16 +74,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 (&amp;) to (&amp;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 -->
@@ -135,10 +146,12 @@ public class URL extends Component {
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;
@@ -236,14 +249,14 @@ public class URL extends Component {
String result;
if (value == null && action != null) {
if(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
result = PortletUrlHelper.buildUrl(action, namespace, parameters, portletUrlType, portletMode, windowState);
if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
result = PortletUrlHelper.buildUrl(action, namespace, method, parameters, portletUrlType, portletMode, windowState);
}
else {
result = determineActionURL(action, namespace, method, req, res, parameters, scheme, includeContext, encode);
result = determineActionURL(action, namespace, method, req, res, parameters, scheme, includeContext, encode, forceAddSchemeHostAndPort, escapeAmp);
}
} else {
if(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
result = PortletUrlHelper.buildResourceUrl(value, parameters);
}
else {
@@ -254,7 +267,7 @@ public class URL extends Component {
if (_value != null && _value.indexOf("?") > 0) {
_value = _value.substring(0, _value.indexOf("?"));
}
result = UrlHelper.buildUrl(_value, req, res, parameters, scheme, includeContext, encode);
result = UrlHelper.buildUrl(_value, req, res, parameters, scheme, includeContext, encode, forceAddSchemeHostAndPort, escapeAmp);
}
}
if ( anchor != null && anchor.length() > 0 ) {
@@ -328,7 +341,7 @@ public class URL extends Component {
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;
}
@@ -338,6 +351,16 @@ public class URL extends Component {
this.anchor = anchor;
}
@StrutsTagAttribute(description="Specifies whether to escape ampersand (&amp;) to (&amp;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;
}
/**
* Merge request parameters into current parameters. If a parameter is
@@ -1 +1,23 @@
<!--
/*
* $Id: pom.xml 560558 2007-07-28 15:47:10Z 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.
*/
-->
<body>JSP UI tags for rendering table output in HTML.</body>
@@ -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,9 +22,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 java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -33,6 +31,7 @@ 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 com.opensymphony.xwork2.inject.Inject;
@@ -41,8 +40,7 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.ValueStack;
import freemarker.template.Configuration;
import freemarker.template.SimpleHash;
import freemarker.template.*;
/**
* Freemarker based template engine.
@@ -51,6 +49,10 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine {
static Class bodyContent = null;
private FreemarkerManager freemarkerManager;
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 {
try {
bodyContent = ClassLoaderUtil.loadClass("javax.servlet.jsp.tagext.BodyContent",
@@ -82,22 +84,40 @@ 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);
try {
// try to load, and if it works, stop at the first one
template = config.getTemplate(templateName);
break;
} catch (IOException e) {
if (exception == null) {
exception = e;
if (freemarkerCaching) {
if (!isTemplateMissing(templateName)) {
try {
template = findInCache(templateName); // look in cache first
if (template == null) {
// try to load, and if it works, stop at the first one
template = config.getTemplate(templateName);
addToCache(templateName, template);
}
break;
} catch (IOException e) {
addToMissingTemplateCache(templateName);
if (exception == null) {
exception = e;
}
}
}
} else {
try {
// try to load, and if it works, stop at the first one
template = config.getTemplate(templateName);
break;
} catch (IOException e) {
if (exception == null) {
exception = e;
}
}
}
}
@@ -154,4 +174,40 @@ public class FreemarkerTemplateEngine extends BaseTemplateEngine {
protected String getSuffix() {
return "ftl";
}
protected void addToMissingTemplateCache(String templateName) {
synchronized(missingTemplates) {
missingTemplates.add(templateName);
}
}
protected boolean isTemplateMissing(String templateName) {
synchronized(missingTemplates) {
return missingTemplates.contains(templateName);
}
}
protected void addToCache(String templateName,
freemarker.template.Template template) {
synchronized(templates) {
templates.put(templateName, template);
}
}
protected freemarker.template.Template findInCache(String templateName) {
synchronized(templates) {
return templates.get(templateName);
}
}
/**
* Enables or disables Struts caching of Freemarker templates. By default disabled.
* Set struts.freemarker.templatesCache=true to enable cache
* @param cacheTemplates "true" if the template engine should cache freemarker template
* internally
*/
@Inject(StrutsConstants.STRUTS_FREEMARKER_TEMPLATES_CACHE)
public void setCacheTemplates(String cacheTemplates) {
freemarkerCaching = "true".equals(cacheTemplates);
}
}
@@ -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);
@@ -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
@@ -163,6 +163,7 @@ public class BeanSelectionProvider implements ConfigurationProvider {
if ("true".equalsIgnoreCase(props.getProperty(StrutsConstants.STRUTS_DEVMODE))) {
props.setProperty(StrutsConstants.STRUTS_I18N_RELOAD, "true");
props.setProperty(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true");
props.setProperty(StrutsConstants.STRUTS_FREEMARKER_TEMPLATES_CACHE, "false");
// Convert struts properties into ones that xwork expects
props.setProperty("devMode", "true");
} else {
@@ -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>
@@ -746,12 +746,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());
@@ -23,7 +23,9 @@ package org.apache.struts2.dispatcher;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Enumeration;
@@ -148,10 +150,12 @@ public class FilterDispatcher implements StrutsStatics, Filter {
*/
private static final Log LOG = LogFactory.getLog(FilterDispatcher.class);
static final String DEFAULT_STATIC_PACKAGES = "org.apache.struts2.static template org.apache.struts2.interceptor.debugging";
/**
* Store set of path prefixes to use with static resources.
*/
private String[] pathPrefixes;
String[] pathPrefixes;
/**
* Provide a formatted date for setting heading information when caching static content.
@@ -201,7 +205,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
dispatcher.init();
String param = filterConfig.getInitParameter("packages");
String packages = "org.apache.struts2.static template org.apache.struts2.interceptor.debugging";
String packages = DEFAULT_STATIC_PACKAGES;
if (param != null) {
packages = param + " " + packages;
}
@@ -406,8 +410,7 @@ public class FilterDispatcher implements StrutsStatics, Filter {
}
if (serveStatic && resourcePath.startsWith("/struts")) {
String name = resourcePath.substring("/struts".length());
findStaticResource(name, request, response);
findStaticResource(resourcePath, findAndCheckResources(resourcePath), request, response);
} else {
// this is a normal request, let it pass through
chain.doFilter(request, response);
@@ -429,72 +432,138 @@ public class FilterDispatcher implements StrutsStatics, Filter {
/**
* Locate a static resource and copy directly to the response,
* setting the appropriate caching headers.
* setting the appropriate caching headers.
*
* @param name The resource name
* @param path The resource path
* @param resourceUrls List of matching resource URLs
* @param request The request
* @param response The response
* @throws IOException If anything goes wrong
*/
protected void findStaticResource(String name, HttpServletRequest request, HttpServletResponse response) throws IOException {
if (!name.endsWith(".class")) {
for (String pathPrefix : pathPrefixes) {
InputStream is = findInputStream(name, pathPrefix);
if (is != null) {
Calendar cal = Calendar.getInstance();
// check for if-modified-since, prior to any other headers
long ifModifiedSince = 0;
try {
ifModifiedSince = request.getDateHeader("If-Modified-Since");
} catch (Exception e) {
LOG.warn("Invalid If-Modified-Since header value: '" + request.getHeader("If-Modified-Since") + "', ignoring");
}
long lastModifiedMillis = lastModifiedCal.getTimeInMillis();
long now = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, 1);
long expires = cal.getTimeInMillis();
if (ifModifiedSince > 0 && ifModifiedSince <= lastModifiedMillis) {
// not modified, content is not sent - only basic headers and status SC_NOT_MODIFIED
response.setDateHeader("Expires", expires);
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
is.close();
return;
}
// set the content-type header
String contentType = getContentType(name);
if (contentType != null) {
response.setContentType(contentType);
}
public void findStaticResource(String path, List<URL> resourceUrls, HttpServletRequest request, HttpServletResponse response)
throws IOException {
for (URL resourceUrl : resourceUrls) {
InputStream is;
try {
is = resourceUrl.openStream();
} catch (Exception ex) {
// just ignore it
continue;
}
if (serveStaticBrowserCache) {
// set heading information for caching static content
response.setDateHeader("Date", now);
response.setDateHeader("Expires", expires);
response.setDateHeader("Retry-After", expires);
response.setHeader("Cache-Control", "public");
response.setDateHeader("Last-Modified", lastModifiedMillis);
} else {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "-1");
}
try {
copy(is, response.getOutputStream());
} finally {
is.close();
}
return;
}
//not inside the try block, as this could throw IOExceptions also
if (is != null) {
process(is, path, request, response);
return;
}
}
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
/**
* Locate a static classpath resource and check for safety constraints.
*
* @param path The resource path to check for available resources
* @return verified classpath resource URLs
* @throws IOException If anything goes wrong
*/
protected List<URL> findAndCheckResources(String path) throws IOException {
String name = cleanupPath(path);
List<URL> resourceUrls = new ArrayList<URL>(pathPrefixes.length);
for (String pathPrefix : pathPrefixes) {
URL resourceUrl = findResource(buildPath(name, pathPrefix));
String pathEnding = buildPath(name, pathPrefix);
//check that the resource path is under the pathPrefix path
if (resourceUrl != null && resourceUrl.getFile().endsWith(pathEnding)) {
resourceUrls.add(resourceUrl);
}
}
return resourceUrls;
}
/**
* Look for a static resource in the classpath.
*
* @param path The resource path
* @return The inputstream of the resource
* @throws IOException If there is a problem locating the resource
*/
protected URL findResource(String path) throws IOException {
return ClassLoaderUtil.getResource(path, getClass());
}
/**
* @param name resource name
* @param packagePrefix The package prefix to use to locate the resource
* @return full path
* @throws java.io.UnsupportedEncodingException
* @throws IOException
*/
protected String buildPath(String name, String packagePrefix) throws UnsupportedEncodingException {
String resourcePath;
if (packagePrefix.endsWith("/") && name.startsWith("/")) {
resourcePath = packagePrefix + name.substring(1);
} else {
resourcePath = packagePrefix + name;
}
return URLDecoder.decode(resourcePath, encoding);
}
protected void process(InputStream is, String path, HttpServletRequest request, HttpServletResponse response) throws IOException {
if (is != null) {
Calendar cal = Calendar.getInstance();
// check for if-modified-since, prior to any other headers
long ifModifiedSince = 0;
try {
ifModifiedSince = request.getDateHeader("If-Modified-Since");
} catch (Exception e) {
LOG.warn("Invalid If-Modified-Since header value: '"
+ request.getHeader("If-Modified-Since") + "', ignoring");
}
long lastModifiedMillis = lastModifiedCal.getTimeInMillis();
long now = cal.getTimeInMillis();
cal.add(Calendar.DAY_OF_MONTH, 1);
long expires = cal.getTimeInMillis();
if (ifModifiedSince > 0 && ifModifiedSince <= lastModifiedMillis) {
// not modified, content is not sent - only basic
// headers and status SC_NOT_MODIFIED
response.setDateHeader("Expires", expires);
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
is.close();
return;
}
// set the content-type header
String contentType = getContentType(path);
if (contentType != null) {
response.setContentType(contentType);
}
if (serveStaticBrowserCache) {
// set heading information for caching static content
response.setDateHeader("Date", now);
response.setDateHeader("Expires", expires);
response.setDateHeader("Retry-After", expires);
response.setHeader("Cache-Control", "public");
response.setDateHeader("Last-Modified", lastModifiedMillis);
} else {
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "-1");
}
try {
copy(is, response.getOutputStream());
} finally {
is.close();
}
}
}
/**
* Determine the content type for the resource name.
*
@@ -559,4 +628,13 @@ public class FilterDispatcher implements StrutsStatics, Filter {
return ClassLoaderUtil.getResourceAsStream(resourcePath, getClass());
}
/**
* @param path requested path
* @return path without leading "/struts" or "/static"
*/
protected String cleanupPath(String path) {
//path will start with "/struts" or "/static", remove them
return path.substring(7);
}
}
@@ -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 -->
@@ -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>
@@ -26,10 +26,10 @@ import java.util.Map;
/**
* Actions that want access to the user's HTTP session should implement this interface.<p>
* <p/>
* This interface is only relevant if the Action is used in a servlet environment.<p>
* This will give them access to a Map where they can put objects that can be made available
* to subsequent requests.<p/>
* <p/>
* Note that using this interface makes the Action tied to a servlet environment, so it should be
* avoided if possible since things like unit testing will become more difficult.
* Typical uses may be cached user data such as name, or a shopping cart.
*
*/
public interface SessionAware {
@@ -103,4 +103,24 @@ public interface PortletActionConstants {
* {@link org.apache.struts2.portlet.context.PortletActionContext}.
*/
String DEFAULT_ACTION_FOR_MODE = "struts.portlet.defaultActionForMode";
/**
* Key for request attribute indicating if the action has been reset.
*/
String ACTION_RESET = "struts.portlet.actionReset";
/**
* Key for session attribute indicating the location of the render direct action.
*/
String RENDER_DIRECT_LOCATION = "struts.portlet.renderDirectLocation";
/**
* Session key where the value stack from the event phase is stored.
*/
String STACK_FROM_EVENT_PHASE = "struts.portlet.valueStackFromEventPhase";
/**
* Default name of dispatcher servlet in web.xml
*/
String DEFAULT_DISPATCHER_SERVLET_NAME = "Struts2PortletDispatcherServlet";
}
@@ -22,16 +22,11 @@ package org.apache.struts2.portlet.context;
import java.util.Map;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.*;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.portlet.PortletActionConstants;
import org.apache.struts2.StrutsStatics;
import com.opensymphony.xwork2.ActionContext;
@@ -194,4 +189,12 @@ public class PortletActionContext implements PortletActionConstants {
return (Map)getContext().get(MODE_NAMESPACE_MAP);
}
/**
* Get the portlet context.
* @return The portlet context.
*/
public static PortletContext getPortletContext() {
return (PortletContext)getContext().get(StrutsStatics.STRUTS_PORTLET_CONTEXT);
}
}
@@ -1,66 +0,0 @@
/*
* $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.context;
import java.io.IOException;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.StrutsStatics;
import com.opensymphony.xwork2.ActionContext;
/**
* Since a portlet is not dispatched the same way as a servlet, the
* {@link org.apache.struts2.ServletActionContext} is not immediately available, as it
* depends on objects from the servlet API. However, the WW2 view implementations require access
* to the objects in the {@link org.apache.struts2.ServletActionContext}, and this servlet
* makes sure that these are available when the portlet actions are executing the render results.
*
*/
public class PreparatorServlet extends HttpServlet implements StrutsStatics {
private static final long serialVersionUID = 1853399729352984089L;
private final static Log LOG = LogFactory.getLog(PreparatorServlet.class);
/**
* Prepares the {@link org.apache.struts2.ServletActionContext} with the
* {@link ServletContext}, {@link HttpServletRequest} and {@link HttpServletResponse}.
*/
public void service(HttpServletRequest servletRequest,
HttpServletResponse servletResponse) throws ServletException,
IOException {
LOG.debug("Preparing servlet objects for dispatch");
ServletContext ctx = getServletContext();
ActionContext.getContext().put(SERVLET_CONTEXT, ctx);
ActionContext.getContext().put(HTTP_REQUEST, servletRequest);
ActionContext.getContext().put(HTTP_RESPONSE, servletResponse);
LOG.debug("Preparation complete");
}
}
@@ -1,63 +0,0 @@
/*
* $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.context;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
/**
* Some of the factory/managers (e.g. the ObjectFactory) need access to
* the {@link org.apache.struts2.ServletActionContext} object when initializing.
* This {@link javax.servlet.ServletContextListener} keeps a reference to the
* {@link javax.servlet.ServletContext} and exposes it through a <code>public static</code>
* method.
*
*/
public class ServletContextHolderListener implements ServletContextListener {
private static ServletContext context = null;
/**
* @return The current servlet context
*/
public static ServletContext getServletContext() {
return context;
}
/**
* Stores the reference to the {@link ServletContext}.
*
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
*/
public void contextInitialized(ServletContextEvent event) {
context = event.getServletContext();
}
/**
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
*/
public void contextDestroyed(ServletContextEvent event) {
context = null;
}
}
@@ -23,6 +23,10 @@ package org.apache.struts2.portlet.dispatcher;
import com.opensymphony.xwork2.Action;
import java.io.Serializable;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.portlet.PortletActionConstants;
/**
* When a portlet is targetted for an <code>event</code>, the portlet will receive two
@@ -38,7 +42,7 @@ import java.io.Serializable;
* specifying this action and the location of the view, which then will be executed in the
* following render request.
*/
public class DirectRenderFromEventAction implements Action, Serializable {
public class DirectRenderFromEventAction implements SessionAware, PortletActionConstants, Action, Serializable {
private static final long serialVersionUID = -1814807772308405785L;
@@ -53,15 +57,6 @@ public class DirectRenderFromEventAction implements Action, Serializable {
return location;
}
/**
* Set the location of the view.
*
* @param location The location to set.
*/
public void setLocation(String location) {
this.location = location;
}
/**
* Always return success.
*
@@ -70,4 +65,8 @@ public class DirectRenderFromEventAction implements Action, Serializable {
public String execute() throws Exception {
return SUCCESS;
}
public void setSession(Map session) {
location = (String)session.get(RENDER_DIRECT_LOCATION);
}
}
@@ -20,23 +20,14 @@
*/
package org.apache.struts2.portlet.dispatcher;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletMode;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionProxyFactory;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.FileManager;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.TextUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.StrutsConstants;
@@ -53,19 +44,20 @@ import org.apache.struts2.portlet.PortletApplicationMap;
import org.apache.struts2.portlet.PortletRequestMap;
import org.apache.struts2.portlet.PortletSessionMap;
import org.apache.struts2.portlet.context.PortletActionContext;
import org.apache.struts2.portlet.context.ServletContextHolderListener;
import org.apache.struts2.portlet.util.HttpServletRequestMock;
import org.apache.struts2.portlet.servlet.PortletServletContext;
import org.apache.struts2.portlet.servlet.PortletServletRequest;
import org.apache.struts2.portlet.servlet.PortletServletResponse;
import org.apache.struts2.util.AttributeMap;
import com.opensymphony.xwork2.util.FileManager;
import com.opensymphony.xwork2.util.ValueStack;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionProxy;
import com.opensymphony.xwork2.ActionProxyFactory;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.inject.Container;
import com.opensymphony.xwork2.util.LocalizedTextUtil;
import com.opensymphony.xwork2.util.TextUtils;
import javax.portlet.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* <!-- START SNIPPET: javadoc -->
@@ -76,7 +68,7 @@ import com.opensymphony.xwork2.util.TextUtils;
* </p>
* <!-- END SNIPPET: javadoc -->
*
* @author <a href="nils-helge.garli@bekk.no">Nils-Helge Garli </a>
* @author Nils-Helge Garli
* @author Rainer Hermanns
*
* <p><b>Init parameters</b></p>
@@ -187,9 +179,10 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
String value = cfg.getInitParameter(name);
params.put(name, value);
}
// TODO: CHECK IF NEEDED (RG Portlet Refactoring Backports)
Dispatcher.setPortletSupportActive(true);
dispatcherUtils = new Dispatcher(ServletContextHolderListener.getServletContext(), params);
dispatcherUtils = new Dispatcher(new PortletServletContext(cfg.getPortletContext()), params);
dispatcherUtils.init();
// For testability
@@ -300,6 +293,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
LOG.debug("Entering render");
resetActionContext();
response.setTitle(getTitle(request));
if(!request.getWindowState().equals(WindowState.MINIMIZED)) {
try {
// Check to see if an event set the render to be included directly
serviceAction(request, response, getActionMapping(request),
@@ -310,6 +304,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
} finally {
resetActionContext();
}
}
}
/**
@@ -336,11 +331,22 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
*/
public HashMap createContextMap(Map requestMap, Map parameterMap,
Map sessionMap, Map applicationMap, PortletRequest request,
PortletResponse response, PortletConfig portletConfig, Integer phase) {
PortletResponse response, PortletConfig portletConfig, Integer phase) throws IOException {
// TODO Must put http request/response objects into map for use with
// ServletActionContext
HttpServletResponse dummyResponse = new PortletServletResponse(response);
HttpServletRequest dummyRequest = new PortletServletRequest(request, getPortletContext());
ServletContext dummyServletContext = new PortletServletContext(getPortletContext());
if(EVENT_PHASE.equals(phase)) {
dummyRequest = dispatcherUtils.wrapRequest(dummyRequest, dummyServletContext);
}
HashMap<String,Object> extraContext = new HashMap<String,Object>();
// The dummy servlet objects. Eases reuse of existing interceptors that uses the servlet objects.
extraContext.put(StrutsStatics.HTTP_REQUEST, dummyRequest);
extraContext.put(StrutsStatics.HTTP_RESPONSE, dummyResponse);
extraContext.put(StrutsStatics.SERVLET_CONTEXT, dummyServletContext);
// End dummy servlet objects
extraContext.put(ActionContext.PARAMETERS, parameterMap);
extraContext.put(ActionContext.SESSION, sessionMap);
extraContext.put(ActionContext.APPLICATION, applicationMap);
@@ -397,13 +403,13 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
Map sessionMap, Map applicationMap, String portletNamespace,
Integer phase) throws PortletException {
LOG.debug("serviceAction");
HashMap extraContext = createContextMap(requestMap, parameterMap,
sessionMap, applicationMap, request, response,
getPortletConfig(), phase);
String actionName = mapping.getName();
String namespace = mapping.getNamespace();
Dispatcher.setInstance(dispatcherUtils);
try {
HashMap extraContext = createContextMap(requestMap, parameterMap,
sessionMap, applicationMap, request, response,
getPortletConfig(), phase);
LOG.debug("Creating action proxy for name = " + actionName
+ ", namespace = " + namespace);
ActionProxy proxy = factory.createActionProxy(namespace,
@@ -411,27 +417,7 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
proxy.setMethod(mapping.getMethod());
request.setAttribute("struts.valueStack", proxy.getInvocation()
.getStack());
if (PortletActionConstants.RENDER_PHASE.equals(phase)
&& TextUtils.stringSet(request
.getParameter(EVENT_ACTION))) {
ActionProxy action = (ActionProxy) request.getPortletSession()
.getAttribute(EVENT_ACTION);
if (action != null) {
ValueStack stack = proxy.getInvocation().getStack();
Object top = stack.pop();
stack.push(action.getInvocation().getAction());
stack.push(top);
}
}
proxy.execute();
if (PortletActionConstants.EVENT_PHASE.equals(phase)) {
// Store the executed action in the session for retrieval in the
// render phase.
ActionResponse actionResp = (ActionResponse) response;
request.getPortletSession().setAttribute(EVENT_ACTION, proxy);
actionResp.setRenderParameter(EVENT_ACTION, "true");
}
} catch (ConfigurationException e) {
LOG.error("Could not find action", e);
throw new PortletException("Could not find action " + actionName, e);
@@ -467,20 +453,18 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
ActionMapping mapping = null;
String actionPath = null;
if (resetAction(request)) {
mapping = (ActionMapping) actionMap.get(request.getPortletMode());
mapping = actionMap.get(request.getPortletMode());
} else {
actionPath = request.getParameter(ACTION_PARAM);
if (!TextUtils.stringSet(actionPath)) {
mapping = (ActionMapping) actionMap.get(request
mapping = actionMap.get(request
.getPortletMode());
} else {
// Use the usual action mapper, but it is expecting an action extension
// on the uri, so we add the default one, which should be ok as the
// portlet is a portlet first, a servlet second
HttpServletRequestMock httpRequest = new HttpServletRequestMock()
.setServletPath(actionPath + ".action")
.setParameterMap(request.getParameterMap());
PortletServletRequest httpRequest = new PortletServletRequest(request, getPortletContext());
mapping = actionMapper.getMapping(httpRequest, dispatcherUtils.getConfigurationManager());
}
}
@@ -584,6 +568,12 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics,
reset = true;
}
}
if(reset) {
request.setAttribute(ACTION_RESET, Boolean.TRUE);
}
else {
request.setAttribute(ACTION_RESET, Boolean.FALSE);
}
return reset;
}
@@ -0,0 +1,84 @@
/*
* $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.interceptor;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.interceptor.PrincipalAware;
import org.apache.struts2.portlet.PortletActionConstants;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
public class PortletAwareInterceptor extends AbstractInterceptor implements PortletActionConstants, StrutsStatics {
private static final long serialVersionUID = 2476509721059587700L;
private static final Log LOG = LogFactory.getLog(PortletAwareInterceptor.class);
/**
* Sets action properties based on the interfaces an action implements. Things like application properties,
* parameters, session attributes, etc are set based on the implementing interface.
*
* @param invocation an encapsulation of the action execution state.
* @throws Exception if an error occurs when setting action properties.
*/
public String intercept(ActionInvocation invocation) throws Exception {
final Object action = invocation.getAction();
final ActionContext context = invocation.getInvocationContext();
if (action instanceof PortletRequestAware) {
PortletRequest request = (PortletRequest) context.get(REQUEST);
((PortletRequestAware) action).setPortletRequest(request);
}
if (action instanceof PortletResponseAware) {
PortletResponse response = (PortletResponse) context.get(RESPONSE);
((PortletResponseAware) action).setPortletResponse(response);
}
if (action instanceof PrincipalAware) {
PortletRequest request = (PortletRequest) context.get(REQUEST);
((PrincipalAware) action).setPrincipalProxy(new PortletPrincipalProxy(request));
}
if (action instanceof PortletContextAware) {
PortletContext portletContext = (PortletContext) context.get(STRUTS_PORTLET_CONTEXT);
((PortletContextAware) action).setPortletContext(portletContext);
}
if (action instanceof PortletPreferencesAware) {
PortletRequest request = (PortletRequest) context.get(REQUEST);
// Check if running in a servlet environment
if (request == null) {
LOG.warn("This portlet preferences implementation should only be used during development");
((PortletPreferencesAware)action).setPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
} else {
((PortletPreferencesAware)action).setPortletPreferences(request.getPreferences());
}
}
return invocation.invoke();
}
}
@@ -0,0 +1,29 @@
/*
* $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.interceptor;
import javax.portlet.PortletContext;
public interface PortletContextAware {
void setPortletContext(PortletContext portletContext);
}
@@ -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.portlet.interceptor;
import org.apache.struts2.interceptor.PrincipalProxy;
@@ -0,0 +1,29 @@
/*
* $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.interceptor;
import javax.portlet.PortletRequest;
public interface PortletRequestAware {
void setPortletRequest(PortletRequest request);
}
@@ -0,0 +1,29 @@
/*
* $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.interceptor;
import javax.portlet.PortletResponse;
public interface PortletResponseAware {
void setPortletResponse(PortletResponse response);
}
@@ -0,0 +1,95 @@
/*
* $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.interceptor;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.util.CompoundRoot;
import com.opensymphony.xwork2.util.TextUtils;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.portlet.PortletActionConstants;
import org.apache.struts2.portlet.dispatcher.DirectRenderFromEventAction;
import javax.portlet.ActionResponse;
import javax.portlet.RenderRequest;
import java.util.Map;
public class PortletStateInterceptor extends AbstractInterceptor implements PortletActionConstants {
private final static Log LOG = LogFactory.getLog(PortletStateInterceptor.class);
private static final long serialVersionUID = 6138452063353911784L;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Integer phase = (Integer) invocation.getInvocationContext().get(PHASE);
if (RENDER_PHASE.equals(phase)) {
restoreStack(invocation);
return invocation.invoke();
} else if (EVENT_PHASE.equals(phase)) {
try {
return invocation.invoke();
} finally {
saveStack(invocation);
}
} else {
return invocation.invoke();
}
}
@SuppressWarnings("unchecked")
private void saveStack(ActionInvocation invocation) {
Map session = invocation.getInvocationContext().getSession();
session.put(STACK_FROM_EVENT_PHASE, invocation.getStack());
ActionResponse actionResponse = (ActionResponse) invocation.getInvocationContext().get(RESPONSE);
actionResponse.setRenderParameter(EVENT_ACTION, "true");
}
@SuppressWarnings("unchecked")
private void restoreStack(ActionInvocation invocation) {
RenderRequest request = (RenderRequest) invocation.getInvocationContext().get(REQUEST);
if (TextUtils.stringSet(request.getParameter(EVENT_ACTION))) {
Map session = invocation.getInvocationContext().getSession();
if(!isProperPrg(invocation)) {
LOG.debug("Restoring value stack from event phase");
ValueStack oldStack = (ValueStack) invocation.getInvocationContext().getSession().get(
STACK_FROM_EVENT_PHASE);
if (oldStack != null) {
CompoundRoot oldRoot = oldStack.getRoot();
ValueStack currentStack = invocation.getStack();
CompoundRoot root = currentStack.getRoot();
root.addAll(oldRoot);
LOG.debug("Restored stack");
}
}
else {
LOG.debug("Won't restore stack from event phase since it's a proper PRG request");
}
}
}
private boolean isProperPrg(ActionInvocation invocation) {
return !(invocation.getAction() instanceof DirectRenderFromEventAction);
}
}
@@ -0,0 +1,238 @@
/*
* $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.result;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.struts2.dispatcher.ServletActionRedirectResult;
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.views.util.UrlHelper;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.config.entities.ResultConfig;
import com.opensymphony.xwork2.inject.Inject;
/**
*
* Portlet modification of the {@link ServletActionRedirectResult}.
*
* <!-- START SNIPPET: description -->
* This result uses the {@link ActionMapper} provided by the {@link ActionMapperFactory} to instruct the render phase to
* invoke the specified action and (optional) namespace. This is better than the {@link PortletResult}
* because it does not require you to encode the URL patterns processed by the {@link ActionMapper} in to your struts.xml
* configuration files. This means you can change your URL patterns at any point and your application will still work.
* It is strongly recommended that if you are redirecting to another action, you use this result rather than the
* standard redirect result.
*
* See examples below for an example of how request parameters could be passed in.
*
* <!-- END SNIPPET: description -->
*
* <b>This result type takes the following parameters:</b>
*
* <!-- START SNIPPET: params -->
*
* <ul>
*
* <li><b>actionName (default)</b> - the name of the action that will be redirect to</li>
*
* <li><b>namespace</b> - used to determine which namespace the action is in that we're redirecting to . If namespace is
* null, this defaults to the current namespace</li>
*
* </ul>
*
* <!-- END SNIPPET: params -->
*
* <b>Example:</b>
*
* <pre><!-- START SNIPPET: example -->
* &lt;package name="public" extends="struts-default"&gt;
* &lt;action name="login" class="..."&gt;
* &lt;!-- Redirect to another namespace --&gt;
* &lt;result type="redirect-action"&gt;
* &lt;param name="actionName"&gt;dashboard&lt;/param&gt;
* &lt;param name="namespace"&gt;/secure&lt;/param&gt;
* &lt;/result&gt;
* &lt;/action&gt;
* &lt;/package&gt;
*
* &lt;package name="secure" extends="struts-default" namespace="/secure"&gt;
* &lt;-- Redirect to an action in the same namespace --&gt;
* &lt;action name="dashboard" class="..."&gt;
* &lt;result&gt;dashboard.jsp&lt;/result&gt;
* &lt;result name="error" type="redirect-action"&gt;error&lt;/result&gt;
* &lt;/action&gt;
*
* &lt;action name="error" class="..."&gt;
* &lt;result&gt;error.jsp&lt;/result&gt;
* &lt;/action&gt;
* &lt;/package&gt;
*
* &lt;package name="passingRequestParameters" extends="struts-default" namespace="/passingRequestParameters"&gt;
* &lt;-- Pass parameters (reportType, width and height) --&gt;
* &lt;!--
* The redirect-action url generated will be :
* /genReport/generateReport.action?reportType=pie&width=100&height=100
* --&gt;
* &lt;action name="gatherReportInfo" class="..."&gt;
* &lt;result name="showReportResult" type="redirect-action"&gt;
* &lt;param name="actionName"&gt;generateReport&lt;/param&gt;
* &lt;param name="namespace"&gt;/genReport&lt;/param&gt;
* &lt;param name="reportType"&gt;pie&lt;/param&gt;
* &lt;param name="width"&gt;100&lt;/param&gt;
* &lt;param name="height"&gt;100&lt;/param&gt;
* &lt;/result&gt;
* &lt;/action&gt;
* &lt;/package&gt;
*
*
* <!-- END SNIPPET: example --></pre>
*
* @see ActionMapper
*/
public class PortletActionRedirectResult extends PortletResult {
private static final long serialVersionUID = -7627388936683562557L;
/** The default parameter */
public static final String DEFAULT_PARAM = "actionName";
protected String actionName;
protected String namespace;
protected String method;
private Map<String, String> requestParameters = new LinkedHashMap<String, String>();
private ActionMapper actionMapper;
public PortletActionRedirectResult() {
super();
}
public PortletActionRedirectResult(String actionName) {
this(null, actionName, null);
}
public PortletActionRedirectResult(String actionName, String method) {
this(null, actionName, method);
}
public PortletActionRedirectResult(String namespace, String actionName, String method) {
super(null);
this.namespace = namespace;
this.actionName = actionName;
this.method = method;
}
protected List<String> prohibitedResultParam = Arrays.asList(new String[] {
DEFAULT_PARAM, "namespace", "method", "encode", "parse", "location",
"prependServletContext" });
@Inject
public void setActionMapper(ActionMapper actionMapper) {
this.actionMapper = actionMapper;
}
/**
* @see com.opensymphony.xwork2.Result#execute(com.opensymphony.xwork2.ActionInvocation)
*/
public void execute(ActionInvocation invocation) throws Exception {
actionName = conditionalParse(actionName, invocation);
if (namespace == null) {
namespace = invocation.getProxy().getNamespace();
} else {
namespace = conditionalParse(namespace, invocation);
}
if (method == null) {
method = "";
}
else {
method = conditionalParse(method, invocation);
}
String resultCode = invocation.getResultCode();
if (resultCode != null) {
ResultConfig resultConfig = invocation.getProxy().getConfig().getResults().get(
resultCode);
Map resultConfigParams = resultConfig.getParams();
for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
if (! prohibitedResultParam.contains(e.getKey())) {
requestParameters.put(e.getKey().toString(),
e.getValue() == null ? "":
conditionalParse(e.getValue().toString(), invocation));
}
}
}
StringBuffer tmpLocation = new StringBuffer(actionMapper.getUriFromActionMapping(new ActionMapping(actionName, namespace, method, null)));
UrlHelper.buildParametersString(requestParameters, tmpLocation, "&");
setLocation(tmpLocation.toString());
super.execute(invocation);
}
/**
* Sets the action name
*
* @param actionName The name
*/
public void setActionName(String actionName) {
this.actionName = actionName;
}
/**
* Sets the namespace
*
* @param namespace The namespace
*/
public void setNamespace(String namespace) {
this.namespace = namespace;
}
/**
* Sets the method
*
* @param method The method
*/
public void setMethod(String method) {
this.method = method;
}
/**
* Adds a request parameter to be added to the redirect url
*
* @param key The parameter name
* @param value The parameter value
*/
public PortletActionRedirectResult addParameter(String key, Object value) {
requestParameters.put(key, String.valueOf(value));
return this;
}
}
@@ -20,20 +20,8 @@
*/
package org.apache.struts2.portlet.result;
import java.io.IOException;
import java.util.StringTokenizer;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.TextUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
@@ -41,14 +29,20 @@ import org.apache.struts2.dispatcher.StrutsResultSupport;
import org.apache.struts2.portlet.PortletActionConstants;
import org.apache.struts2.portlet.context.PortletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.util.TextUtils;
import javax.portlet.*;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Map;
/**
* Result type that includes a JSP to render.
*
*/
public class PortletResult extends StrutsResultSupport {
public class PortletResult extends StrutsResultSupport implements PortletActionConstants {
private static final long serialVersionUID = 434251393926178567L;
@@ -116,28 +110,26 @@ public class PortletResult extends StrutsResultSupport {
* @param finalLocation
* @param invocation
*/
protected void executeActionResult(String finalLocation,
ActionInvocation invocation) {
protected void executeActionResult(String finalLocation, ActionInvocation invocation) {
LOG.debug("Executing result in Event phase");
ActionResponse res = PortletActionContext.getActionResponse();
Map sessionMap = invocation.getInvocationContext().getSession();
LOG.debug("Setting event render parameter: " + finalLocation);
if (finalLocation.indexOf('?') != -1) {
convertQueryParamsToRenderParams(res, finalLocation
.substring(finalLocation.indexOf('?') + 1));
finalLocation = finalLocation.substring(0, finalLocation
.indexOf('?'));
convertQueryParamsToRenderParams(res, finalLocation.substring(finalLocation.indexOf('?') + 1));
finalLocation = finalLocation.substring(0, finalLocation.indexOf('?'));
}
if (finalLocation.endsWith(".action")) {
// View is rendered with a view action...luckily...
finalLocation = finalLocation.substring(0, finalLocation
.lastIndexOf("."));
res.setRenderParameter(PortletActionConstants.ACTION_PARAM, finalLocation);
res.setRenderParameter(ACTION_PARAM, finalLocation);
} else {
// View is rendered outside an action...uh oh...
res.setRenderParameter(PortletActionConstants.ACTION_PARAM, "renderDirect");
res.setRenderParameter("location", finalLocation);
sessionMap.put(RENDER_DIRECT_LOCATION, finalLocation);
}
res.setRenderParameter(PortletActionConstants.MODE_PARAM, PortletActionContext
res.setRenderParameter(MODE_PARAM, PortletActionContext
.getRequest().getPortletMode().toString());
}
@@ -178,20 +170,6 @@ public class PortletResult extends StrutsResultSupport {
res.setTitle(title);
}
LOG.debug("Location: " + finalLocation);
PortletRequestDispatcher preparator = cfg.getPortletContext()
.getNamedDispatcher("preparator");
if(preparator == null) {
throw new PortletException("Cannot look up 'preparator' servlet. Make sure that you" +
"have configured it correctly in the web.xml file.");
}
new IncludeTemplate() {
protected void when(PortletException e) {
LOG.error("PortletException while dispatching to 'preparator' servlet", e);
}
protected void when(IOException e) {
LOG.error("IOException while dispatching to 'preparator' servlet", e);
}
}.include(preparator, req, res);
PortletRequestDispatcher dispatcher = cfg.getPortletContext().getRequestDispatcher(finalLocation);
if(dispatcher == null) {
throw new PortletException("Could not locate dispatcher for '" + finalLocation + "'");
@@ -20,20 +20,10 @@
*/
package org.apache.struts2.portlet.result;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspFactory;
import javax.servlet.jsp.PageContext;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
@@ -47,10 +37,15 @@ import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import javax.portlet.ActionResponse;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspFactory;
import javax.servlet.jsp.PageContext;
import java.io.OutputStreamWriter;
import java.io.Writer;
/**
* <!-- START SNIPPET: description -->
@@ -160,7 +155,6 @@ public class PortletVelocityResult extends StrutsResultSupport {
*/
public void executeRenderResult(String finalLocation,
ActionInvocation invocation) throws Exception {
prepareServletActionContext();
ValueStack stack = ActionContext.getContext().getValueStack();
HttpServletRequest request = ServletActionContext.getRequest();
@@ -192,7 +186,7 @@ public class PortletVelocityResult extends StrutsResultSupport {
if (encoding != null) {
contentType = contentType + ";charset=" + encoding;
}
response.setContentType(contentType);
Template t = getTemplate(stack,
velocityManager.getVelocityEngine(), invocation,
finalLocation, encoding);
@@ -202,8 +196,6 @@ public class PortletVelocityResult extends StrutsResultSupport {
Writer writer = new OutputStreamWriter(response.getOutputStream(),
encoding);
response.setContentType(contentType);
t.merge(context, writer);
// always flush the writer (we used to only flush it if this was a
@@ -294,14 +286,4 @@ public class PortletVelocityResult extends StrutsResultSupport {
return velocityManager.createContext(stack, request, response);
}
/**
* Prepares the servlet action context for this request
*/
private void prepareServletActionContext() throws PortletException,
IOException {
PortletRequestDispatcher disp = PortletActionContext.getPortletConfig()
.getPortletContext().getNamedDispatcher("preparator");
disp.include(PortletActionContext.getRenderRequest(),
PortletActionContext.getRenderResponse());
}
}
@@ -0,0 +1,214 @@
/*
* $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.servlet;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.portlet.PortletSession;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;
/**
* Wrapper object exposing a {@link PortletSession} as a {@link HttpSession} instance.
* Clients accessing this session object will in fact operate on the
* {@link PortletSession} object wrapped by this session object.
*/
public class PortletHttpSession implements HttpSession {
private PortletSession portletSession;
public PortletHttpSession(PortletSession portletSession) {
this.portletSession = portletSession;
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getAttribute(java.lang.String)
*/
public Object getAttribute(String name) {
return portletSession.getAttribute(name);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getAttributeNames()
*/
public Enumeration getAttributeNames() {
return portletSession.getAttributeNames();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getCreationTime()
*/
public long getCreationTime() {
return portletSession.getCreationTime();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getId()
*/
public String getId() {
return portletSession.getId();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getLastAccessedTime()
*/
public long getLastAccessedTime() {
return portletSession.getLastAccessedTime();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getMaxInactiveInterval()
*/
public int getMaxInactiveInterval() {
return portletSession.getMaxInactiveInterval();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getServletContext()
*/
public ServletContext getServletContext() {
return new PortletServletContext(portletSession.getPortletContext());
}
/**
* @see javax.servlet.http.HttpSession#getSessionContext()
* @throws IllegalStateException
* Not supported in a portlet.
*/
public HttpSessionContext getSessionContext() {
throw new IllegalStateException("Not supported in a portlet");
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getValue(java.lang.String)
*/
public Object getValue(String name) {
return getAttribute(name);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#getValueNames()
*/
public String[] getValueNames() {
List<String> names = new ArrayList<String>();
Enumeration attrNames = getAttributeNames();
while (attrNames.hasMoreElements()) {
names.add((String) attrNames.nextElement());
}
return names.toArray(new String[0]);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#invalidate()
*/
public void invalidate() {
portletSession.invalidate();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#isNew()
*/
public boolean isNew() {
return portletSession.isNew();
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#putValue(java.lang.String,
* java.lang.Object)
*/
public void putValue(String name, Object value) {
setAttribute(name, value);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#removeAttribute(java.lang.String)
*/
public void removeAttribute(String name) {
portletSession.removeAttribute(name);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#removeValue(java.lang.String)
*/
public void removeValue(String name) {
removeAttribute(name);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#setAttribute(java.lang.String,
* java.lang.Object)
*/
public void setAttribute(String name, Object value) {
portletSession.setAttribute(name, value);
}
/*
* (non-Javadoc)
*
* @see javax.servlet.http.HttpSession#setMaxInactiveInterval(int)
*/
public void setMaxInactiveInterval(int interval) {
portletSession.setMaxInactiveInterval(interval);
}
/**
* Get the wrapped portlet session.
*
* @return The wrapped portlet session.
*/
public PortletSession getPortletSession() {
return portletSession;
}
}
@@ -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.servlet;
import java.util.Enumeration;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
/**
* Wrapper object exposing a {@link PortletConfig} as a {@link ServletConfig} instance.
* Clients accessing this config object will in fact operate on the
* {@link PortletConfig} object wrapped by this config object.
*/
public class PortletServletConfig implements ServletConfig {
private PortletConfig portletConfig;
public PortletServletConfig(PortletConfig portletConfig) {
this.portletConfig = portletConfig;
}
/* (non-Javadoc)
* @see javax.servlet.ServletConfig#getInitParameter(java.lang.String)
*/
public String getInitParameter(String name) {
return portletConfig.getInitParameter(name);
}
/* (non-Javadoc)
* @see javax.servlet.ServletConfig#getInitParameterNames()
*/
public Enumeration getInitParameterNames() {
return portletConfig.getInitParameterNames();
}
/**
* Get the {@link PortletContext} as a {@link PortletServletContext} instance.
* @see javax.servlet.ServletConfig#getServletContext()
*/
public ServletContext getServletContext() {
return new PortletServletContext(portletConfig.getPortletContext());
}
/**
* Will return the portlet name.
* @see javax.servlet.ServletConfig#getServletName()
*/
public String getServletName() {
return portletConfig.getPortletName();
}
/**
* Get the wrapped {@link PortletConfig} instance.
* @return The wrapped {@link PortletConfig} instance.
*/
public PortletConfig getPortletConfig() {
return portletConfig;
}
}
@@ -0,0 +1,235 @@
/*
* $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.servlet;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Set;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequestDispatcher;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
/**
* Wrapper object exposing a {@link PortletContext} as a {@link ServletContext} instance.
* Clients accessing this context object will in fact operate on the
* {@link PortletContext} object wrapped by this context object.
*/
public class PortletServletContext implements ServletContext {
private PortletContext portletContext;
public PortletServletContext(PortletContext portletContext) {
this.portletContext = portletContext;
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getAttribute(java.lang.String)
*/
public Object getAttribute(String name) {
return portletContext.getAttribute(name);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getAttributeNames()
*/
public Enumeration getAttributeNames() {
return portletContext.getAttributeNames();
}
/**
* @see javax.servlet.ServletContext#getContext(java.lang.String)
* @throws IllegalStateException Not supported in a portlet.
*/
public ServletContext getContext(String uripath) {
throw new IllegalStateException("Not supported in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
*/
public String getInitParameter(String name) {
return portletContext.getInitParameter(name);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getInitParameterNames()
*/
public Enumeration getInitParameterNames() {
return portletContext.getInitParameterNames();
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getMajorVersion()
*/
public int getMajorVersion() {
return portletContext.getMajorVersion();
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getMimeType(java.lang.String)
*/
public String getMimeType(String file) {
return portletContext.getMimeType(file);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getMinorVersion()
*/
public int getMinorVersion() {
return portletContext.getMinorVersion();
}
/**
* Returns a {@link PortletServletRequestDispatcher} wrapping the {@link PortletRequestDispatcher}
* as a {@link RequestDispatcher} instance.
* @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
* @return PortletServletRequestDispatcher
*/
public RequestDispatcher getNamedDispatcher(String name) {
return new PortletServletRequestDispatcher(portletContext.getNamedDispatcher(name));
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getRealPath(java.lang.String)
*/
public String getRealPath(String path) {
return portletContext.getRealPath(path);
}
/**
* Returns a {@link PortletServletRequestDispatcher} wrapping the {@link PortletRequestDispatcher}
* as a {@link RequestDispatcher} instance.
* @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
* @return PortletServletRequestDispatcher
*/
public RequestDispatcher getRequestDispatcher(String path) {
return new PortletServletRequestDispatcher(portletContext.getRequestDispatcher(path));
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getResource(java.lang.String)
*/
public URL getResource(String path) throws MalformedURLException {
return portletContext.getResource(path);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
*/
public InputStream getResourceAsStream(String path) {
return portletContext.getResourceAsStream(path);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
*/
public Set getResourcePaths(String path) {
return portletContext.getResourcePaths(path);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getServerInfo()
*/
public String getServerInfo() {
return portletContext.getServerInfo();
}
/**
* @see javax.servlet.ServletContext#getServlet(java.lang.String)
* @throws IllegalStateException Not supported in a portlet.
*/
public Servlet getServlet(String name) throws ServletException {
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#getServletContextName()
*/
public String getServletContextName() {
return portletContext.getPortletContextName();
}
/**
* @see javax.servlet.ServletContext#getServletNames()
* @throws IllegalStateException Not supported in a portlet.
*/
public Enumeration getServletNames() {
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* @see javax.servlet.ServletContext#getServlets()
* @throws IllegalStateException Not supported in a portlet.
*/
public Enumeration getServlets() {
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#log(java.lang.String)
*/
public void log(String msg) {
portletContext.log(msg);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#log(java.lang.Exception, java.lang.String)
*/
public void log(Exception exception, String msg) {
log(msg, exception);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#log(java.lang.String, java.lang.Throwable)
*/
public void log(String message, Throwable throwable) {
portletContext.log(message, throwable);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
*/
public void removeAttribute(String name) {
portletContext.removeAttribute(name);
}
/* (non-Javadoc)
* @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
*/
public void setAttribute(String name, Object object) {
portletContext.setAttribute(name, object);
}
/**
* Get the wrapped {@link PortletContext} instance.
* @return The wrapped {@link PortletContext} instance.
*/
public PortletContext getPortletContext() {
return portletContext;
}
}
@@ -0,0 +1,121 @@
/*
* $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.servlet;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletInputStream;
/**
* Wrapper object exposing a {@link InputStream} from a portlet as a {@link ServletInputStream} instance.
* Clients accessing this stream object will in fact operate on the
* {@link InputStream} object wrapped by this stream object.
*/
public class PortletServletInputStream extends ServletInputStream {
private InputStream portletInputStream;
public PortletServletInputStream(InputStream portletInputStream) {
this.portletInputStream = portletInputStream;
}
/* (non-Javadoc)
* @see java.io.InputStream#read()
*/
@Override
public int read() throws IOException {
return portletInputStream.read();
}
/* (non-Javadoc)
* @see java.io.InputStream#available()
*/
@Override
public int available() throws IOException {
return portletInputStream.available();
}
/* (non-Javadoc)
* @see java.io.InputStream#close()
*/
@Override
public void close() throws IOException {
portletInputStream.close();
}
/* (non-Javadoc)
* @see java.io.InputStream#mark(int)
*/
@Override
public synchronized void mark(int readlimit) {
portletInputStream.mark(readlimit);
}
/* (non-Javadoc)
* @see java.io.InputStream#markSupported()
*/
@Override
public boolean markSupported() {
return portletInputStream.markSupported();
}
/* (non-Javadoc)
* @see java.io.InputStream#read(byte[], int, int)
*/
@Override
public int read(byte[] b, int off, int len) throws IOException {
return portletInputStream.read(b, off, len);
}
/* (non-Javadoc)
* @see java.io.InputStream#read(byte[])
*/
@Override
public int read(byte[] b) throws IOException {
return portletInputStream.read(b);
}
/* (non-Javadoc)
* @see java.io.InputStream#reset()
*/
@Override
public synchronized void reset() throws IOException {
portletInputStream.reset();
}
/* (non-Javadoc)
* @see java.io.InputStream#skip(long)
*/
@Override
public long skip(long n) throws IOException {
return portletInputStream.skip(n);
}
/**
* Get the wrapped {@link InputStream} instance.
* @return The wrapped {@link InputStream} instance.
*/
public InputStream getInputStream() {
return portletInputStream;
}
}
@@ -0,0 +1,88 @@
/*
* $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.servlet;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletOutputStream;
/**
* Wrapper object exposing a {@link OutputStream} from a portlet as a {@link ServletOutputStream} instance.
* Clients accessing this stream object will in fact operate on the
* {@link OutputStream} object wrapped by this stream object.
*/
public class PortletServletOutputStream extends ServletOutputStream {
private OutputStream portletOutputStream;
public PortletServletOutputStream(OutputStream portletOutputStream) {
this.portletOutputStream = portletOutputStream;
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(int)
*/
@Override
public void write(int ch) throws IOException {
portletOutputStream.write(ch);
}
/* (non-Javadoc)
* @see java.io.OutputStream#close()
*/
@Override
public void close() throws IOException {
portletOutputStream.close();
}
/* (non-Javadoc)
* @see java.io.OutputStream#flush()
*/
@Override
public void flush() throws IOException {
portletOutputStream.flush();
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(byte[])
*/
@Override
public void write(byte[] b) throws IOException {
portletOutputStream.write(b);
}
/* (non-Javadoc)
* @see java.io.OutputStream#write(byte[], int, int)
*/
@Override
public void write(byte[] b, int off, int len) throws IOException {
portletOutputStream.write(b, off, len);
}
/**
* Get the wrapped {@link OutputStream} instance.
* @return The wrapped {@link OutputStream} instance.
*/
public OutputStream getOutputStream() {
return portletOutputStream;
}
}
@@ -0,0 +1,558 @@
/*
* $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.servlet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import javax.portlet.ActionRequest;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSession;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletRequest;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.portlet.PortletActionConstants;
/**
* Wrapper object exposing a {@link PortletRequest} as a {@link HttpServletRequest} instance.
* Clients accessing this request object will in fact operate on the
* {@link PortletRequest} object wrapped by this request object.
*/
public class PortletServletRequest implements HttpServletRequest, PortletActionConstants {
private PortletRequest portletRequest;
private PortletContext portletContext;
public PortletServletRequest(PortletRequest portletRequest, PortletContext portletContext) {
this.portletRequest = portletRequest;
this.portletContext = portletContext;
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getAuthType()
*/
public String getAuthType() {
return portletRequest.getAuthType();
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getContextPath()
*/
public String getContextPath() {
return portletRequest.getContextPath();
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public Cookie[] getCookies() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getCookies();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public long getDateHeader(String name) {
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Gets a property from the {@link PortletRequest}. Note that a {@link PortletRequest} is not
* guaranteed to map properties to headers.
* @see PortletRequest#getProperty(String)
* @see javax.servlet.http.HttpServletRequest#getHeader(java.lang.String)
*/
public String getHeader(String name) {
return portletRequest.getProperty(name);
}
/**
* Gets the property names from the {@link PortletRequest}. Note that a {@link PortletRequest} is not
* guaranteed to map properties to headers.
* @see PortletRequest#getPropertyNames()
* @see javax.servlet.http.HttpServletRequest#getHeaderNames()
*/
public Enumeration getHeaderNames() {
return portletRequest.getPropertyNames();
}
/**
* Gets the values for the specified property from the {@link PortletRequest}. Note that a
* {@link PortletRequest} is not guaranteed to map properties to headers.
* @see PortletRequest#getProperties(String)
* @see HttpServletRequest#getHeaders(String)
*/
public Enumeration getHeaders(String name) {
return portletRequest.getProperties(name);
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public int getIntHeader(String name) {
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getMethod()
*/
public String getMethod() {
return null;
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getPathInfo()
*/
public String getPathInfo() {
return null;
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getPathTranslated()
*/
public String getPathTranslated() {
return null;
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getQueryString()
*/
public String getQueryString() {
return null;
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getRemoteUser()
*/
public String getRemoteUser() {
return portletRequest.getRemoteUser();
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public String getRequestURI() {
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public StringBuffer getRequestURL() {
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getRequestedSessionId()
*/
public String getRequestedSessionId() {
return portletRequest.getRequestedSessionId();
}
/**
* A {@link PortletRequest} has no servlet path. But for compatibility with Struts 2 components and
* interceptors, the action parameter on the request is mapped to the servlet path.
* @see javax.servlet.http.HttpServletRequest#getServletPath()
*/
public String getServletPath() {
String actionPath = getParameter(ACTION_PARAM);
if(actionPath != null && !actionPath.endsWith(".action")) {
actionPath += ".action";
}
return actionPath;
}
/**
* Get the {@link PortletSession} as a {@link PortletHttpSession} instance.
* @see javax.servlet.http.HttpServletRequest#getSession()
*/
public HttpSession getSession() {
return new PortletHttpSession(portletRequest.getPortletSession());
}
/**
* Get the {@link PortletSession} as a {@link PortletHttpSession} instance.
* @see javax.servlet.http.HttpServletRequest#getSession(boolean)
*/
public HttpSession getSession(boolean create) {
return new PortletHttpSession(portletRequest.getPortletSession(create));
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#getUserPrincipal()
*/
public Principal getUserPrincipal() {
return portletRequest.getUserPrincipal();
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public boolean isRequestedSessionIdFromCookie() {
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public boolean isRequestedSessionIdFromURL() {
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public boolean isRequestedSessionIdFromUrl() {
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#isRequestedSessionIdValid()
*/
public boolean isRequestedSessionIdValid() {
return portletRequest.isRequestedSessionIdValid();
}
/* (non-Javadoc)
* @see javax.servlet.http.HttpServletRequest#isUserInRole(java.lang.String)
*/
public boolean isUserInRole(String role) {
return portletRequest.isUserInRole(role);
}
/**
* Gets an attribute value on the {@link PortletRequest}. If the attribute name is
* <tt>javax.servlet.include.servlet_path</tt>, it returns the same as
* {@link PortletServletRequest#getServletPath()}
* @see javax.servlet.ServletRequest#getAttribute(java.lang.String)
*/
public Object getAttribute(String name) {
if("javax.servlet.include.servlet_path".equals(name)) {
return getServletPath();
}
else {
return portletRequest.getAttribute(name);
}
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getAttributeNames()
*/
public Enumeration getAttributeNames() {
return portletRequest.getAttributeNames();
}
/**
* Can only be invoked in the event phase.
* @see ServletRequest#getCharacterEncoding()
* @throws IllegalStateException If the portlet is not in the event phase.
*/
public String getCharacterEncoding() {
if(portletRequest instanceof ActionRequest) {
return ((ActionRequest)portletRequest).getCharacterEncoding();
}
else {
throw new IllegalStateException("Not allowed in render phase");
}
}
/**
* Can only be invoked in the event phase.
* @see ServletRequest#getContentLength()
* @throws IllegalStateException If the portlet is not in the event phase.
*/
public int getContentLength() {
if(portletRequest instanceof ActionRequest) {
return ((ActionRequest)portletRequest).getContentLength();
}
else {
throw new IllegalStateException("Not allowed in render phase");
}
}
/**
* Can only be invoked in the event phase.
* @see ServletRequest#getContentType()
* @throws IllegalStateException If the portlet is not in the event phase.
*/
public String getContentType() {
if(portletRequest instanceof ActionRequest) {
return ((ActionRequest)portletRequest).getContentType();
}
else {
throw new IllegalStateException("Not allowed in render phase");
}
}
/**
* Can only be invoked in the event phase. When invoked in the event phase, it will wrap the
* portlet's {@link InputStream} as a {@link PortletServletInputStream}.
* @see ServletRequest#getInputStream()
* @throws IllegalStateException If the portlet is not in the event phase.
*/
public ServletInputStream getInputStream() throws IOException {
if(portletRequest instanceof ActionRequest) {
return new PortletServletInputStream(((ActionRequest)portletRequest).getPortletInputStream());
}
else {
throw new IllegalStateException("Not allowed in render phase");
}
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public String getLocalAddr() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getLocalAddr();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public String getLocalName() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getLocalName();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public int getLocalPort() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getLocalPort();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getLocale()
*/
public Locale getLocale() {
return portletRequest.getLocale();
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getLocales()
*/
public Enumeration getLocales() {
return portletRequest.getLocales();
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getParameter(java.lang.String)
*/
public String getParameter(String name) {
return portletRequest.getParameter(name);
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getParameterMap()
*/
public Map getParameterMap() {
return portletRequest.getParameterMap();
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getParameterNames()
*/
public Enumeration getParameterNames() {
return portletRequest.getParameterNames();
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
*/
public String[] getParameterValues(String name) {
return portletRequest.getParameterValues(name);
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public String getProtocol() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getProtocol();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Can only be invoked in the event phase.
* @see ServletRequest#getReader()
* @throws IllegalStateException If the portlet is not in the event phase.
*/
public BufferedReader getReader() throws IOException {
if(portletRequest instanceof ActionRequest) {
return ((ActionRequest)portletRequest).getReader();
}
else {
throw new IllegalStateException("Not allowed in render phase");
}
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getRealPath(java.lang.String)
*/
public String getRealPath(String path) {
return portletContext.getRealPath(path);
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public String getRemoteAddr() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getRemoteAddr();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public String getRemoteHost() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getRemoteHost();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public int getRemotePort() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getRemotePort();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/**
* Get the {@link PortletRequestDispatcher} as a {@link PortletServletRequestDispatcher} instance.
* @see javax.servlet.ServletRequest#getRequestDispatcher(java.lang.String)
*/
public RequestDispatcher getRequestDispatcher(String path) {
return new PortletServletRequestDispatcher(portletContext.getRequestDispatcher(path));
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getScheme()
*/
public String getScheme() {
return portletRequest.getScheme();
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#getServerName()
*/
public String getServerName() {
return portletRequest.getServerName();
}
/**
* Not allowed in a portlet.
* @throws IllegalStateException Not allowed in a portlet.
*/
public int getServerPort() {
if(portletRequest instanceof HttpServletRequest) {
return ((HttpServletRequest)portletRequest).getServerPort();
}
throw new IllegalStateException("Not allowed in a portlet");
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#isSecure()
*/
public boolean isSecure() {
return portletRequest.isSecure();
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#removeAttribute(java.lang.String)
*/
public void removeAttribute(String name) {
portletRequest.removeAttribute(name);
}
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#setAttribute(java.lang.String, java.lang.Object)
*/
public void setAttribute(String name, Object o) {
portletRequest.setAttribute(name, o);
}
/**
* Can only be invoked in the event phase.
* @see ServletRequest#setCharacterEncoding(String)
* @throws IllegalStateException If the portlet is not in the event phase.
*/
public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
if(portletRequest instanceof ActionRequest) {
((ActionRequest)portletRequest).setCharacterEncoding(env);
}
else {
throw new IllegalStateException("Not allowed in render phase");
}
}
/**
* Get the wrapped {@link PortletRequest} instance.
* @return The wrapped {@link PortletRequest} instance.
*/
public PortletRequest getPortletRequest() {
return portletRequest;
}
}
@@ -0,0 +1,70 @@
/*
* $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.servlet;
import java.io.IOException;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class PortletServletRequestDispatcher implements RequestDispatcher {
private PortletRequestDispatcher portletRequestDispatcher;
public PortletServletRequestDispatcher(PortletRequestDispatcher portletRequestDispatcher) {
this.portletRequestDispatcher = portletRequestDispatcher;
}
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
throw new IllegalStateException("Not allowed in a portlet");
}
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
if(request instanceof PortletServletRequest && response instanceof PortletServletResponse) {
PortletRequest req = ((PortletServletRequest)request).getPortletRequest();
PortletResponse resp = ((PortletServletResponse)response).getPortletResponse();
if(req instanceof RenderRequest && resp instanceof RenderResponse) {
try {
portletRequestDispatcher.include((RenderRequest)req, (RenderResponse)resp);
}
catch(PortletException e) {
throw new ServletException(e);
}
}
else {
throw new IllegalStateException("Can only be invoked in the render phase");
}
}
else {
throw new IllegalStateException("Can only be invoked in a portlet");
}
}
}
@@ -0,0 +1,233 @@
/*
* $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.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import javax.portlet.PortletResponse;
import javax.portlet.RenderResponse;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
public class PortletServletResponse implements HttpServletResponse {
private PortletResponse portletResponse;
public PortletServletResponse(PortletResponse portletResponse) {
this.portletResponse = portletResponse;
}
public void addCookie(Cookie cookie) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void addDateHeader(String name, long date) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void addHeader(String name, String value) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void addIntHeader(String name, int value) {
throw new IllegalStateException("Not allowed in a portlet");
}
public boolean containsHeader(String name) {
throw new IllegalStateException("Not allowed in a portlet");
}
public String encodeRedirectURL(String url) {
throw new IllegalStateException("Not allowed in a portlet");
}
public String encodeRedirectUrl(String url) {
throw new IllegalStateException("Not allowed in a portlet");
}
public String encodeURL(String url) {
throw new IllegalStateException("Not allowed in a portlet");
}
public String encodeUrl(String url) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void sendError(int sc) throws IOException {
throw new IllegalStateException("Not allowed in a portlet");
}
public void sendError(int sc, String msg) throws IOException {
throw new IllegalStateException("Not allowed in a portlet");
}
public void sendRedirect(String location) throws IOException {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setDateHeader(String name, long date) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setHeader(String name, String value) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setIntHeader(String name, int value) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setStatus(int sc) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setStatus(int sc, String sm) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void flushBuffer() throws IOException {
if(portletResponse instanceof RenderResponse) {
((RenderResponse)portletResponse).flushBuffer();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public int getBufferSize() {
if(portletResponse instanceof RenderResponse) {
return ((RenderResponse)portletResponse).getBufferSize();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public String getCharacterEncoding() {
if(portletResponse instanceof RenderResponse) {
return ((RenderResponse)portletResponse).getCharacterEncoding();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public String getContentType() {
if(portletResponse instanceof RenderResponse) {
return ((RenderResponse)portletResponse).getContentType();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public Locale getLocale() {
if(portletResponse instanceof RenderResponse) {
return ((RenderResponse)portletResponse).getLocale();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public ServletOutputStream getOutputStream() throws IOException {
if(portletResponse instanceof RenderResponse) {
return new PortletServletOutputStream(((RenderResponse)portletResponse).getPortletOutputStream());
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public PrintWriter getWriter() throws IOException {
if(portletResponse instanceof RenderResponse) {
return ((RenderResponse)portletResponse).getWriter();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public boolean isCommitted() {
if(portletResponse instanceof RenderResponse) {
return ((RenderResponse)portletResponse).isCommitted();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public void reset() {
if(portletResponse instanceof RenderResponse) {
((RenderResponse)portletResponse).reset();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public void resetBuffer() {
if(portletResponse instanceof RenderResponse) {
((RenderResponse)portletResponse).resetBuffer();
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public void setBufferSize(int size) {
if(portletResponse instanceof RenderResponse) {
((RenderResponse)portletResponse).setBufferSize(size);
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public void setCharacterEncoding(String charset) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setContentLength(int len) {
throw new IllegalStateException("Not allowed in a portlet");
}
public void setContentType(String type) {
if(portletResponse instanceof RenderResponse) {
((RenderResponse)portletResponse).setContentType(type);
}
else {
throw new IllegalStateException("Not allowed in event phase");
}
}
public void setLocale(Locale loc) {
throw new IllegalStateException("Not allowed in a portlet");
}
public PortletResponse getPortletResponse() {
return portletResponse;
}
}
@@ -0,0 +1,27 @@
<!--
/*
* $Id: package.html 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.
*/
-->
<body>
Portlet wrapper objects for some of the servlet api objects. The wrappers simply delegate to the
underlying, corresponding portlet objects. The portlet wrapper objects makes it easier to reuse
interceptors and components from struts2 core.
</body>
@@ -1,278 +0,0 @@
/*
* $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.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* A simple mock class to interact with Struts 2 API's that require a servlet request
*/
public class HttpServletRequestMock implements HttpServletRequest {
private String servletPath;
private Map parameterMap;
public String getAuthType() {
return null;
}
public String getContextPath() {
return null;
}
public Cookie[] getCookies() {
return null;
}
public long getDateHeader(String arg0) {
return 0;
}
public String getHeader(String arg0) {
return null;
}
public Enumeration getHeaderNames() {
return null;
}
public Enumeration getHeaders(String arg0) {
return null;
}
public int getIntHeader(String arg0) {
return 0;
}
public String getMethod() {
return null;
}
public String getPathInfo() {
return null;
}
public String getPathTranslated() {
return null;
}
public String getQueryString() {
return null;
}
public String getRemoteUser() {
return null;
}
public String getRequestURI() {
return null;
}
public StringBuffer getRequestURL() {
return null;
}
public String getRequestedSessionId() {
return null;
}
public String getServletPath() {
return servletPath;
}
public HttpSession getSession() {
return null;
}
public HttpSession getSession(boolean arg0) {
return null;
}
public Principal getUserPrincipal() {
return null;
}
public boolean isRequestedSessionIdFromCookie() {
return false;
}
public boolean isRequestedSessionIdFromURL() {
return false;
}
public boolean isRequestedSessionIdFromUrl() {
return false;
}
public boolean isRequestedSessionIdValid() {
return false;
}
public boolean isUserInRole(String arg0) {
return false;
}
public Object getAttribute(String arg0) {
return null;
}
public Enumeration getAttributeNames() {
return null;
}
public String getCharacterEncoding() {
return null;
}
public int getContentLength() {
return 0;
}
public String getContentType() {
return null;
}
public ServletInputStream getInputStream() throws IOException {
return null;
}
public String getLocalAddr() {
return null;
}
public String getLocalName() {
return null;
}
public int getLocalPort() {
return 0;
}
public Locale getLocale() {
return null;
}
public Enumeration getLocales() {
return null;
}
public String getParameter(String arg0) {
return null;
}
public Map getParameterMap() {
return parameterMap;
}
public Enumeration getParameterNames() {
return null;
}
public String[] getParameterValues(String arg0) {
return null;
}
public String getProtocol() {
return null;
}
public BufferedReader getReader() throws IOException {
return null;
}
public String getRealPath(String arg0) {
return null;
}
public String getRemoteAddr() {
return null;
}
public String getRemoteHost() {
return null;
}
public int getRemotePort() {
return 0;
}
public RequestDispatcher getRequestDispatcher(String arg0) {
return null;
}
public String getScheme() {
return null;
}
public String getServerName() {
return null;
}
public int getServerPort() {
return 0;
}
public boolean isSecure() {
return false;
}
public void removeAttribute(String arg0) {
}
public void setAttribute(String arg0, Object arg1) {
}
public void setCharacterEncoding(String arg0)
throws UnsupportedEncodingException {
}
/**
* @param parameterMap the parameterMap to set
*/
public HttpServletRequestMock setParameterMap(Map parameterMap) {
this.parameterMap = parameterMap;
return this;
}
/**
* @param servletPath the servletPath to set
*/
public HttpServletRequestMock setServletPath(String servletPath) {
this.servletPath = servletPath;
return this;
}
}
@@ -22,8 +22,8 @@ package org.apache.struts2.portlet.util;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.StringTokenizer;
@@ -59,15 +59,16 @@ public class PortletUrlHelper {
*
* @param action The action the URL should invoke.
* @param namespace The namespace of the action to invoke.
* @param method The method of the action to invoke.
* @param params The parameters of the URL.
* @param type The type of the url, either <tt>action</tt> or <tt>render</tt>
* @param mode The PortletMode of the URL.
* @param state The WindowState of the URL.
* @return The URL String.
*/
public static String buildUrl(String action, String namespace, Map params,
public static String buildUrl(String action, String namespace, String method, Map params,
String type, String mode, String state) {
return buildUrl(action, namespace, params, null, type, mode, state,
return buildUrl(action, namespace, method, params, null, type, mode, state,
true, true);
}
@@ -76,9 +77,10 @@ public class PortletUrlHelper {
*
* @see #buildUrl(String, String, Map, String, String, String)
*/
public static String buildUrl(String action, String namespace, Map params,
public static String buildUrl(String action, String namespace, String method, Map params,
String scheme, String type, String portletMode, String windowState,
boolean includeContext, boolean encodeResult) {
StringBuffer resultingAction = new StringBuffer();
RenderRequest request = PortletActionContext.getRenderRequest();
RenderResponse response = PortletActionContext.getRenderResponse();
LOG.debug("Creating url. Action = " + action + ", Namespace = "
@@ -102,15 +104,17 @@ public class PortletUrlHelper {
}
}
if (TextUtils.stringSet(namespace)) {
StringBuffer sb = new StringBuffer();
sb.append(namespace);
resultingAction.append(namespace);
if(!action.startsWith("/") && !namespace.endsWith("/")) {
sb.append("/");
resultingAction.append("/");
}
action = sb.append(action).toString();
LOG.debug("Resulting actionPath: " + action);
}
params.put(PortletActionConstants.ACTION_PARAM, new String[] { action });
resultingAction.append(action);
if(TextUtils.stringSet(method)) {
resultingAction.append("!").append(method);
}
LOG.debug("Resulting actionPath: " + resultingAction);
params.put(PortletActionConstants.ACTION_PARAM, new String[] { resultingAction.toString() });
PortletURL url = null;
if ("action".equalsIgnoreCase(type)) {
@@ -230,7 +234,7 @@ public class PortletUrlHelper {
public static Map ensureParamsAreStringArrays(Map params) {
Map result = null;
if (params != null) {
result = new HashMap(params.size());
result = new LinkedHashMap(params.size());
Iterator it = params.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
@@ -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;
@@ -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";
@@ -262,7 +262,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);
}
}
@@ -317,8 +317,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();
@@ -326,9 +328,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);
}
}
}
}
@@ -20,33 +20,24 @@
*/
package org.apache.struts2.views.freemarker;
import java.io.IOException;
import java.io.Writer;
import java.util.Locale;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import freemarker.template.*;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.StrutsResultSupport;
import org.apache.struts2.portlet.PortletActionConstants;
import org.apache.struts2.portlet.context.PortletActionContext;
import org.apache.struts2.views.util.ResourceUtil;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.inject.Inject;
import com.opensymphony.xwork2.util.ValueStack;
import freemarker.template.Configuration;
import freemarker.template.ObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
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.Locale;
/**
*/
@@ -136,7 +127,6 @@ public class PortletFreemarkerResult extends StrutsResultSupport {
private void executeRenderResult(String location,
ActionInvocation invocation) throws TemplateException, IOException,
TemplateModelException, PortletException {
prepareServletActionContext();
this.location = location;
this.invocation = invocation;
this.configuration = getConfiguration();
@@ -164,17 +154,6 @@ public class PortletFreemarkerResult extends StrutsResultSupport {
}
}
/**
*
*/
private void prepareServletActionContext() throws PortletException,
IOException {
PortletRequestDispatcher disp = PortletActionContext.getPortletConfig()
.getPortletContext().getNamedDispatcher("preparator");
disp.include(PortletActionContext.getRenderRequest(),
PortletActionContext.getRenderResponse());
}
/**
* This method is called from {@link #doExecute(String, ActionInvocation)}
* to obtain the FreeMarker configuration object that this result will use
@@ -242,7 +242,7 @@ public class StrutsModels {
return date;
}
public DateTimePickerModel getDateTimePicker() {
public DateTimePickerModel getDatetimepicker() {
if (dateTimePicker == null) {
dateTimePicker = new DateTimePickerModel(stack, req, res);
}
@@ -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 ComponentTagSupport {
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 ComponentTagSupport {
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) {
@@ -84,6 +92,10 @@ public class URLTag extends ComponentTagSupport {
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 ComponentTagSupport {
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 ComponentTagSupport {
public void setAnchor(String anchor) {
this.anchor = anchor;
}
public void setForceAddSchemeHostAndPort(String forceAddSchemeHostAndPort) {
this.forceAddSchemeHostAndPort = forceAddSchemeHostAndPort;
}
}
@@ -205,7 +205,7 @@ public class IteratorGeneratorTag extends StrutsBodyTagSupport {
count = ((Long)countObj).intValue();
}
else if (countObj instanceof Double) {
count = ((Long)countObj).intValue();
count = ((Double)countObj).intValue();
}
else if (countObj instanceof String) {
try {
@@ -214,7 +214,7 @@ public class SubsetIteratorTag extends StrutsBodyTagSupport {
count = ((Long)countObj).intValue();
}
else if (countObj instanceof Double) {
count = ((Long)countObj).intValue();
count = ((Double)countObj).intValue();
}
else if (countObj instanceof String) {
try {
@@ -240,7 +240,7 @@ public class SubsetIteratorTag extends StrutsBodyTagSupport {
start = ((Long)startObj).intValue();
}
else if (startObj instanceof Double) {
start = ((Long)startObj).intValue();
start = ((Double)startObj).intValue();
}
else if (startObj instanceof String) {
try {

Some files were not shown because too many files have changed in this diff Show More