WW-1488 Update license headers for Struts 2 source.

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@471756 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ted Nathan Husted
2006-11-06 15:01:43 +00:00
parent 9b30bb4b5d
commit 1181c3d502
729 changed files with 23440 additions and 20684 deletions
+174
View File
@@ -0,0 +1,174 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
+6
View File
@@ -0,0 +1,6 @@
Apache Struts
Copyright 2006 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/
@@ -1,3 +1,24 @@
/*
* $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 example;
import com.opensymphony.xwork2.ActionSupport;
@@ -1,3 +1,24 @@
/*
* $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 example;
/**
@@ -1,3 +1,24 @@
/*
* $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 example;
public class Login extends ExampleSupport {
@@ -1,3 +1,24 @@
/*
* $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 example;
import com.opensymphony.xwork2.ActionSupport;
@@ -1,3 +1,24 @@
/*
* $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 example;
import com.opensymphony.xwork2.ActionSupport;
@@ -1,3 +1,24 @@
/*
* $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 example;
import com.opensymphony.xwork2.ActionSupport;
@@ -1,19 +1,22 @@
/*
* Copyright 1999-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
@@ -73,7 +76,7 @@ public final class Constants {
*/
public static final String HOST = "host";
// ---- Error Messages ----
/**
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2000-2004 Apache Software Foundation
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2000-2004 Apache Software Foundation
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 1999-2004 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
@@ -1,3 +1,24 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
import org.apache.struts.apps.mailreader.dao.User;
@@ -1,3 +1,24 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
import com.opensymphony.xwork2.Preparable;
@@ -116,7 +137,7 @@ public class Subscription extends MailreaderSupport
}
if (hasErrors()) return INPUT;
saveUser();
return SUCCESS;
}
@@ -1,3 +1,24 @@
/*
* $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package mailreader2;
/**
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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;
@@ -23,13 +26,13 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ExampleAction extends ActionSupport {
private String name = "PortletWork Example";
public String getName() {
return name;
}
public Map getRenderParameters() {
return ActionContext.getContext().getParameters();
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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;
@@ -22,7 +25,7 @@ import com.opensymphony.xwork2.ActionSupport;
/**
*/
public class FormExample extends ActionSupport {
String firstName = null;
String lastName = null;
public String execute() throws Exception {
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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;
@@ -24,11 +27,11 @@ import com.opensymphony.xwork2.ActionSupport;
public class FormExampleWithValidation extends ActionSupport {
private String firstName = null;
private String lastName = null;
public String input() {
return SUCCESS;
}
public String getFirstName() {
return firstName;
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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;
@@ -30,14 +33,14 @@ import com.opensymphony.xwork2.ActionSupport;
public class FormResultAction extends ActionSupport {
private String result = null;
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public Collection getRenderParams() {
RenderRequest req = PortletActionContext.getRenderRequest();
Map params = req.getParameterMap();
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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;
@@ -40,7 +43,7 @@ public class SavePrefsAction extends ActionSupport {
public void setPreferenceTwo(String preferenceTwo) {
this.preferenceTwo = preferenceTwo;
}
public String execute() throws Exception {
ActionRequest req = PortletActionContext.getActionRequest();
PortletPreferences prefs = req.getPreferences();
@@ -49,7 +52,7 @@ public class SavePrefsAction extends ActionSupport {
prefs.store();
return SUCCESS;
}
public String showForm() throws Exception {
PortletPreferences prefs = PortletActionContext.getRequest().getPreferences();
preferenceOne = prefs.getValue("preferenceOne", "not set");
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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.spring;
@@ -26,26 +29,26 @@ import com.opensymphony.xwork2.ActionSupport;
/**
*/
public class SpringAction extends ActionSupport {
private ThingManager thingManager = null;
private String thing = null;
public void setThingManager(ThingManager thingManager) {
this.thingManager = thingManager;
}
public List getThings() {
return thingManager.getThings();
}
public String getThing() {
return thing;
}
public void setThing(String thing) {
this.thing = thing;
}
public String execute() {
if(StringUtils.isNotEmpty(thing)) {
thingManager.addThing(thing);
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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.spring;
@@ -24,11 +27,11 @@ import java.util.List;
*/
public class ThingManager {
private List things = new ArrayList();
public void addThing(String thing) {
things.add(thing);
}
public List getThings() {
return things;
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase;
@@ -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.showcase;
import org.apache.struts2.showcase.ajax.tree.Category;
@@ -8,27 +28,27 @@ import com.opensymphony.xwork2.ActionSupport;
public class DynamicTreeSelectAction extends ActionSupport {
private long nodeId;
private Category currentCategory;
public void setNodeId(long nodeId) {
this.nodeId = nodeId;
}
public long getNodeId() {
return nodeId;
}
public String execute() throws Exception {
currentCategory = Category.getById(nodeId);
return SUCCESS;
}
public String getNodeName() {
return currentCategory.getName();
}
private long nodeId;
private Category currentCategory;
public void setNodeId(long nodeId) {
this.nodeId = nodeId;
}
public long getNodeId() {
return nodeId;
}
public String execute() throws Exception {
currentCategory = Category.getById(nodeId);
return SUCCESS;
}
public String getNodeName() {
return currentCategory.getName();
}
}
//START SNIPPET: treeExampleDynamicJavaSelected
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase;
@@ -26,198 +29,198 @@ import com.opensymphony.xwork2.ActionSupport;
/**
*/
public class LotsOfOptiontransferselectAction extends ActionSupport {
private List _favouriteCartoonCharactersKeys;
private List _notFavouriteCartoonCharactersKeys;
private List _favouriteCarsKeys;
private List _notFavouriteCarsKeys;
private List _favouriteMotorcyclesKeys;
private List _notFavouriteMotorcyclesKeys;
private List _favouriteCountriesKeys;
private List _notFavouriteCountriesKeys;
private List _prioritisedFavouriteCartoonCharacters;
private List _prioritisedFavouriteCars;
private List _prioritisedFavouriteCountries;
// Cartoon Characters
public Map getDefaultFavouriteCartoonCharacters() {
Map m = new LinkedHashMap();
m.put("heMan", "He-Man");
m.put("popeye", "Popeye");
m.put("mockeyMouse", "Mickey Mouse");
return m;
}
public Map getDefaultNotFavouriteCartoonCharacters() {
Map m = new LinkedHashMap();
m.put("donaldDuck", "Donald Duck");
m.put("atomicAnt", "Atomic Ant");
m.put("pinkPainter", "Pink Painter");
return m;
}
public List getFavouriteCartoonCharacters() {
return _favouriteCartoonCharactersKeys;
}
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
}
public List getNotFavouriteCartoonCharacters() {
return _notFavouriteCartoonCharactersKeys;
}
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
}
// Cars
public Map getDefaultFavouriteCars() {
Map m = new LinkedHashMap();
m.put("alfaRomeo", "Alfa Romeo");
m.put("Toyota", "Toyota");
m.put("Mitsubitshi", "Mitsubitshi");
return m;
}
public Map getDefaultNotFavouriteCars() {
Map m = new LinkedHashMap();
m.put("ford", "Ford");
m.put("landRover", "Land Rover");
m.put("mercedes", "Mercedes");
return m;
}
public List getFavouriteCars() {
return _favouriteCarsKeys;
}
public void setFavouriteCars(List favouriteCars) {
_favouriteCarsKeys = favouriteCars;
}
public List getNotFavouriteCars() {
return _notFavouriteCarsKeys;
}
public void setNotFavouriteCars(List notFavouriteCars) {
_notFavouriteCarsKeys = notFavouriteCars;
}
// Motorcycles
public Map getDefaultFavouriteMotorcycles() {
Map m = new LinkedHashMap();
m.put("honda", "Honda");
m.put("yamaha", "Yamaha");
m.put("Aprillia", "Aprillia");
return m;
}
public Map getDefaultNotFavouriteMotorcycles() {
Map m = new LinkedHashMap();
m.put("cagiva", "Cagiva");
m.put("harleyDavidson", "Harley Davidson");
m.put("suzuki", "Suzuki");
return m;
}
public List getFavouriteMotorcycles() {
return _favouriteMotorcyclesKeys;
}
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
_favouriteMotorcyclesKeys = favouriteMotorcycles;
}
public List getNotFavouriteMotorcycles() {
return _notFavouriteMotorcyclesKeys;
}
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
}
// Countries
public Map getDefaultFavouriteCountries() {
Map m = new LinkedHashMap();
m.put("england", "England");
m.put("america", "America");
m.put("brazil", "Brazil");
return m;
}
public Map getDefaultNotFavouriteCountries() {
Map m = new LinkedHashMap();
m.put("germany", "Germany");
m.put("china", "China");
m.put("russia", "Russia");
return m;
}
public List getFavouriteCountries() {
return _favouriteCountriesKeys;
}
public void setFavouriteCountries(List favouriteCountries) {
_favouriteCountriesKeys = favouriteCountries;
}
public List getNotFavouriteCountries() {
return _notFavouriteCountriesKeys;
}
public void setNotFavouriteCountries(List notFavouriteCountries) {
_notFavouriteCountriesKeys = notFavouriteCountries;
}
public List getPrioritisedFavouriteCartoonCharacters() {
return _prioritisedFavouriteCartoonCharacters;
}
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
public List getPrioritisedFavouriteCars() {
return _prioritisedFavouriteCars;
}
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
_prioritisedFavouriteCars = prioritisedFavouriteCars;
}
public List getPrioritisedFavouriteCountries() {
return _prioritisedFavouriteCountries;
}
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
}
// actions
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
private List _favouriteCartoonCharactersKeys;
private List _notFavouriteCartoonCharactersKeys;
private List _favouriteCarsKeys;
private List _notFavouriteCarsKeys;
private List _favouriteMotorcyclesKeys;
private List _notFavouriteMotorcyclesKeys;
private List _favouriteCountriesKeys;
private List _notFavouriteCountriesKeys;
private List _prioritisedFavouriteCartoonCharacters;
private List _prioritisedFavouriteCars;
private List _prioritisedFavouriteCountries;
// Cartoon Characters
public Map getDefaultFavouriteCartoonCharacters() {
Map m = new LinkedHashMap();
m.put("heMan", "He-Man");
m.put("popeye", "Popeye");
m.put("mockeyMouse", "Mickey Mouse");
return m;
}
public Map getDefaultNotFavouriteCartoonCharacters() {
Map m = new LinkedHashMap();
m.put("donaldDuck", "Donald Duck");
m.put("atomicAnt", "Atomic Ant");
m.put("pinkPainter", "Pink Painter");
return m;
}
public List getFavouriteCartoonCharacters() {
return _favouriteCartoonCharactersKeys;
}
public void setFavouriteCartoonCharacters(List favouriteCartoonCharacters) {
_favouriteCartoonCharactersKeys = favouriteCartoonCharacters;
}
public List getNotFavouriteCartoonCharacters() {
return _notFavouriteCartoonCharactersKeys;
}
public void setNotFavouriteCartoonCharacters(List notFavouriteCartoonCharacters) {
_notFavouriteCartoonCharactersKeys = notFavouriteCartoonCharacters;
}
// Cars
public Map getDefaultFavouriteCars() {
Map m = new LinkedHashMap();
m.put("alfaRomeo", "Alfa Romeo");
m.put("Toyota", "Toyota");
m.put("Mitsubitshi", "Mitsubitshi");
return m;
}
public Map getDefaultNotFavouriteCars() {
Map m = new LinkedHashMap();
m.put("ford", "Ford");
m.put("landRover", "Land Rover");
m.put("mercedes", "Mercedes");
return m;
}
public List getFavouriteCars() {
return _favouriteCarsKeys;
}
public void setFavouriteCars(List favouriteCars) {
_favouriteCarsKeys = favouriteCars;
}
public List getNotFavouriteCars() {
return _notFavouriteCarsKeys;
}
public void setNotFavouriteCars(List notFavouriteCars) {
_notFavouriteCarsKeys = notFavouriteCars;
}
// Motorcycles
public Map getDefaultFavouriteMotorcycles() {
Map m = new LinkedHashMap();
m.put("honda", "Honda");
m.put("yamaha", "Yamaha");
m.put("Aprillia", "Aprillia");
return m;
}
public Map getDefaultNotFavouriteMotorcycles() {
Map m = new LinkedHashMap();
m.put("cagiva", "Cagiva");
m.put("harleyDavidson", "Harley Davidson");
m.put("suzuki", "Suzuki");
return m;
}
public List getFavouriteMotorcycles() {
return _favouriteMotorcyclesKeys;
}
public void setFavouriteMotorcycles(List favouriteMotorcycles) {
_favouriteMotorcyclesKeys = favouriteMotorcycles;
}
public List getNotFavouriteMotorcycles() {
return _notFavouriteMotorcyclesKeys;
}
public void setNotFavouriteMotorcycles(List notFavouriteMotorcycles) {
_notFavouriteMotorcyclesKeys = notFavouriteMotorcycles;
}
// Countries
public Map getDefaultFavouriteCountries() {
Map m = new LinkedHashMap();
m.put("england", "England");
m.put("america", "America");
m.put("brazil", "Brazil");
return m;
}
public Map getDefaultNotFavouriteCountries() {
Map m = new LinkedHashMap();
m.put("germany", "Germany");
m.put("china", "China");
m.put("russia", "Russia");
return m;
}
public List getFavouriteCountries() {
return _favouriteCountriesKeys;
}
public void setFavouriteCountries(List favouriteCountries) {
_favouriteCountriesKeys = favouriteCountries;
}
public List getNotFavouriteCountries() {
return _notFavouriteCountriesKeys;
}
public void setNotFavouriteCountries(List notFavouriteCountries) {
_notFavouriteCountriesKeys = notFavouriteCountries;
}
public List getPrioritisedFavouriteCartoonCharacters() {
return _prioritisedFavouriteCartoonCharacters;
}
public void setPrioritisedFavouriteCartoonCharacters(List prioritisedFavouriteCartoonCharacters) {
_prioritisedFavouriteCartoonCharacters = prioritisedFavouriteCartoonCharacters;
}
public List getPrioritisedFavouriteCars() {
return _prioritisedFavouriteCars;
}
public void setPrioritisedFavouriteCars(List prioritisedFavouriteCars) {
_prioritisedFavouriteCars = prioritisedFavouriteCars;
}
public List getPrioritisedFavouriteCountries() {
return _prioritisedFavouriteCountries;
}
public void setPrioritisedFavouriteCountries(List prioritisedFavouriteCountries) {
_prioritisedFavouriteCountries = prioritisedFavouriteCountries;
}
// actions
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
}
@@ -1,75 +1,78 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
*/
public class LotsOfRichtexteditorAction extends ActionSupport {
public String description1;
public String description2 = "This is Description 2";
public String description3;
public String description4 = "This is Description 4";
public String getDescription1() {
return this.description1;
}
public void setDescription1(String description1) {
this.description1 = description1;
}
public String getDescription2() {
return this.description2;
}
public void setDescription2(String description2) {
this.description2 = description2;
}
public String getDescription3() {
return this.description3;
}
public void setDescription3(String description3) {
this.description3 = description3;
}
public String getDescription4() {
return this.description4;
}
public void setDescription4(String description4) {
this.description4 = description4;
}
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
public String description1;
public String description2 = "This is Description 2";
public String description3;
public String description4 = "This is Description 4";
public String getDescription1() {
return this.description1;
}
public void setDescription1(String description1) {
this.description1 = description1;
}
public String getDescription2() {
return this.description2;
}
public void setDescription2(String description2) {
this.description2 = description2;
}
public String getDescription3() {
return this.description3;
}
public void setDescription3(String description3) {
this.description3 = description3;
}
public String getDescription4() {
return this.description4;
}
public void setDescription4(String description4) {
this.description4 = description4;
}
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
}
@@ -1,16 +1,36 @@
/*
* $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.showcase;
import org.apache.struts2.showcase.ajax.tree.Category;
import com.opensymphony.xwork2.ActionSupport;
// START SNIPPET: treeExampleDynamicJavaShow
// START SNIPPET: treeExampleDynamicJavaShow
public class ShowDynamicTreeAction extends ActionSupport {
public Category getTreeRootNode() {
return Category.getById(1);
}
public Category getTreeRootNode() {
return Category.getById(1);
}
}
// END SNIPPET: treeExampleDynamicJavaShow
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase;
@@ -33,11 +36,11 @@ import java.io.File;
/**
*/
public class UITagExample extends ActionSupport implements Validateable {
private static final long serialVersionUID = -94044809860988047L;
String name;
private static final long serialVersionUID = -94044809860988047L;
String name;
Date birthday;
String bio;
String favoriteColor;
@@ -51,89 +54,89 @@ public class UITagExample extends ActionSupport implements Validateable {
String favouriteLanguage;
String favouriteVehicalType = "MotorcycleKey";
String favouriteVehicalSpecific = "YamahaKey";
List leftSideCartoonCharacters;
List rightSideCartoonCharacters;
List favouriteLanguages = new ArrayList();
List vehicalTypeList = new ArrayList();
Map vehicalSpecificMap = new HashMap();
String thoughts;
public UITagExample() {
favouriteLanguages.add(new Language("EnglishKey", "English Language"));
favouriteLanguages.add(new Language("FrenchKey", "French Language"));
favouriteLanguages.add(new Language("SpanishKey", "Spanish Language"));
VehicalType car = new VehicalType("CarKey", "Car");
VehicalType motorcycle = new VehicalType("MotorcycleKey", "Motorcycle");
vehicalTypeList.add(car);
vehicalTypeList.add(motorcycle);
List cars = new ArrayList();
cars.add(new VehicalSpecific("MercedesKey", "Mercedes"));
cars.add(new VehicalSpecific("HondaKey", "Honda"));
cars.add(new VehicalSpecific("FordKey", "Ford"));
List motorcycles = new ArrayList();
motorcycles.add(new VehicalSpecific("SuzukiKey", "Suzuki"));
motorcycles.add(new VehicalSpecific("YamahaKey", "Yamaha"));
vehicalSpecificMap.put(car, cars);
vehicalSpecificMap.put(motorcycle, motorcycles);
favouriteLanguages.add(new Language("EnglishKey", "English Language"));
favouriteLanguages.add(new Language("FrenchKey", "French Language"));
favouriteLanguages.add(new Language("SpanishKey", "Spanish Language"));
VehicalType car = new VehicalType("CarKey", "Car");
VehicalType motorcycle = new VehicalType("MotorcycleKey", "Motorcycle");
vehicalTypeList.add(car);
vehicalTypeList.add(motorcycle);
List cars = new ArrayList();
cars.add(new VehicalSpecific("MercedesKey", "Mercedes"));
cars.add(new VehicalSpecific("HondaKey", "Honda"));
cars.add(new VehicalSpecific("FordKey", "Ford"));
List motorcycles = new ArrayList();
motorcycles.add(new VehicalSpecific("SuzukiKey", "Suzuki"));
motorcycles.add(new VehicalSpecific("YamahaKey", "Yamaha"));
vehicalSpecificMap.put(car, cars);
vehicalSpecificMap.put(motorcycle, motorcycles);
}
public List getLeftSideCartoonCharacters() {
return leftSideCartoonCharacters;
return leftSideCartoonCharacters;
}
public void setLeftSideCartoonCharacters(List leftSideCartoonCharacters) {
this.leftSideCartoonCharacters = leftSideCartoonCharacters;
this.leftSideCartoonCharacters = leftSideCartoonCharacters;
}
public List getRightSideCartoonCharacters() {
return rightSideCartoonCharacters;
return rightSideCartoonCharacters;
}
public void setRightSideCartoonCharacters(List rightSideCartoonCharacters) {
this.rightSideCartoonCharacters = rightSideCartoonCharacters;
this.rightSideCartoonCharacters = rightSideCartoonCharacters;
}
public String getFavouriteVehicalType() {
return favouriteVehicalType;
return favouriteVehicalType;
}
public void setFavouriteVehicalType(String favouriteVehicalType) {
this.favouriteVehicalType = favouriteVehicalType;
this.favouriteVehicalType = favouriteVehicalType;
}
public String getFavouriteVehicalSpecific() {
return favouriteVehicalSpecific;
return favouriteVehicalSpecific;
}
public void setFavouriteVehicalSpecific(String favouriteVehicalSpecific) {
this.favouriteVehicalSpecific = favouriteVehicalSpecific;
this.favouriteVehicalSpecific = favouriteVehicalSpecific;
}
public List getVehicalTypeList() {
return vehicalTypeList;
return vehicalTypeList;
}
public List getVehicalSpecificList() {
ValueStack stack = ServletActionContext.getValueStack(ServletActionContext.getRequest());
Object vehicalType = stack.findValue("top");
if (vehicalType != null && vehicalType instanceof VehicalType) {
List l = (List) vehicalSpecificMap.get(vehicalType);
return l;
}
return Collections.EMPTY_LIST;
ValueStack stack = ServletActionContext.getValueStack(ServletActionContext.getRequest());
Object vehicalType = stack.findValue("top");
if (vehicalType != null && vehicalType instanceof VehicalType) {
List l = (List) vehicalSpecificMap.get(vehicalType);
return l;
}
return Collections.EMPTY_LIST;
}
public List getFavouriteLanguages() {
return favouriteLanguages;
return favouriteLanguages;
}
public String execute() throws Exception {
@@ -215,100 +218,100 @@ public class UITagExample extends ActionSupport implements Validateable {
public void setPictureFileName(String pictureFileName) {
this.pictureFileName = pictureFileName;
}
public void setFavouriteLanguage(String favouriteLanguage) {
this.favouriteLanguage = favouriteLanguage;
this.favouriteLanguage = favouriteLanguage;
}
public String getFavouriteLanguage() {
return favouriteLanguage;
return favouriteLanguage;
}
public void setThoughts(String thoughts) {
this.thoughts = thoughts;
this.thoughts = thoughts;
}
public String getThoughts() {
return this.thoughts;
return this.thoughts;
}
public String doSubmit() {
return SUCCESS;
return SUCCESS;
}
// === inner class
// === inner class
public static class Language {
String description;
String key;
public Language(String key, String description) {
this.key = key;
this.description = description;
}
public String getKey() {
return key;
}
public String getDescription() {
return description;
}
String description;
String key;
public Language(String key, String description) {
this.key = key;
this.description = description;
}
public String getKey() {
return key;
}
public String getDescription() {
return description;
}
}
public static class VehicalType {
String key;
String description;
public VehicalType(String key, String description) {
this.key = key;
this.description = description;
}
public String getKey() { return this.key; }
public String getDescription() { return this.description; }
public boolean equals(Object obj) {
if (! (obj instanceof VehicalType)) {
return false;
}
else {
return key.equals(((VehicalType)obj).getKey());
}
}
public int hashCode() {
return key.hashCode();
}
String key;
String description;
public VehicalType(String key, String description) {
this.key = key;
this.description = description;
}
public String getKey() { return this.key; }
public String getDescription() { return this.description; }
public boolean equals(Object obj) {
if (! (obj instanceof VehicalType)) {
return false;
}
else {
return key.equals(((VehicalType)obj).getKey());
}
}
public int hashCode() {
return key.hashCode();
}
}
public static class VehicalSpecific {
String key;
String description;
public VehicalSpecific(String key, String description) {
this.key = key;
this.description = description;
}
public String getKey() { return this.key; }
public String getDescription() { return this.description; }
public boolean equals(Object obj) {
if (! (obj instanceof VehicalSpecific)) {
return false;
}
else {
return key.equals(((VehicalSpecific)obj).getKey());
}
}
public int hashCode() {
return key.hashCode();
}
String key;
String description;
public VehicalSpecific(String key, String description) {
this.key = key;
this.description = description;
}
public String getKey() { return this.key; }
public String getDescription() { return this.description; }
public boolean equals(Object obj) {
if (! (obj instanceof VehicalSpecific)) {
return false;
}
else {
return key.equals(((VehicalSpecific)obj).getKey());
}
}
public int hashCode() {
return key.hashCode();
}
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.action;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.action;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.action;
@@ -1,42 +1,45 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
*/
public class ActionChain1 extends ActionSupport {
private static final long serialVersionUID = -6811701750042275153L;
private String actionChain1Property1 = "Property Set In Action Chain 1";
private static final long serialVersionUID = -6811701750042275153L;
public String getActionChain1Property1() {
return actionChain1Property1;
}
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String input() throws Exception {
return SUCCESS;
}
private String actionChain1Property1 = "Property Set In Action Chain 1";
public String getActionChain1Property1() {
return actionChain1Property1;
}
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String input() throws Exception {
return SUCCESS;
}
}
@@ -1,55 +1,58 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
*/
public class ActionChain2 extends ActionSupport {
private static final long serialVersionUID = 3951745956044674809L;
private String actionChain1Property1;
private String actionChain2Property1 = "Property Set in Action Chain 2";
public String getActionChain1Property1() {
return actionChain1Property1;
}
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
public String execute() throws Exception {
return SUCCESS;
}
private static final long serialVersionUID = 3951745956044674809L;
private String actionChain1Property1;
private String actionChain2Property1 = "Property Set in Action Chain 2";
public String getActionChain1Property1() {
return actionChain1Property1;
}
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
public String execute() throws Exception {
return SUCCESS;
}
}
@@ -1,65 +1,68 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.actionchaining;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
*/
public class ActionChain3 extends ActionSupport {
private static final long serialVersionUID = -1456568865075250621L;
private String actionChain1Property1;
private String actionChain2Property1;
private String actionChain3Property1 = "Property set in Action Chain 3";
public String getActionChain1Property1() {
return actionChain1Property1;
}
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
public String getActionChain3Property1() {
return actionChain3Property1;
}
public void setActionChain3Property1(String actionChain3Property1) {
this.actionChain3Property1 = actionChain3Property1;
}
public String execute() throws Exception {
return SUCCESS;
}
private static final long serialVersionUID = -1456568865075250621L;
private String actionChain1Property1;
private String actionChain2Property1;
private String actionChain3Property1 = "Property set in Action Chain 3";
public String getActionChain1Property1() {
return actionChain1Property1;
}
public void setActionChain1Property1(String actionChain1Property1) {
this.actionChain1Property1 = actionChain1Property1;
}
public String getActionChain2Property1() {
return actionChain2Property1;
}
public void setActionChain2Property1(String actionChain2Property1) {
this.actionChain2Property1 = actionChain2Property1;
}
public String getActionChain3Property1() {
return actionChain3Property1;
}
public void setActionChain3Property1(String actionChain3Property1) {
this.actionChain3Property1 = actionChain3Property1;
}
public String execute() throws Exception {
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.ajax;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.ajax;
@@ -27,46 +30,46 @@ import com.opensymphony.xwork2.ActionSupport;
*/
public class Example4ShowPanelAction extends ActionSupport {
private String name;
private String gender;
private static final long serialVersionUID = 7751976335066456596L;
private String name;
private String gender;
public String panel1() throws Exception {
return SUCCESS;
}
public String panel2() throws Exception {
return SUCCESS;
}
public String panel3() throws Exception {
return SUCCESS;
}
private static final long serialVersionUID = 7751976335066456596L;
public String getGender() {
return gender;
}
public String panel1() throws Exception {
return SUCCESS;
}
public void setGender(String gender) {
this.gender = gender;
}
public String panel2() throws Exception {
return SUCCESS;
}
public String getName() {
return name;
}
public String panel3() throws Exception {
return SUCCESS;
}
public void setName(String name) {
this.name = name;
}
public String getTodayDate() {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy");
return sdf.format(new Date());
}
public String getTodayTime() {
SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss");
return sdf.format(new Date());
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTodayDate() {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy");
return sdf.format(new Date());
}
public String getTodayTime() {
SimpleDateFormat sdf = new SimpleDateFormat("kk:mm:ss");
return sdf.format(new Date());
}
}
@@ -1,23 +1,43 @@
/*
* $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.showcase.ajax;
import com.opensymphony.xwork2.ActionSupport;
public class Example5Action extends ActionSupport {
private static final long serialVersionUID = 2111967621952300611L;
private String name;
private Integer age;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Integer getAge() { return age; }
public void setAge(Integer age) { this.age = age; }
@Override
public String execute() throws Exception {
return SUCCESS;
}
private static final long serialVersionUID = 2111967621952300611L;
private String name;
private Integer age;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Integer getAge() { return age; }
public void setAge(Integer age) { this.age = age; }
@Override
public String execute() throws Exception {
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.ajax.tree;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.ajax.tree;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.ajax.tree;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.application;
@@ -38,7 +41,7 @@ import java.util.Map;
public class MemoryStorage implements Storage {
private static final long serialVersionUID = 8611213748834904125L;
private static final long serialVersionUID = 8611213748834904125L;
private Map memory = new HashMap();
@@ -127,7 +130,7 @@ public class MemoryStorage implements Storage {
public Collection findAll( Class entityClass ) {
if (entityClass != null) {
return getEntityMap(entityClass).values();
return getEntityMap(entityClass).values();
} else {
return new ArrayList();
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.application;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.application;
@@ -36,9 +39,9 @@ import java.util.Arrays;
public class TestDataProvider implements Serializable, InitializingBean {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(TestDataProvider.class);
private static final Logger log = Logger.getLogger(TestDataProvider.class);
public static final String[] POSITIONS = {
"Developer",
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -29,29 +32,29 @@ import com.opensymphony.xwork2.interceptor.Interceptor;
public class ChatAuthenticationInterceptor implements Interceptor {
private static final long serialVersionUID = 1L;
private static final Log _log = LogFactory.getLog(ChatAuthenticationInterceptor.class);
public static final String USER_SESSION_KEY = "chatUserSessionKey";
private static final long serialVersionUID = 1L;
public void destroy() {
}
private static final Log _log = LogFactory.getLog(ChatAuthenticationInterceptor.class);
public void init() {
}
public static final String USER_SESSION_KEY = "chatUserSessionKey";
public String intercept(ActionInvocation invocation) throws Exception {
_log.debug("Authenticating chat user");
SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION);
User user = (User) session.get(USER_SESSION_KEY);
if (user == null) {
return Action.LOGIN;
}
return invocation.invoke();
}
public void destroy() {
}
public void init() {
}
public String intercept(ActionInvocation invocation) throws Exception {
_log.debug("Authenticating chat user");
SessionMap session = (SessionMap) ActionContext.getContext().get(ActionContext.SESSION);
User user = (User) session.get(USER_SESSION_KEY);
if (user == null) {
return Action.LOGIN;
}
return invocation.invoke();
}
}
@@ -1,33 +1,36 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
public class ChatException extends RuntimeException {
private static final long serialVersionUID = 1L;
public enum ErrorType {
ROOM_ALREADY_EXISTS,
USER_ALREADY_EXISTS,
NO_SUCH_ROOM_EXISTS
}
public ChatException(String description, ErrorType type) {
super(description);
}
private static final long serialVersionUID = 1L;
public enum ErrorType {
ROOM_ALREADY_EXISTS,
USER_ALREADY_EXISTS,
NO_SUCH_ROOM_EXISTS
}
public ChatException(String description, ErrorType type) {
super(description);
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -31,28 +34,28 @@ import com.opensymphony.xwork2.interceptor.Interceptor;
* Authenticate showcase chat example, make sure everyone have a username.
*/
public class ChatInterceptor implements Interceptor {
private static final Log _log = LogFactory.getLog(ChatInterceptor.class);
private static final long serialVersionUID = 1L;
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
private static final Log _log = LogFactory.getLog(ChatInterceptor.class);
public void destroy() {
}
private static final long serialVersionUID = 1L;
public void init() {
}
public static final String CHAT_USER_SESSION_KEY = "ChatUserSessionKey";
public String intercept(ActionInvocation invocation) throws Exception {
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
if (chatUser == null) {
_log.debug("Chat user not logged in");
return Action.LOGIN;
}
return invocation.invoke();
}
public void destroy() {
}
public void init() {
}
public String intercept(ActionInvocation invocation) throws Exception {
HttpSession session = (HttpSession) ActionContext.getContext().get(ActionContext.SESSION);
User chatUser = (User) session.getAttribute(CHAT_USER_SESSION_KEY);
if (chatUser == null) {
_log.debug("Chat user not logged in");
return Action.LOGIN;
}
return invocation.invoke();
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -25,41 +28,41 @@ import com.opensymphony.xwork2.ActionSupport;
public class ChatLoginAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map session;
private String name;
public ChatLoginAction(ChatService chatService) {
this.chatService = chatService;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String execute() throws Exception {
try {
chatService.login(new User(name));
session.put(ChatAuthenticationInterceptor.USER_SESSION_KEY, new User(name));
}
catch(ChatException e) {
e.printStackTrace();
addActionError(e.getMessage());
return INPUT;
}
return SUCCESS;
}
private static final long serialVersionUID = 1L;
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
private ChatService chatService;
private Map session;
private String name;
public ChatLoginAction(ChatService chatService) {
this.chatService = chatService;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String execute() throws Exception {
try {
chatService.login(new User(name));
session.put(ChatAuthenticationInterceptor.USER_SESSION_KEY, new User(name));
}
catch(ChatException e) {
e.printStackTrace();
addActionError(e.getMessage());
return INPUT;
}
return SUCCESS;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -25,31 +28,31 @@ import com.opensymphony.xwork2.ActionSupport;
public class ChatLogoutAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map session;
public ChatLogoutAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
if (user != null) {
chatService.logout(user.getName());
session.remove(ChatAuthenticationInterceptor.USER_SESSION_KEY);
}
return SUCCESS;
}
private ChatService chatService;
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
private Map session;
public ChatLogoutAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
if (user != null) {
chatService.logout(user.getName());
session.remove(ChatAuthenticationInterceptor.USER_SESSION_KEY);
}
return SUCCESS;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -1,46 +1,49 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
import java.util.Date;
public class ChatMessage {
private Date creationDate;
private String message;
private User creator;
public ChatMessage(String message, User creator) {
assert(message != null);
assert(creator != null);
this.creationDate = new Date(System.currentTimeMillis());
this.message = message;
this.creator = creator;
}
public Date getCreationDate() {
return creationDate;
}
public User getCreator() {
return creator;
}
public String getMessage() {
return message;
}
private Date creationDate;
private String message;
private User creator;
public ChatMessage(String message, User creator) {
assert(message != null);
assert(creator != null);
this.creationDate = new Date(System.currentTimeMillis());
this.message = message;
this.creator = creator;
}
public Date getCreationDate() {
return creationDate;
}
public User getCreator() {
return creator;
}
public String getMessage() {
return message;
}
}
@@ -1,34 +1,37 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
import java.util.List;
public interface ChatService {
List<User> getAvailableUsers();
void login(User user);
void logout(String name);
List<Room> getAvailableRooms();
void addRoom(Room room);
void enterRoom(User user, String roomName);
void exitRoom(String userName, String roomName);
List<ChatMessage> getMessagesInRoom(String roomName);
void sendMessageToRoom(String roomName, User user, String message);
List<User> getUsersAvailableInRoom(String roomName);
List<User> getAvailableUsers();
void login(User user);
void logout(String name);
List<Room> getAvailableRooms();
void addRoom(Room room);
void enterRoom(User user, String roomName);
void exitRoom(String userName, String roomName);
List<ChatMessage> getMessagesInRoom(String roomName);
void sendMessageToRoom(String roomName, User user, String message);
List<User> getUsersAvailableInRoom(String roomName);
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -23,90 +26,90 @@ import java.util.List;
import java.util.Map;
public class ChatServiceImpl implements ChatService {
private Map<String, User> availableUsers = new LinkedHashMap<String, User>();
private Map<String, Room> availableRooms = new LinkedHashMap<String, Room>();
public List<User> getAvailableUsers() {
return new ArrayList<User>(availableUsers.values());
}
public List<Room> getAvailableRooms() {
return new ArrayList<Room>(availableRooms.values());
}
private Map<String, User> availableUsers = new LinkedHashMap<String, User>();
private Map<String, Room> availableRooms = new LinkedHashMap<String, Room>();
public void addRoom(Room room) {
if (availableRooms.containsKey(room.getName())) {
throw new ChatException("room ["+room.getName()+"] is already available", ChatException.ErrorType.valueOf("ROOM_ALREADY_EXISTS"));
}
availableRooms.put(room.getName(), room);
}
public void login(User user) {
assert(user != null);
if (availableUsers.containsKey(user.getName())) {
throw new ChatException("User ["+user.getName()+"] already exists", ChatException.ErrorType.valueOf("USER_ALREADY_EXISTS"));
}
availableUsers.put(user.getName(), user);
}
public void logout(String name) {
assert(name != null);
assert(name.trim().length() > 0);
availableUsers.remove(name);
for (Room room : availableRooms.values()) {
if (room.hasMember(name)) {
room.memberExit(name);
}
}
}
public List<User> getAvailableUsers() {
return new ArrayList<User>(availableUsers.values());
}
public void exitRoom(String userName, String roomName) {
assert(roomName != null);
assert(roomName.trim().length()> 0);
if (availableRooms.containsKey(roomName)) {
Room room = availableRooms.get(roomName);
room.memberExit(userName);
}
}
public void enterRoom(User user, String roomName) {
assert(roomName != null);
assert(roomName.trim().length() > 0);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
room.memberEnter(user);
}
public List<Room> getAvailableRooms() {
return new ArrayList<Room>(availableRooms.values());
}
public List<ChatMessage> getMessagesInRoom(String roomName) {
assert(roomName != null);
assert(roomName.trim().length() > 0);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
return room.getChatMessages();
}
public void addRoom(Room room) {
if (availableRooms.containsKey(room.getName())) {
throw new ChatException("room ["+room.getName()+"] is already available", ChatException.ErrorType.valueOf("ROOM_ALREADY_EXISTS"));
}
availableRooms.put(room.getName(), room);
}
public void sendMessageToRoom(String roomName, User user, String message) {
assert(roomName != null);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
room.addMessage(new ChatMessage(message, user));
}
public void login(User user) {
assert(user != null);
if (availableUsers.containsKey(user.getName())) {
throw new ChatException("User ["+user.getName()+"] already exists", ChatException.ErrorType.valueOf("USER_ALREADY_EXISTS"));
}
availableUsers.put(user.getName(), user);
}
public List<User> getUsersAvailableInRoom(String roomName) {
assert(roomName != null);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
return room.getMembers();
}
public void logout(String name) {
assert(name != null);
assert(name.trim().length() > 0);
availableUsers.remove(name);
for (Room room : availableRooms.values()) {
if (room.hasMember(name)) {
room.memberExit(name);
}
}
}
public void exitRoom(String userName, String roomName) {
assert(roomName != null);
assert(roomName.trim().length()> 0);
if (availableRooms.containsKey(roomName)) {
Room room = availableRooms.get(roomName);
room.memberExit(userName);
}
}
public void enterRoom(User user, String roomName) {
assert(roomName != null);
assert(roomName.trim().length() > 0);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
room.memberEnter(user);
}
public List<ChatMessage> getMessagesInRoom(String roomName) {
assert(roomName != null);
assert(roomName.trim().length() > 0);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
return room.getChatMessages();
}
public void sendMessageToRoom(String roomName, User user, String message) {
assert(roomName != null);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
room.addMessage(new ChatMessage(message, user));
}
public List<User> getUsersAvailableInRoom(String roomName) {
assert(roomName != null);
if (! availableRooms.containsKey(roomName)) {
throw new ChatException("No such room exists ["+roomName+"]", ChatException.ErrorType.NO_SUCH_ROOM_EXISTS);
}
Room room = availableRooms.get(roomName);
return room.getMembers();
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -28,23 +31,23 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
public class ChatSessionListener implements HttpSessionListener {
private static final Log _log = LogFactory.getLog(ChatSessionListener.class);
public void sessionCreated(HttpSessionEvent event) {
}
private static final Log _log = LogFactory.getLog(ChatSessionListener.class);
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event.getSession();
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
if (context != null) {
User user = (User) session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY);
if (user != null) {
ChatService service = (ChatService) context.getBean("chatService");
service.logout(user.getName());
_log.info("session expired, logged user ["+user.getName()+"] out");
}
}
}
public void sessionCreated(HttpSessionEvent event) {
}
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event.getSession();
WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
if (context != null) {
User user = (User) session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY);
if (user != null) {
ChatService service = (ChatService) context.getBean("chatService");
service.logout(user.getName());
_log.info("session expired, logged user ["+user.getName()+"] out");
}
}
}
}
@@ -1,22 +1,25 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
public class Constants {
public static String UPDATE_FREQ = "30000";
public static String UPDATE_FREQ = "30000";
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -21,41 +24,41 @@ import com.opensymphony.xwork2.ActionSupport;
public class CrudRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private ChatService chatService;
private String name;
private String description;
public String getDescription() {
return description;
}
private ChatService chatService;
public void setDescription(String description) {
this.description = description;
}
private String name;
private String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public CrudRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String create() throws Exception {
try {
chatService.addRoom(new Room(name, description));
}
catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CrudRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String create() throws Exception {
try {
chatService.addRoom(new Room(name, description));
}
catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -27,30 +30,30 @@ import org.apache.commons.logging.LogFactory;
import org.apache.struts2.util.StrutsTypeConverter;
public class DateConverter extends StrutsTypeConverter {
private static final Log _log = LogFactory.getLog(DateConverter.class);
public Object convertFromString(Map context, String[] values, Class toClass) {
if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) {
SimpleDateFormat sdf = new SimpleDateFormat();
try {
return sdf.parse(values[0]);
}
catch(ParseException e) {
_log.error("error converting value ["+values[0]+"] to Date ", e);
}
}
return null;
}
private static final Log _log = LogFactory.getLog(DateConverter.class);
public String convertToString(Map context, Object o) {
if (o instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
return sdf.format((Date) o);
}
return "";
}
public Object convertFromString(Map context, String[] values, Class toClass) {
if (values.length > 0 && values[0] != null && values[0].trim().length() > 0) {
SimpleDateFormat sdf = new SimpleDateFormat();
try {
return sdf.parse(values[0]);
}
catch(ParseException e) {
_log.error("error converting value ["+values[0]+"] to Date ", e);
}
}
return null;
}
public String convertToString(Map context, Object o) {
if (o instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
return sdf.format((Date) o);
}
return "";
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -25,35 +28,35 @@ import com.opensymphony.xwork2.ActionSupport;
public class EnterRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map session;
private String roomName;
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) { this.roomName = roomName; }
public EnterRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
try {
chatService.enterRoom(user, roomName);
}
catch(Exception e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
private static final long serialVersionUID = 1L;
private ChatService chatService;
private Map session;
private String roomName;
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) { this.roomName = roomName; }
public EnterRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
try {
chatService.enterRoom(user, roomName);
}
catch(Exception e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -25,31 +28,31 @@ import com.opensymphony.xwork2.ActionSupport;
public class ExitRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private String roomName;
private Map session;
public String getRoomName() { return roomName; }
public void setRoomName(String roomName) { this.roomName = roomName; }
private ChatService chatService;
public ExitRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
chatService.exitRoom(user.getName(), roomName);
return SUCCESS;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
private String roomName;
private Map session;
public String getRoomName() { return roomName; }
public void setRoomName(String roomName) { this.roomName = roomName; }
private ChatService chatService;
public ExitRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
chatService.exitRoom(user.getName(), roomName);
return SUCCESS;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -24,33 +27,33 @@ import com.opensymphony.xwork2.ActionSupport;
public class MessagesAvailableInRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private String roomName;
private ChatService chatService;
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public List<ChatMessage> getMessagesAvailableInRoom() {
return messagesAvailableInRoom;
}
public MessagesAvailableInRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
try {
messagesAvailableInRoom = chatService.getMessagesInRoom(roomName);
}
catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
private String roomName;
private ChatService chatService;
private List<ChatMessage> messagesAvailableInRoom = new ArrayList<ChatMessage>();
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public List<ChatMessage> getMessagesAvailableInRoom() {
return messagesAvailableInRoom;
}
public MessagesAvailableInRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
try {
messagesAvailableInRoom = chatService.getMessagesInRoom(roomName);
}
catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -24,75 +27,75 @@ import java.util.List;
import java.util.Map;
public class Room {
private static final int MAX_CHAT_MESSAGES = 10;
private String name;
private String description;
private Date creationDate;
private List<ChatMessage> messages = new ArrayList<ChatMessage>();
private Map<String, User> members = new LinkedHashMap<String, User>();
public Room(String name, String description) {
this.name = name;
this.description = description;
this.creationDate = new Date(System.currentTimeMillis());
}
// properties
public Date getCreationDate() {
return creationDate;
}
public String getDescription() {
return description;
}
private static final int MAX_CHAT_MESSAGES = 10;
public String getName() {
return name;
}
// (behaviour) members
public List<User> getMembers() {
return new ArrayList<User>(members.values());
}
public User findMember(String name) {
assert(name != null);
return members.get(name);
}
public boolean hasMember(String name) {
assert(name != null);
return members.containsKey(name);
}
public void memberEnter(User member) {
assert(member != null);
if (! hasMember(member.getName())) {
members.put(member.getName(), member);
}
}
public void memberExit(String memberName) {
assert(memberName != null);
assert(memberName.trim().length() > 0);
members.remove(memberName);
}
private String name;
private String description;
private Date creationDate;
private List<ChatMessage> messages = new ArrayList<ChatMessage>();
private Map<String, User> members = new LinkedHashMap<String, User>();
public Room(String name, String description) {
this.name = name;
this.description = description;
this.creationDate = new Date(System.currentTimeMillis());
}
// properties
public Date getCreationDate() {
return creationDate;
}
public String getDescription() {
return description;
}
public String getName() {
return name;
}
// (behaviour) members
public List<User> getMembers() {
return new ArrayList<User>(members.values());
}
public User findMember(String name) {
assert(name != null);
return members.get(name);
}
public boolean hasMember(String name) {
assert(name != null);
return members.containsKey(name);
}
public void memberEnter(User member) {
assert(member != null);
if (! hasMember(member.getName())) {
members.put(member.getName(), member);
}
}
public void memberExit(String memberName) {
assert(memberName != null);
assert(memberName.trim().length() > 0);
members.remove(memberName);
}
// (behaviour) chat messags
public void addMessage(ChatMessage chatMessage) {
if (messages.size() > MAX_CHAT_MESSAGES) {
// messages.remove(messages.size() - 1);
messages.remove(0);
}
messages.add(chatMessage);
}
public List<ChatMessage> getChatMessages() {
return new ArrayList<ChatMessage>(messages);
}
// (behaviour) chat messags
public void addMessage(ChatMessage chatMessage) {
if (messages.size() > MAX_CHAT_MESSAGES) {
// messages.remove(messages.size() - 1);
messages.remove(0);
}
messages.add(chatMessage);
}
public List<ChatMessage> getChatMessages() {
return new ArrayList<ChatMessage>(messages);
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -24,22 +27,22 @@ import com.opensymphony.xwork2.ActionSupport;
public class RoomsAvailableAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
private List<Room> availableRooms = new ArrayList<Room>();
private ChatService chatService;
public RoomsAvailableAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
availableRooms = chatService.getAvailableRooms();
return SUCCESS;
}
public List<Room> getAvailableRooms() {
return availableRooms;
}
private List<Room> availableRooms = new ArrayList<Room>();
private ChatService chatService;
public RoomsAvailableAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
availableRooms = chatService.getAvailableRooms();
return SUCCESS;
}
public List<Room> getAvailableRooms() {
return availableRooms;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -25,43 +28,43 @@ import com.opensymphony.xwork2.ActionSupport;
public class SendMessageToRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private String roomName;
private String message;
private Map session;
public SendMessageToRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getMessage() { return this.message; }
public void setMessage(String message) {
this.message = message;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
try {
chatService.sendMessageToRoom(roomName, user, message);
}catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
private static final long serialVersionUID = 1L;
private ChatService chatService;
private String roomName;
private String message;
private Map session;
public SendMessageToRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public String getMessage() { return this.message; }
public void setMessage(String message) {
this.message = message;
}
public String execute() throws Exception {
User user = (User) session.get(ChatAuthenticationInterceptor.USER_SESSION_KEY);
try {
chatService.sendMessageToRoom(roomName, user, message);
}catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
public void setSession(Map session) {
this.session = session;
}
public void setSession(Map session) {
this.session = session;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -24,22 +27,22 @@ import java.util.Date;
* Represends a user in the Chat example.
*/
public class User implements Serializable {
private static final long serialVersionUID = -1434958919516089297L;
private String name;
private Date creationDate;
public User(String name) {
this.name = name;
this.creationDate = new Date(System.currentTimeMillis());
}
public Date getCreationDate() {
return creationDate;
}
public String getName() {
return name;
}
private static final long serialVersionUID = -1434958919516089297L;
private String name;
private Date creationDate;
public User(String name) {
this.name = name;
this.creationDate = new Date(System.currentTimeMillis());
}
public Date getCreationDate() {
return creationDate;
}
public String getName() {
return name;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -24,23 +27,23 @@ import com.opensymphony.xwork2.ActionSupport;
public class UsersAvailableAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private List<User> availableUsers = new ArrayList<User>();
private ChatService chatService;
public UsersAvailableAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
availableUsers = chatService.getAvailableUsers();
return SUCCESS;
}
public List<User> getAvailableUsers() {
return availableUsers;
}
private static final long serialVersionUID = 1L;
private List<User> availableUsers = new ArrayList<User>();
private ChatService chatService;
public UsersAvailableAction(ChatService chatService) {
this.chatService = chatService;
}
public String execute() throws Exception {
availableUsers = chatService.getAvailableUsers();
return SUCCESS;
}
public List<User> getAvailableUsers() {
return availableUsers;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.chat;
@@ -24,35 +27,35 @@ import com.opensymphony.xwork2.ActionSupport;
public class UsersAvailableInRoomAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private ChatService chatService;
private List<User> usersAvailableInRoom = new ArrayList<User>();
private String roomName;
public UsersAvailableInRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public List<User> getUsersAvailableInRoom() {
return usersAvailableInRoom;
}
public String execute() throws Exception {
try {
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
}
catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
private static final long serialVersionUID = 1L;
private ChatService chatService;
private List<User> usersAvailableInRoom = new ArrayList<User>();
private String roomName;
public UsersAvailableInRoomAction(ChatService chatService) {
this.chatService = chatService;
}
public String getRoomName() { return this.roomName; }
public void setRoomName(String roomName) {
this.roomName = roomName;
}
public List<User> getUsersAvailableInRoom() {
return usersAvailableInRoom;
}
public String execute() throws Exception {
try {
usersAvailableInRoom = chatService.getUsersAvailableInRoom(roomName);
}
catch(ChatException e) {
addActionError(e.getMessage());
}
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id: Person.java 440597 2006-09-06 03:34:39Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
@@ -22,14 +25,14 @@ package org.apache.struts2.showcase.conversion;
* @version $Date$ $Id$
*/
public class Address {
private String id;
private String address;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getAddress() { return address; }
public void setAddress(String address) { this.address = address; }
private String id;
private String address;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getAddress() { return address; }
public void setAddress(String address) { this.address = address; }
}
@@ -1,19 +1,22 @@
/*
* $Id: Person.java 440597 2006-09-06 03:34:39Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
@@ -27,18 +30,18 @@ import com.opensymphony.xwork2.ActionSupport;
*/
public class AddressAction extends ActionSupport {
private Set addresses = new LinkedHashSet();
public Set getAddresses() { return addresses; }
public void setAddresses(Set addresses) { this.addresses = addresses; }
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
System.out.println(addresses);
return SUCCESS;
}
private Set addresses = new LinkedHashSet();
public Set getAddresses() { return addresses; }
public void setAddresses(Set addresses) { this.addresses = addresses; }
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
System.out.println(addresses);
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id: Person.java 440597 2006-09-06 03:34:39Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
@@ -29,27 +32,27 @@ import org.apache.struts2.util.StrutsTypeConverter;
*/
public class EnumTypeConverter extends StrutsTypeConverter {
@Override
public Object convertFromString(Map context, String[] values, Class toClass) {
List<Enum> result = new ArrayList<Enum>();
for (int a=0; a< values.length; a++) {
Enum e = Enum.valueOf(OperationsEnum.class, values[a]);
if (e != null)
result.add(e);
}
return result;
}
@Override
public Object convertFromString(Map context, String[] values, Class toClass) {
List<Enum> result = new ArrayList<Enum>();
for (int a=0; a< values.length; a++) {
Enum e = Enum.valueOf(OperationsEnum.class, values[a]);
if (e != null)
result.add(e);
}
return result;
}
@Override
public String convertToString(Map context, Object o) {
List l = (List) o;
String result ="<";
for (Iterator i = l.iterator(); i.hasNext(); ) {
result = result + "["+ i.next() +"]";
}
result = result+">";
return result;
}
@Override
public String convertToString(Map context, Object o) {
List l = (List) o;
String result ="<";
for (Iterator i = l.iterator(); i.hasNext(); ) {
result = result + "["+ i.next() +"]";
}
result = result+">";
return result;
}
}
@@ -1,30 +1,33 @@
/*
* $Id: Person.java 440597 2006-09-06 03:34:39Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
/**
*
*
* @version $Date$ $Id$
*/
public enum OperationsEnum {
ADD,
MINUS,
DIVIDE,
MULTIPLY,
REMAINDER;
ADD,
MINUS,
DIVIDE,
MULTIPLY,
REMAINDER;
}
@@ -1,19 +1,22 @@
/*
* $Id: Person.java 440597 2006-09-06 03:34:39Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
@@ -24,30 +27,30 @@ import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
* @version $Date$ $Id$
*/
public class OperationsEnumAction extends ActionSupport {
private static final long serialVersionUID = -2229489704988870318L;
private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>();
public List<OperationsEnum> getSelectedOperations() { return this.selectedOperations; }
public void setSelectedOperations(List<OperationsEnum> selectedOperations) {
this.selectedOperations = selectedOperations;
}
public List<OperationsEnum> getAvailableOperations() {
return Arrays.asList(OperationsEnum.values());
}
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
private static final long serialVersionUID = -2229489704988870318L;
private List<OperationsEnum> selectedOperations = new LinkedList<OperationsEnum>();
public List<OperationsEnum> getSelectedOperations() { return this.selectedOperations; }
public void setSelectedOperations(List<OperationsEnum> selectedOperations) {
this.selectedOperations = selectedOperations;
}
public List<OperationsEnum> getAvailableOperations() {
return Arrays.asList(OperationsEnum.values());
}
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
@@ -23,12 +26,12 @@ import java.io.Serializable;
*
*/
public class Person implements Serializable {
private String name;
private Integer age;
public void setName(String name) { this.name = name; }
public String getName() { return this.name; }
public void setAge(Integer age) { this.age = age; }
public Integer getAge() { return this.age; }
private String name;
private Integer age;
public void setName(String name) { this.name = name; }
public String getName() { return this.name; }
public void setAge(Integer age) { this.age = age; }
public Integer getAge() { return this.age; }
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.conversion;
@@ -22,22 +25,22 @@ import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
/**
*
*
*/
public class PersonAction extends ActionSupport {
private List persons;
public List getPersons() { return persons; }
public void setPersons(List persons) { this.persons = persons; }
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
private List persons;
public List getPersons() { return persons; }
public void setPersons(List persons) { this.persons = persons; }
public String input() throws Exception {
return SUCCESS;
}
public String submit() throws Exception {
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.dao;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.dao;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.dao;
@@ -30,7 +33,7 @@ import java.util.ArrayList;
public class EmployeeDao extends AbstractDao {
private static final long serialVersionUID = -6615310540042830594L;
private static final long serialVersionUID = -6615310540042830594L;
protected SkillDao skillDao;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.dao;
@@ -26,7 +29,7 @@ import org.apache.struts2.showcase.model.Skill;
public class SkillDao extends AbstractDao {
private static final long serialVersionUID = -8160406514074630866L;
private static final long serialVersionUID = -8160406514074630866L;
public Class getFeaturedClass() {
return Skill.class;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.exception;
@@ -24,8 +27,8 @@ package org.apache.struts2.showcase.exception;
public class CreateException extends StorageException {
private static final long serialVersionUID = 6734349565111633783L;
private static final long serialVersionUID = 6734349565111633783L;
public CreateException(String message) {
super(message);
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.exception;
@@ -24,9 +27,9 @@ package org.apache.struts2.showcase.exception;
public class DeleteException extends StorageException {
private static final long serialVersionUID = -5286362812955627352L;
private static final long serialVersionUID = -5286362812955627352L;
public DeleteException(String message) {
public DeleteException(String message) {
super(message);
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.exception;
@@ -24,7 +27,7 @@ package org.apache.struts2.showcase.exception;
public class DuplicateKeyException extends CreateException {
private static final long serialVersionUID = 989620752592415898L;
private static final long serialVersionUID = 989620752592415898L;
public DuplicateKeyException(String message) {
super(message);
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.exception;
@@ -24,8 +27,8 @@ package org.apache.struts2.showcase.exception;
public class StorageException extends Exception {
private static final long serialVersionUID = -2528721270540362905L;
private static final long serialVersionUID = -2528721270540362905L;
public StorageException(String message) {
super(message);
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.exception;
@@ -25,8 +28,8 @@ package org.apache.struts2.showcase.exception;
public class UpdateException extends StorageException {
private static final long serialVersionUID = -4728238600375630452L;
private static final long serialVersionUID = -4728238600375630452L;
public UpdateException(String message) {
super(message);
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.filedownload;
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.fileupload;
@@ -27,23 +30,23 @@ import java.io.File;
*/
public class FileUploadAction extends ActionSupport {
private static final long serialVersionUID = 5156288255337069381L;
private String contentType;
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;
return fileName;
}
public void setUploadFileName(String fileName) {
this.fileName = 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() {
@@ -53,7 +56,7 @@ public class FileUploadAction extends ActionSupport {
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() {
@@ -63,7 +66,7 @@ public class FileUploadAction extends ActionSupport {
this.upload = upload;
}
public String getCaption() {
return caption;
}
@@ -1,19 +1,22 @@
/*
* $Id: FileUploadAction.java 432886 2006-08-19 22:03:04Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.fileupload;
@@ -23,7 +26,7 @@ import com.opensymphony.xwork2.ActionSupport;
/**
* Showcase action - mutiple file upload using array.
*
*
* @version $Date$ $Id$
*/
public class MultipleFileUploadUsingArrayAction extends ActionSupport {
@@ -31,17 +34,17 @@ public class MultipleFileUploadUsingArrayAction extends ActionSupport {
private File[] uploads;
private String[] uploadFileNames;
private String[] uploadContentTypes;
public File[] getUpload() { return this.uploads; }
public void setUpload(File[] upload) { this.uploads = upload; }
public String[] getUploadFileName() { return this.uploadFileNames; }
public void setUploadFileName(String[] uploadFileName) { this.uploadFileNames = uploadFileName; }
public String[] getUploadContentType() { return this.uploadContentTypes; }
public void setUploadContentType(String[] uploadContentType) { this.uploadContentTypes = uploadContentType; }
public String upload() throws Exception {
System.out.println("\n\n upload2");
System.out.println("files:");
@@ -59,5 +62,5 @@ public class MultipleFileUploadUsingArrayAction extends ActionSupport {
System.out.println("\n\n");
return SUCCESS;
}
}
@@ -1,25 +1,22 @@
package org.apache.struts2.showcase.fileupload;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
/*
* $Id: FileUploadAction.java 432886 2006-08-19 22:03:04Z tmjee $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* 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.
*/
import com.opensymphony.xwork2.ActionSupport;
@@ -32,34 +29,34 @@ public class MultipleFileUploadUsingListAction extends ActionSupport {
private List<File> uploads = new ArrayList<File>();
private List<String> uploadFileNames = new ArrayList<String>();
private List<String> uploadContentTypes = new ArrayList<String>();
public List<File> getUpload() {
return this.uploads;
}
public void setUpload(List<File> uploads) {
this.uploads = uploads;
}
public List<String> getUploadFileName() {
return this.uploadFileNames;
}
public void setUploadFileName(List<String> uploadFileNames) {
this.uploadFileNames = uploadFileNames;
}
public List<String> getUploadContentType() {
return this.uploadContentTypes;
}
public void setUploadContentType(List<String> contentTypes) {
this.uploadContentTypes = contentTypes;
}
public String upload() throws Exception {
System.out.println("\n\n upload1");
System.out.println("files:");
for (File u: uploads) {
@@ -76,6 +73,6 @@ public class MultipleFileUploadUsingListAction extends ActionSupport {
System.out.println("\n\n");
return SUCCESS;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.freemarker;
@@ -26,29 +29,29 @@ import org.apache.struts2.views.freemarker.ScopesHashModel;
import com.opensymphony.xwork2.util.OgnlValueStack;
/**
* This is an example of a custom FreemarkerManager, mean to be
* instantiated through Spring.
* This is an example of a custom FreemarkerManager, mean to be
* instantiated through Spring.
* <p/>
*
*
* It will add into Freemarker's model
* an utility class called {@link CustomFreemarkerManagerUtil} as a simple
* an utility class called {@link CustomFreemarkerManagerUtil} as a simple
* example demonstrating how to extends FreemarkerManager.
* <p/>
*
* The {@link CustomFreemarkerManagerUtil} will be created by Spring and
*
* The {@link CustomFreemarkerManagerUtil} will be created by Spring and
* injected through constructor injection.
* <p/>
*/
public class CustomFreemarkerManager extends FreemarkerManager {
private CustomFreemarkerManagerUtil util;
public CustomFreemarkerManager(CustomFreemarkerManagerUtil util) {
this.util = util;
}
public void populateContext(ScopesHashModel model, OgnlValueStack stack, Object action, HttpServletRequest request, HttpServletResponse response) {
super.populateContext(model, stack, action, request, response);
model.put("customFreemarkerManagerUtil", util);
}
private CustomFreemarkerManagerUtil util;
public CustomFreemarkerManager(CustomFreemarkerManagerUtil util) {
this.util = util;
}
public void populateContext(ScopesHashModel model, OgnlValueStack stack, Object action, HttpServletRequest request, HttpServletResponse response) {
super.populateContext(model, stack, action, request, response);
model.put("customFreemarkerManagerUtil", util);
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.freemarker;
@@ -21,19 +24,19 @@ import java.text.SimpleDateFormat;
import java.util.Date;
/**
* This class is just a simple util that gets injected into
* This class is just a simple util that gets injected into
* {@link CustomFreemarkerManager} through Spring's constructor
* injection, serving as a simple example in Struts' Showcase.
* injection, serving as a simple example in Struts' Showcase.
*/
public class CustomFreemarkerManagerUtil {
public String getTodayDate() {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
return sdf.format(new Date());
}
public String getTimeNow() {
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
return sdf.format(new Date());
}
public String getTodayDate() {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
return sdf.format(new Date());
}
public String getTimeNow() {
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
return sdf.format(new Date());
}
}
@@ -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.showcase.hangman;
import java.util.Map;
@@ -7,33 +27,33 @@ import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
public class GetUpdatedHangmanAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 5506025785406043027L;
private Map session;
private Hangman hangman;
public String execute() throws Exception {
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
System.out.println("\n\n\n");
System.out.println("hangman="+hangman);
System.out.println("available = "+hangman.getCharactersAvailable().size());
System.out.println("guess left="+hangman.guessLeft());
System.out.println("\n\n\n");
return SUCCESS;
}
public void setSession(Map session) {
this.session = session;
}
public Hangman getHangman() {
return hangman;
}
public void setHangman(Hangman hangman) {
this.hangman = hangman;
}
private static final long serialVersionUID = 5506025785406043027L;
private Map session;
private Hangman hangman;
public String execute() throws Exception {
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
System.out.println("\n\n\n");
System.out.println("hangman="+hangman);
System.out.println("available = "+hangman.getCharactersAvailable().size());
System.out.println("guess left="+hangman.guessLeft());
System.out.println("\n\n\n");
return SUCCESS;
}
public void setSession(Map session) {
this.session = session;
}
public Hangman getHangman() {
return hangman;
}
public void setHangman(Hangman hangman) {
this.hangman = hangman;
}
}
@@ -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.showcase.hangman;
import java.util.Map;
@@ -7,33 +27,33 @@ import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
public class GuessCharacterAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 9050915577007590674L;
private Map session;
private Character character;
private Hangman hangman;
public String execute() throws Exception {
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
hangman.guess(character);
return SUCCESS;
}
public Hangman getHangman() {
return hangman;
}
public void setSession(Map session) {
this.session = session;
}
public void setCharacter(Character character) {
this.character = character;
}
public Character getCharacter() {
return this.character;
}
private static final long serialVersionUID = 9050915577007590674L;
private Map session;
private Character character;
private Hangman hangman;
public String execute() throws Exception {
hangman = (Hangman) session.get(HangmanConstants.HANGMAN_SESSION_KEY);
hangman.guess(character);
return SUCCESS;
}
public Hangman getHangman() {
return hangman;
}
public void setSession(Map session) {
this.session = session;
}
public void setCharacter(Character character) {
this.character = character;
}
public Character getCharacter() {
return this.character;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
@@ -23,84 +26,84 @@ import java.util.Arrays;
import java.util.List;
public class Hangman implements Serializable {
private static final long serialVersionUID = 8566954355839652509L;
private Vocab vocab;
private Boolean win = false;
private int guessLeft = 5;
public List<Character> charactersAvailable;
public List<Character> charactersGuessed;
public Hangman(Vocab vocab) {
// Arrays.asList(...) returns List that doesn't support remove(), hence
// we wrap it with an ArrayList to avoid UnsupportedOperationException
// when doing a remove()
charactersAvailable = new ArrayList<Character>(Arrays.asList(
new Character[] {
Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'),
Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'),
Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'),
Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'),
Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'),
Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'),
Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'),
Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'),
Character.valueOf('Y'), Character.valueOf('Z')
}));
charactersGuessed = new ArrayList<Character>();
this.vocab = vocab;
}
public void guess(Character character) {
assert(character != null);
synchronized(charactersAvailable) {
if (guessLeft < 0) {
throw new HangmanException(
HangmanException.Type.valueOf("GAME_ENDED"), "Game already eneded");
}
Character characterInUpperCase = Character.toUpperCase(character);
boolean ok = charactersAvailable.remove(characterInUpperCase);
if (ok) {
charactersGuessed.add(characterInUpperCase);
if (! vocab.containCharacter(characterInUpperCase)) {
guessLeft = guessLeft - 1;
}
}
if (vocab.containsAllCharacter(charactersGuessed)) {
win = true;
}
System.out.println(" *********************************** "+win);
}
}
public Boolean isWin() {
return this.win;
}
public Vocab getVocab() {
return vocab;
}
public Boolean gameEnded() {
return ((guessLeft < 0) || win);
}
public Integer guessLeft() {
return guessLeft;
}
public List<Character> getCharactersAvailable() {
synchronized(charactersAvailable) {
return new ArrayList<Character>(charactersAvailable);
//return charactersAvailable;
}
}
public boolean characterGuessedBefore(Character character) {
return charactersGuessed.contains(character);
}
private static final long serialVersionUID = 8566954355839652509L;
private Vocab vocab;
private Boolean win = false;
private int guessLeft = 5;
public List<Character> charactersAvailable;
public List<Character> charactersGuessed;
public Hangman(Vocab vocab) {
// Arrays.asList(...) returns List that doesn't support remove(), hence
// we wrap it with an ArrayList to avoid UnsupportedOperationException
// when doing a remove()
charactersAvailable = new ArrayList<Character>(Arrays.asList(
new Character[] {
Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'),
Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'),
Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'),
Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'),
Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'),
Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'),
Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'),
Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'),
Character.valueOf('Y'), Character.valueOf('Z')
}));
charactersGuessed = new ArrayList<Character>();
this.vocab = vocab;
}
public void guess(Character character) {
assert(character != null);
synchronized(charactersAvailable) {
if (guessLeft < 0) {
throw new HangmanException(
HangmanException.Type.valueOf("GAME_ENDED"), "Game already eneded");
}
Character characterInUpperCase = Character.toUpperCase(character);
boolean ok = charactersAvailable.remove(characterInUpperCase);
if (ok) {
charactersGuessed.add(characterInUpperCase);
if (! vocab.containCharacter(characterInUpperCase)) {
guessLeft = guessLeft - 1;
}
}
if (vocab.containsAllCharacter(charactersGuessed)) {
win = true;
}
System.out.println(" *********************************** "+win);
}
}
public Boolean isWin() {
return this.win;
}
public Vocab getVocab() {
return vocab;
}
public Boolean gameEnded() {
return ((guessLeft < 0) || win);
}
public Integer guessLeft() {
return guessLeft;
}
public List<Character> getCharactersAvailable() {
synchronized(charactersAvailable) {
return new ArrayList<Character>(charactersAvailable);
//return charactersAvailable;
}
}
public boolean characterGuessedBefore(Character character) {
return charactersGuessed.contains(character);
}
}
@@ -1,6 +1,26 @@
/*
* $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.showcase.hangman;
public class HangmanConstants {
// keeps a Hangman object in HttpSession
public static final String HANGMAN_SESSION_KEY = "Hangman_Session_Key";
// keeps a Hangman object in HttpSession
public static final String HANGMAN_SESSION_KEY = "Hangman_Session_Key";
}
@@ -1,41 +1,44 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
public class HangmanException extends RuntimeException {
private static final long serialVersionUID = -8500292863595941335L;
enum Type {
GAME_ENDED,
NO_VOCAB,
NO_VOCAB_SOURCE;
}
private Type type;
public HangmanException (Type type, String reason) {
super(reason);
this.type = type;
}
public Type getType() {
return type;
}
private static final long serialVersionUID = -8500292863595941335L;
enum Type {
GAME_ENDED,
NO_VOCAB,
NO_VOCAB_SOURCE;
}
private Type type;
public HangmanException (Type type, String reason) {
super(reason);
this.type = type;
}
public Type getType() {
return type;
}
}
@@ -1,31 +1,34 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
public class HangmanService {
public VocabSource vocabSource;
public HangmanService(VocabSource vocabSource) {
this.vocabSource = vocabSource;
}
public Hangman startNewGame() {
return new Hangman(vocabSource.getRandomVocab());
}
public VocabSource vocabSource;
public HangmanService(VocabSource vocabSource) {
this.vocabSource = vocabSource;
}
public Hangman startNewGame() {
return new Hangman(vocabSource.getRandomVocab());
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
@@ -24,45 +27,45 @@ import java.util.Properties;
public class PropertiesVocabSource implements VocabSource {
private Properties prop;
private List<Vocab> vocabs;
public PropertiesVocabSource() {
}
public PropertiesVocabSource(Properties prop) {
assert(prop != null);
this.prop = prop;
vocabs = readVocab(prop);
}
public void setVocabProperties(Properties prop) {
assert(prop != null);
this.prop = prop;
vocabs = readVocab(prop);
}
public Vocab getRandomVocab() {
if (vocabs == null) {
throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB_SOURCE"), "No vocab source");
}
if (vocabs.size() <= 0) {
throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB"), "No vocab");
}
long vocabIndex = Math.round((Math.random() * (double)prop.size()));
vocabIndex = vocabIndex == vocabs.size() ? vocabs.size() - 1 : vocabIndex;
return vocabs.get((int)vocabIndex);
}
protected List<Vocab> readVocab(Properties prop) {
List<Vocab> vocabList = new ArrayList<Vocab>();
for (Map.Entry e : prop.entrySet()) {
String vocab = (String) e.getKey();
String hint = (String) e.getValue();
vocabList.add(new Vocab(vocab, hint));
}
return vocabList;
}
private Properties prop;
private List<Vocab> vocabs;
public PropertiesVocabSource() {
}
public PropertiesVocabSource(Properties prop) {
assert(prop != null);
this.prop = prop;
vocabs = readVocab(prop);
}
public void setVocabProperties(Properties prop) {
assert(prop != null);
this.prop = prop;
vocabs = readVocab(prop);
}
public Vocab getRandomVocab() {
if (vocabs == null) {
throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB_SOURCE"), "No vocab source");
}
if (vocabs.size() <= 0) {
throw new HangmanException(HangmanException.Type.valueOf("NO_VOCAB"), "No vocab");
}
long vocabIndex = Math.round((Math.random() * (double)prop.size()));
vocabIndex = vocabIndex == vocabs.size() ? vocabs.size() - 1 : vocabIndex;
return vocabs.get((int)vocabIndex);
}
protected List<Vocab> readVocab(Properties prop) {
List<Vocab> vocabList = new ArrayList<Vocab>();
for (Map.Entry e : prop.entrySet()) {
String vocab = (String) e.getKey();
String hint = (String) e.getValue();
vocabList.add(new Vocab(vocab, hint));
}
return vocabList;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
@@ -26,33 +29,33 @@ import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
public class StartHangmanAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 2333463075324892521L;
private HangmanService service;
private Hangman hangman;
private Map session;
public StartHangmanAction(HangmanService service) {
this.service = service;
}
public String execute() throws Exception {
hangman = service.startNewGame();
session.put(HANGMAN_SESSION_KEY, hangman);
return SUCCESS;
}
public Hangman getHangman() {
return hangman;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
private static final long serialVersionUID = 2333463075324892521L;
private HangmanService service;
private Hangman hangman;
private Map session;
public StartHangmanAction(HangmanService service) {
this.service = service;
}
public String execute() throws Exception {
hangman = service.startNewGame();
session.put(HANGMAN_SESSION_KEY, hangman);
return SUCCESS;
}
public Hangman getHangman() {
return hangman;
}
// === SessionAware ===
public void setSession(Map session) {
this.session = session;
}
}
@@ -1,19 +1,22 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
@@ -23,61 +26,61 @@ import java.util.Arrays;
import java.util.List;
public class Vocab implements Serializable {
private static final long serialVersionUID = 1L;
private String vocab;
private String hint;
private Character[] characters; // character this vocab is made up of
public Vocab(String vocab, String hint) {
assert(vocab != null);
assert(hint != null);
this.vocab = vocab.toUpperCase();
this.hint = hint;
}
public String getVocab() { return this.vocab; }
public String getHint() { return this.hint; }
public Boolean containCharacter(Character character) {
assert(character != null);
return (vocab.contains(character.toString())) ? true : false;
}
public Character[] inCharacters() {
if (characters == null) {
char[] c = vocab.toCharArray();
characters = new Character[c.length];
for (int a=0; a< c.length; a++) {
characters[a] = Character.valueOf(c[a]);
}
}
return characters;
}
public boolean containsAllCharacter(List<Character> charactersGuessed) {
Character[] chars = inCharacters();
List<Character> tmpChars = Arrays.asList(chars);
return charactersGuessed.containsAll(tmpChars);
}
public static void main(String args[]) throws Exception {
Vocab v = new Vocab("JAVA", "a java word");
List<Character> list1= new ArrayList<Character>();
list1.add(new Character('J'));
list1.add(new Character('V'));
List<Character> list2 = new ArrayList<Character>();
list2.add(new Character('J'));
list2.add(new Character('V'));
list2.add(new Character('A'));
System.out.println(v.containsAllCharacter(list1));
System.out.println(v.containsAllCharacter(list2));
}
private static final long serialVersionUID = 1L;
private String vocab;
private String hint;
private Character[] characters; // character this vocab is made up of
public Vocab(String vocab, String hint) {
assert(vocab != null);
assert(hint != null);
this.vocab = vocab.toUpperCase();
this.hint = hint;
}
public String getVocab() { return this.vocab; }
public String getHint() { return this.hint; }
public Boolean containCharacter(Character character) {
assert(character != null);
return (vocab.contains(character.toString())) ? true : false;
}
public Character[] inCharacters() {
if (characters == null) {
char[] c = vocab.toCharArray();
characters = new Character[c.length];
for (int a=0; a< c.length; a++) {
characters[a] = Character.valueOf(c[a]);
}
}
return characters;
}
public boolean containsAllCharacter(List<Character> charactersGuessed) {
Character[] chars = inCharacters();
List<Character> tmpChars = Arrays.asList(chars);
return charactersGuessed.containsAll(tmpChars);
}
public static void main(String args[]) throws Exception {
Vocab v = new Vocab("JAVA", "a java word");
List<Character> list1= new ArrayList<Character>();
list1.add(new Character('J'));
list1.add(new Character('V'));
List<Character> list2 = new ArrayList<Character>();
list2.add(new Character('J'));
list2.add(new Character('V'));
list2.add(new Character('A'));
System.out.println(v.containsAllCharacter(list1));
System.out.println(v.containsAllCharacter(list2));
}
}
@@ -1,22 +1,25 @@
/*
* $Id$
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.hangman;
public interface VocabSource {
Vocab getRandomVocab();
Vocab getRandomVocab();
}
@@ -1,19 +1,22 @@
/*
* $Id: Gangster.java 418530 2006-07-01 23:58:13Z mrdon $
* $Id: $
*
* Copyright 2006 The Apache Software Foundation.
* 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
*
* 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
*
* 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.
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.struts2.showcase.integration;
@@ -33,9 +36,9 @@ public class EditGangsterAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
// Some code to load the gangster from the db as necessary
return mapping.findForward("success");
}
}

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