svn commit: r416935 - in /struts/action2/trunk/apps/showcase/src/main: java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java webapp/WEB-INF/web.xml

2006-06-24 Thread tmjee
Author: tmjee
Date: Sat Jun 24 09:36:59 2006
New Revision: 416935

URL: http://svn.apache.org/viewvc?rev=416935&view=rev
Log:
WW-1351
  - added a SessionListener for Chat showcase example to do clean up
when session expires


Added:

struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
   (with props)
Modified:
struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml

Added: 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
URL: 
http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java?rev=416935&view=auto
==
--- 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
 (added)
+++ 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
 Sat Jun 24 09:36:59 2006
@@ -0,0 +1,31 @@
+package org.apache.struts.action2.showcase.chat;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.web.context.WebApplicationContext;
+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) {
+   }
+
+   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);
+   ChatService service = (ChatService) 
context.getBean("chatService");
+   service.logout(user.getName());
+   
+   _log.info("session expired, logged user 
["+user.getName()+"] out");
+   }
+   }
+
+}

Propchange: 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
--
svn:eol-style = native

Modified: struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml?rev=416935&r1=416934&r2=416935&view=diff
==
--- struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml 
(original)
+++ struts/action2/trunk/apps/showcase/src/main/webapp/WEB-INF/web.xml Sat Jun 
24 09:36:59 2006
@@ -2,7 +2,7 @@
 http://java.sun.com/dtd/web-app_2_3.dtd";>
 
 
-WebWork Showcase Application
+SAF2 Showcase Application
 

 
@@ -46,6 +46,13 @@
 
   org.apache.myfaces.webapp.StartupServletContextListener
 
+
+
+
+
+   
+ org.apache.struts.action2.showcase.chat.ChatSessionListener
+   
 

 




svn commit: r416936 - /struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java

2006-06-24 Thread tmjee
Author: tmjee
Date: Sat Jun 24 09:40:30 2006
New Revision: 416936

URL: http://svn.apache.org/viewvc?rev=416936&view=rev
Log:
WW-1351
  - added apache license on top of code


Modified:

struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java

Modified: 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
URL: 
http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java?rev=416936&r1=416935&r2=416936&view=diff
==
--- 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
 (original)
+++ 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
 Sat Jun 24 09:40:30 2006
@@ -1,3 +1,20 @@
+/*
+ * $Id: DateAction.java 394498 2006-04-16 15:28:06Z tmjee $
+ *
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.struts.action2.showcase.chat;
 
 import javax.servlet.http.HttpSession;




svn commit: r416943 - /struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/User.java

2006-06-24 Thread tmjee
Author: tmjee
Date: Sat Jun 24 11:26:58 2006
New Revision: 416943

URL: http://svn.apache.org/viewvc?rev=416943&view=rev
Log:
WW-1351
  - make User object serializable cause it is saved in session


Modified:

struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/User.java

Modified: 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/User.java
URL: 
http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/User.java?rev=416943&r1=416942&r2=416943&view=diff
==
--- 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/User.java
 (original)
+++ 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/User.java
 Sat Jun 24 11:26:58 2006
@@ -17,12 +17,16 @@
  */
 package org.apache.struts.action2.showcase.chat;
 
+import java.io.Serializable;
 import java.util.Date;
 
 /**
  * Represends a user in the Chat example.
  */
-public class User {
+public class User implements Serializable  {
+   
+   private static final long serialVersionUID = -1434958919516089297L;
+   
private String name;
private Date creationDate;





[Struts Wiki] Update of "StrutsManualActionWebComponent" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionWebComponent

--
  
  '''Attention: this page describes functionality that is not yet available! 
Work in progress!'''
  
- Struts 1.4 allows building portlet-like web components using JSP as view 
technology. ''Struts web component'' is an independent server-side object that 
accepts user input via Action class, and renders itself via JSP file. In a 
sense, Struts web component is a portlet.
+ Struts 1.4 allows building portlet-like web components. A web component is an 
independent server-side object that is able to accept user input and to render 
itself. ''Struts web component'' uses Action class to process incoming events, 
and employs JSP technology to render a view.
  
  A Struts Web Component is a combination of:
   * one Action class that handles input events and updates component state;
+  * one or more JSP files that represent one or more subviews;
-  * an optional form bean that holds input/output data;
+  * an optional form bean that holds input/output data.
-  * one or more views that can be represented with one or more JSP files.
- 
- Struts approach to web components has the following features:
- 
-* Allows composing a page out of one or more independent components.
-* Renders a view that is always synchronized with application state.
-* Solves major issues related to stale pages and double submits.
-* Delivers input directly to a component, no central controller is needed
-* Ensures that every component renders itself independently.
-* Updates page incrementally without full page refresh if browser has 
Javascript turned on and XMLHTTPRequest is available.
-* Seamlessly integrates with Struts, enhancing a well-known action 
framework with component technology.
  
  == Use Case: Home Page With Login Component ==
  
+ Consider a website that has a login form located in a highly visible part of 
the website. The login form allows a user to log in and thus to gain access to 
protected area of the website. A non-logged-in user must be presented with 
login form, a logged-in user should be able to log out. The screenshot from 
www.java.net website illustrates this use case.
- Consider the following use case: a website has a home page that should have 
different content for regular visitors one one hand, and for logged in users 
for another hand. The page contains login/logout form. A non-logged-in user 
must be presented with login, while a logged-in user should be able to log out.
- 
- The picture below illustrates this use case. Of course, since it is just an 
example, the login component is almost as large as the composite page itself, 
but the idea is the same: to design a component that does not have to know the 
location of a composite page it is included into.
  
  inline:login-component-sm.gif
  


[Struts Wiki] Update of "StrutsManualActionWebComponent" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionWebComponent

--
  
  == Use Case: Home Page With Login Component ==
  
- Consider a website that has a login form located in a highly visible part of 
the website. The login form allows a user to log in and thus to gain access to 
protected area of the website. A non-logged-in user must be presented with 
login form, a logged-in user should be able to log out. The screenshot from 
www.java.net website illustrates this use case.
+ Consider a website with a login form that authorizes access to member-only 
area of the website. A non-logged-in user must be presented with login form, a 
logged-in user should be able to log out. The screenshot from www.java.net 
website illustrates this use case.
  
- inline:login-component-sm.gif
+ A casual visitor sees a login form:
+ 
+ inline:javanet_notloggedin.gif
+ 
+ After a visitor logs in, he is presented with exactly the same page. The only 
difference is that login form is replaced with logout form:
+ 
+ inline:javanet_loggedin.gif
+ 
+ In a regular web application it is responsibility of login/logout module to 
navigate to a proper location after processing user input. In the above case a 
user must be transferred to the same location that he was browsing before 
logging in. Therefore login/logout module should be tightly integrated with its 
parent page. Another solution is that a parent page itself must process 
login/logout events.
+ 
+ == Struts Web Components Are Independent ==
+ 
+ With Struts you can build web component that bears no knowledge about page it 
is included into. Furthermore, a composite page itself does not need to know 
what components does it contain. A web component must handle its own input and 
render its own markup. Struts takes care about everything else. This boring 
tasks include:
+ 
+  * Calculating the location of a composite page, used to reload a composite 
page.
+  * Calculating the location of a component, can be used as submit target.
+  * Save page/component locations between requests.
+  * Checking whether a browser supports Javascript and if it does, using Ajax 
to replace component markup in place instead of reloading a whole composite 
page.
+ 
+ When you develop a Struts Web Component you have to deal only with 
component's input and component's output. You do not need to care how exactly 
the composite page will be updated.
  
  == Building Struts Web Components ==
  


[Struts Wiki] Update of "StrutsManualActionWebComponent" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionWebComponent

--
  
  '''Attention: this page describes functionality that is not yet available! 
Work in progress!'''
  
- Struts 1.4 allows building portlet-like web components. A web component is an 
independent server-side object that is able to accept user input and to render 
itself. ''Struts web component'' uses Action class to process incoming events, 
and employs JSP technology to render a view.
+ Struts 1.4 allows building portlet-like web components. A web component is an 
independent server-side object that is able to accept user input and to render 
itself.
  
- A Struts Web Component is a combination of:
+ A ''Struts Web Component'' is a combination of:
   * one Action class that handles input events and updates component state;
-  * one or more JSP files that represent one or more subviews;
+  * one or more JSP files that represent one or more component subviews;
   * an optional form bean that holds input/output data.
  
- == Use Case: Home Page With Login Component ==
+ Struts web component uses Action class to process incoming events, and 
employs JSP technology to render a view.
  
- Consider a website with a login form that authorizes access to member-only 
area of the website. A non-logged-in user must be presented with login form, a 
logged-in user should be able to log out. The screenshot from www.java.net 
website illustrates this use case.
+ == Use Case: Login Component ==
+ 
+ Consider a website's ''composite page'' that contains a login component. The 
login component authorizes access to member-only area of the website. A 
non-logged-in user must be presented with login form, a logged-in user should 
be able to log out. The screenshot from http://www.java.net website illustrates 
this use case.
  
  A casual visitor sees a login form:
  
  inline:javanet_notloggedin.gif
  
- After a visitor logs in, he is presented with exactly the same page. The only 
difference is that login form is replaced with logout form:
+ After a visitor logs in, he is presented with exactly the same page, the only 
difference is the login form replaced with logout form:
  
  inline:javanet_loggedin.gif
  
- In a regular web application it is responsibility of login/logout module to 
navigate to a proper location after processing user input. In the above case a 
user must be transferred to the same location that he was browsing before 
logging in. Therefore login/logout module should be tightly integrated with its 
parent page. Another solution is that a parent page itself must process 
login/logout events.
+ In a regular web application the login/logout module would be responsible to 
navigate to a proper location after processing user input. In the example above 
a user must be transferred to the same location that he was browsing before 
logging in. Therefore login/logout module should be tightly integrated with its 
parent page, or the parent page must process login/logout events itself.
  
  == Struts Web Components Are Independent ==
  
- With Struts you can build web component that bears no knowledge about page it 
is included into. Furthermore, a composite page itself does not need to know 
what components does it contain. A web component must handle its own input and 
render its own markup. Struts takes care about everything else. This boring 
tasks include:
+ With Struts you can build truly independent web components that bear no 
knowledge about a page they are included into. Furthermore, a composite page 
does not need to know about components contained in it. A web component should 
mean its own business, that is handle its input and render its markup. Struts 
takes care about the rest. These boring tasks include:
  
-  * Calculating the location of a composite page, used to reload a composite 
page.
+  * Calculating the location of a composite page (used to automatically reload 
a composite page).
-  * Calculating the location of a component, can be used as submit target.
+  * Calculating the location of a component (can be used as submission target).
   * Save page/component locations between requests.
   * Checking whether a browser supports Javascript and if it does, using Ajax 
to replace component markup in place instead of reloading a whole composite 
page.
- 
- When you develop a Struts Web Component you have to deal only with 
component's input and component's output. You do not need to care how exactly 
the composite page will be updated.
  
  == Building Struts Web Components ==
  


[Struts Wiki] Update of "StrutsManualActionWebComponent" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionWebComponent

--
   * one or more JSP files that represent one or more component subviews;
   * an optional form bean that holds input/output data.
  
- Struts web component uses Action class to process incoming events, and 
employs JSP technology to render a view.
+ Struts web component uses Action class to process incoming events, and 
employs JSP technology to render a view. The lifecycle of the components is 
fully managed by Struts. The components can be used in any application that 
employs JSP as rendering technology, not just in Struts-based application.
+ 
+ == Dual-Mode Capability ==
+ 
+ Struts utilizes two request processing concepts when dealing with web 
components:
+ 
+  * Traditional synchronous HTTP request/response cycle (Non-Ajax mode), and
+  * Asynchronous in-place update for Javascript-enabled browsers with 
XMLHTTPRequest support (Ajax mode).
+ 
+ In synchronous mode the browser submits input data to a fragment, the 
fragment updates its state if necessary, then the composite page is 
automatically  reloaded by redirecting browser to the original page location. A 
request that follows pulls up web components and they render themselves.
+ 
+ In Ajax mode browser submits input data using an asynchronous request. Struts 
renders a view directly in response to this request, no page reloading is 
needed. HTML markup, returned by a component, is inserted into the composite 
page without full page refresh.
+ 
+ Pages composed from Struts components look and behave uniformly whether they 
run in Ajax mode or not. The dual-mode functionality of Struts web components 
is invaluable for environments where !JavaScript is not allowed or in browsers 
that do not support the {{{XMLHTTPRequest}}} object, like some mobile browsers.
  
  == Use Case: Login Component ==
  
@@ -27, +40 @@

  
  inline:javanet_loggedin.gif
  
- In a regular web application the login/logout module would be responsible to 
navigate to a proper location after processing user input. In the example above 
a user must be transferred to the same location that he was browsing before 
logging in. Therefore login/logout module should be tightly integrated with its 
parent page, or the parent page must process login/logout events itself.
+ In a regular web application the login/logout module would be responsible for 
navigation to a proper location after processing user input. In the example 
above a user must be transferred to the same location that he was browsing 
before logging in. Therefore login/logout module should be tightly integrated 
with its parent page, or the parent page must process login/logout events 
itself.
  
- == Struts Web Components Are Independent ==
- 
- With Struts you can build truly independent web components that bear no 
knowledge about a page they are included into. Furthermore, a composite page 
does not need to know about components contained in it. A web component should 
mean its own business, that is handle its input and render its markup. Struts 
takes care about the rest. These boring tasks include:
+ With Struts you can build truly independent web components that bear no 
knowledge about a page they are included into. Furthermore, a composite page 
does not need to know about components contained in it. A web component should 
mean its own business, that is, handling its input and rendering its markup. 
Struts takes care about the rest. These boring tasks include:
  
   * Calculating the location of a composite page (used to automatically reload 
a composite page).
   * Calculating the location of a component (can be used as submission target).
   * Save page/component locations between requests.
   * Checking whether a browser supports Javascript and if it does, using Ajax 
to replace component markup in place instead of reloading a whole composite 
page.
  
- == Building Struts Web Components ==
+ == Building A Simple Struts Web Component ==
  
- See the links below for further reading:
+ This guide explains Struts component functionality by building a simple login 
component. The Login Component has two states: "Logged In" and "Not Logged In", 
two corresponding views: "loggedin" and "notloggedin", and two input events: 
"login" and "logout".
  
-  * [:StrutsManualActionWebComponentSync:Building synchronous Struts web 
component]
-  * [:StrutsManualActionWebComponentAsync:Building dual-mode Struts web 
component]
+ If a user has not logged in yet, the Login Component stays at "Not Logged In" 
state. The "notloggedin" view displays login form with "username" and 
"password" fields and "Log In" button. The button submits login form, sending 
"login" event to the component.
+   
+ When a user logs in,

[Struts Wiki] Update of "StrutsManualActionWebComponentSync" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionWebComponentSync

--
  
 1. The cycle begins with the initial load of a composite page, starting 
the render phase.
 2. When the JSP processor encounters a  action in a composite 
page, it generates an HTTP request to obtain the content of the included 
component.
-3. The Action class forwards to a view relevant to component state. After 
all components on the composite page have rendered themselves, the render phase 
finishes and a composite page is presented to a user.
+3. The Action class that manages the component receives an "empty" GET 
request. The Action class forwards to a view relevant to component state. After 
all components on the composite page have rendered themselves, the render phase 
finishes and the composite page is presented to a user.
-4. The user initiates the input phase by submitting an HTML form or by 
activating a command link. The browser sends input data to an Action that 
manages component events and state. The Action processes data and updates 
component state if needed. Component state can be stored in a session-scoped 
form bean, in a database or in other location.
+4. The user initiates the input phase by submitting an HTML form or by 
activating a command link. The browser sends input data to an Action that 
manages the component. The Action processes data and updates component state if 
needed. Component state can be stored in a session-scoped form bean, in a 
database or in other location.
 5. After input data has been processed, the Action automatically redirects 
to location of the composite page, effectively switching from input phase back 
to render phase. Steps 1 through 3 are repeated, and an updated page is 
presented to the user.
  
  inline:action_component_title.gif
  
  == Component Configuration ==
  
- Defining configuration before creating a component seems backwards, but 
different configuration options affect component itself, so for the sake of 
this example let us first define the parameters composite page and the login 
component in {{{struts-config.xml}}} file. Do not forget to turn automatic 
validation off, otherwise an event handler will not be called if associated 
form bean failed validation. In Struts 1.4 event definitions are first-class 
elements of an action mapping:
+ Defining configuration before creating a component seems backwards, but 
different configuration options affect the component, so for the sake of this 
example let us first define the composite page and the login component in the 
{{{struts-config.xml}}} file. Do not forget to turn automatic validation off, 
otherwise if an associated form bean fails validation, an event handler in the 
Action will not be called.
+ 
+ In Struts 1.4 event definitions are first-class elements of an action mapping:
  
  {{{
  
@@ -45, +47 @@

  
  }}}
  
- Observe attributes and properties that are new for Struts 1.4:
+ Observe attributes and properties new for Struts 1.4:
  
-* "component" attribute contains the name of a component. It identifies an 
action as a component manager, it is processed differently than a regular 
action or behavioral action.
+* "component" attribute contains the name of a component. It identifies an 
action as a component manager. Such actions are handled differently than a 
regular action or a simple dispatch action.
-* "view" attribute identifies a default view for a component. Must be a 
JSP page. Often consists from several subviews, in our case the Login Component 
has two subviews "Not Logged In" and "Logged In", they will be defined in JSP 
file.
+* "view" attribute identifies a default view for a component. Must be a 
JSP page. Often consists from several subviews, in our case the Login Component 
has two subviews "notloggedin" and "loggedin".
 * "form" is just another name for "name" property
-* "event" property allows to define request parameters as events, and 
corresponding method handlers.
+* "event" property allows to define incoming events and corresponding 
method handlers. An event is just a request parameter.
  
- In Struts 1.2.9 - 1.3.x Action class does not implement dispatching 
functionality, and action mapping does not allow to define events. It is 
recommended to use EventDispatchAction to handle incoming events, its events 
are configured through {{{parameter}}} attribute:
+ In Struts 1.2.9 - 1.3.x Action class does not implement dispatching 
functionality, and action mapping does not allow to define events. 
!EventDispatchAction class is the best choice to handle component events. The 
events are configured through {{{parameter}}} attribute:
  
  '''Struts 1.2.9, 1.3.x:'''
  {{{
@@ -82, +84 @@

  
 

[Struts Wiki] Update of "StrutsManualActionWebComponent" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionWebComponent

--
  
  Next: [:StrutsManualActionWebComponentSync:Building synchronous login 
component]
  
+ == Download WAR file ==
+ 
+ Download the sample: attachment:struts-components.war It also contains source 
code of business-related files (login action, form, JSP file) as well as 
suggested modifications for upcoming Struts 1.4 core.
+ 


[Struts Wiki] Update of "StrutsManualActionClasses" by MichaelJouravlev

2006-06-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsManualActionClasses

--
  
  Action class provides only one method to deal with all incoming requests, 
therefore actions rarely distinguish a ''render request'' from a ''submit 
request''. This often leads to convoluted and unmaintable code that can break 
from an occasional page refresh or from clicking on a Back button.
  
+ inline:setup_submit.gif
+ 
  Despite its shortcomins, the "servlet mode" is one of more popular uses of 
Action class.A typical Action class will often implement logic like the 
following in its execute method:
  
  * Validate the current state of the user's session (for example, checking 
that the user has successfully logged on). If the Action class finds that no 
logon exists, the request can be forwarded to the presentation page that 
displays the username and password prompts for logging on. This could occur 
because a user tried to enter an application "in the middle" (say, from a 
bookmark), or because the session has timed out, and the servlet container 
created a new one.
@@ -30, +32 @@

  * Perform the processing required to deal with this request (such as 
saving a row into a database). This can be done by logic code embedded within 
the Action class itself, but should generally be performed by calling an 
appropriate method of a business logic bean.
  * Update the server-side objects that will be used to create the next 
page of the user interface (typically request scope or session scope beans, 
depending on how long you need to keep these items available).
  * Return an appropriate ActionForward object that identifies the 
presentation page to be used to generate this response, based on the newly 
updated beans. Typically, you will acquire a reference to such an object by 
calling findForward on either the ActionMapping object you received (if you are 
using a logical name local to this mapping), or on the controller servlet 
itself (if you are using a logical name global to the application).
- 
- In Apache Struts 1.0, Actions called a perform method instead of the 
now-preferred execute method. These methods use the same parameters and differ 
only in which exceptions they throw. The elder perform method throws 
SerlvetException and IOException. The new execute method simply throws 
Exception. The change was to facilitate the Declarative Exception handling 
feature introduced in Apache Struts 1.1.
- 
- The perform method may still be used in Apache Struts 1.1 but is deprecated. 
The Apache Struts 1.1 method simply calls the new execute method and wraps any 
Exception thrown as a ServletException. The deprecated perform method was 
removed in Apache Struts 1.2.
  
  == Action As A Behavior Object ==
  


svn commit: r416981 - /struts/action/trunk/core/src/main/resources/org/apache/struts/resources/struts-config_1_3.dtd

2006-06-24 Thread wsmoak
Author: wsmoak
Date: Sat Jun 24 20:23:23 2006
New Revision: 416981

URL: http://svn.apache.org/viewvc?rev=416981&view=rev
Log:
Alphabetize DTD attributes and comments.

Modified:

struts/action/trunk/core/src/main/resources/org/apache/struts/resources/struts-config_1_3.dtd

Modified: 
struts/action/trunk/core/src/main/resources/org/apache/struts/resources/struts-config_1_3.dtd
URL: 
http://svn.apache.org/viewvc/struts/action/trunk/core/src/main/resources/org/apache/struts/resources/struts-config_1_3.dtd?rev=416981&r1=416980&r2=416981&view=diff
==
--- 
struts/action/trunk/core/src/main/resources/org/apache/struts/resources/struts-config_1_3.dtd
 (original)
+++ 
struts/action/trunk/core/src/main/resources/org/apache/struts/resources/struts-config_1_3.dtd
 Sat Jun 24 20:23:23 2006
@@ -268,10 +268,17 @@
  nested within an  element and only available to an Action object
  when it is invoked through that ActionMapping.
 
+ catalog The name of a commons-chain catalog in which to look up
+ a command to be executed as part of servicing this 
request.
+ Only meaningful if "command" is also specified.
+
  className   Fully qualified Java class name of ActionForward
  subclass to use for this object.
  ["org.apache.struts.action.ActionForward"]
 
+ command The name of a commons-chain command which should be 
looked up
+ and executed as part of servicing this request.
+
  extends The name of the forward configuration that this 
  will inherit configuration information from.
 
@@ -383,6 +390,10 @@
  nameName of the form bean, if any, that is associated with 
this
  action mapping.
 
+ parameter   General-purpose configuration parameter that can be used 
to
+ pass extra information to the Action object selected by
+ this action mapping.
+
  pathThe module-relative path of the submitted request, 
starting
  with a "/" character, and without the filename extension 
if
  extension mapping is used.
@@ -391,10 +402,6 @@
  because it will look like a filename extension and
  cause your Action to not be located.
 
- parameter   General-purpose configuration parameter that can be used 
to
- pass extra information to the Action object selected by
- this action mapping.
-
  prefix  Prefix used to match request parameter names to ActionForm
  property names, if any. Optional if "name" is specified,
  else not allowed.
@@ -461,12 +468,19 @@
  file uploads.
  [4096]
 
+ catalog Name of the catalog to use when processing requests
+ for this module.
+ [struts]
+
  className   Fully qualified Java class name of the
  ControllerConfig subclass for this controller object.
  If specified, the object must be a subclass of the
  default class.
  ["org.apache.struts.config.ControllerConfig"]
 
+ command Name of the command to execute to process a request.
+ [servlet-standard]
+
  contentType Default content type (and optional character encoding) to
  be set on each response. May be overridden by the Action,
  JSP, or other resource to which the request is forwarded.
@@ -544,17 +558,13 @@
  file uploads.
  [{Directory provided by servlet container}]
 
- catalog Name of the catalog to use when processing requests
- for this module.
- [struts]
-
- command Name of the command to execute to process a request.
- [servlet-standard]
 -->
 
 
 
+
 
+
 
 
 
@@ -566,8 +576,6 @@
 
 
 
-
-
 
 
 

svn commit: r416987 - /struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java

2006-06-24 Thread tmjee
Author: tmjee
Date: Sat Jun 24 23:52:48 2006
New Revision: 416987

URL: http://svn.apache.org/viewvc?rev=416987&view=rev
Log:
WW-1351
  - checked for possible NPE being thrown


Modified:

struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java

Modified: 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
URL: 
http://svn.apache.org/viewvc/struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java?rev=416987&r1=416986&r2=416987&view=diff
==
--- 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
 (original)
+++ 
struts/action2/trunk/apps/showcase/src/main/java/org/apache/struts/action2/showcase/chat/ChatSessionListener.java
 Sat Jun 24 23:52:48 2006
@@ -38,10 +38,12 @@
WebApplicationContext context = 
WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
if (context != null) {
User user = (User) 
session.getAttribute(ChatInterceptor.CHAT_USER_SESSION_KEY);
-   ChatService service = (ChatService) 
context.getBean("chatService");
-   service.logout(user.getName());
-   
-   _log.info("session expired, logged user 
["+user.getName()+"] out");
+   if (user != null) {
+   ChatService service = (ChatService) 
context.getBean("chatService");
+   service.logout(user.getName());
+   
+   _log.info("session expired, logged user 
["+user.getName()+"] out");
+   }
}
}