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

------------------------------------------------------------------------------
  
  In Struts 1.2.9 - 1.3.x Action class does not implement dispatching 
functionality, you need to extend a dispatching action. Use 
!EventDispatchAction as the simplest and the most flexible choice. Another 
difference is that you need to specify an {{{ActionForward}}} object that 
points to a component view. You must do it in {{{unspecified}}} method or 
whatever method you selected as default in event definition.
  
- Using !EventDispatchAction to handle incoming events gets you only halfway, 
because the code that automatically distinguishes the address of a composite 
page and then redirects to it is not present in older Struts versions. You need 
an add-on library that contains this code. Then you need to call it from 
{{{execute}}} method of your action. '''TODO'''
+ Using !EventDispatchAction or EventActionDispatcher to handle incoming events 
gets you only halfway, because the code that automatically distinguishes the 
address of a composite page and then redirects to it is not present in older 
Struts versions. You need an add-on library that contains this code. Then you 
need to call it from {{{execute}}} method of your action. '''TODO'''
  
  '''Struts 1.2.9, 1.3.x:'''
  {{{
- public class LoginAction extends EventDispatchAction {
+ public class LoginAction extends Action {
+ 
+     // Instantiate event dispatcher
+     protected ActionDispatcher dispatcher = new EventActionDispatcher (this);
+ 
+ 
+     public ActionForward execute(ActionMapping mapping,
+                                  ActionForm form,
+                                  HttpServletRequest request,
+                                  HttpServletResponse response)
+         throws Exception {
+         
+         // Set component ID in page context, so other tags inside this
+         // component knew the component name
+         
request.setAttribute(org.apache.struts.component.Constants.COMPONENT_ID, 
"Login");
+ 
+         // Dispatch requst to a handler
+         ActionForward dispatchedForward =
+             dispatcher.execute(mapping, form, request, response);
+         
+         // Process this action as component action
+         return processComponentRequest(form, request, response, 
dispatchedForward, mapping);
+     }
+ 
  
      public ActionForward execute (...) throws Exception {
          ComponentUtils.componentReload(...); // TODO
@@ -163, +186 @@

                                        ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response) throws 
Exception {
-         return "view";
+         return mapping.findForward("view");
      }
  }
  }}}

Reply via email to