You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Bryan LaPlante <br...@xoscript.org> on 2006/02/01 15:08:11 UTC

Re: Help adding Struts to AJAX impl

I had a chance to look at this in more detail yesterday. It appears that I
will need to write a class to load up all the resources the same way the
init method in ActionServlet does. Am I in the right place to ask for help
understanding the API? It has been roughly a week and no reply.

----- Original Message -----
From: <br...@xoscript.org>
To: <de...@struts.apache.org>
Sent: Friday, January 27, 2006 1:27 PM
Subject: Help adding Struts to AJAX impl


> Hello fellow developers,
>
> I am new to your list. I have enjoyed using Struts for about 3 years now.
I
> have searched the dev archive concerning my current task and I am not sure
how
> to word my query. I am coming up with a lot of results labeled as a commit
to
> your code base.
>
> I have an AJAX implementation at http://www.xoscript.org/ and I want to
build
> support for Struts into the API. In a nutshell I need to find a factory
class
> in Struts that will allow me to obtain the current configuration so that I
can
> allow my users to pass an appropriate ActionMapping at runtime. Below is
the
> basic layout of the process. For more details about how xoscript works
visit
> the getting started and how it works links from the site above.
>
> A UerDefinedClass calls a UerDefinedActionClass.execute passing request
and
> response obtained from the AJAX API. The user will also need to pass an
> ActionMapping and an ActionForm to the execute method. I am trying to find
a
> way to get to this line in ActionServlet but I can not violate the
> getServletContext from one servlet to another. The over all concern is
that I
> am trying to keep my OutputStream from the response formatted in a certain
way
> and I can not just forward the request to the ActionServlet.
>
> ModuleUtils.getInstance().selectModule(request, getServletContext());
>        ModuleConfig config = getModuleConfig(request);
>
> Any help would be greatly appreciated.
>
> Bryan LaPlante
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "bryan@xoscript.org" <br...@xoscript.org>.
the way my client side api would expect to see that data would be like so.

<proxy-object>
 <class-object name="java.lang.String">
     <accountHolders>
       <accountHolder>
         <firstName>Frank</firstName>
         <lastName>Zammetti</lastName>
        <accountBalance>$1,000,000,000,000.00</accountBalance>
       </accountHoldeR>
     </accountHolders>
 </class-object>
</proxy-object>

More than likely the user would simply return a lazy version of the
accountHolders object in which case the <class-object> would go on to describe
the <method-object>'s and so on as preparation for the next method call. My
api is built on the concept that you are writing an application and not a web
page, however using web pages as a struts application would be a really handy
way of returning static html for forms and such. I'll think on that a while
and see what I come up with. I appreciate the collaboration, you are an easy
architect to understand.

Bryan

---------- Original Message -----------
From: "Frank W. Zammetti" <fz...@omnytex.com>
To: "Struts Developers List" <de...@struts.apache.org>
Cc: "Struts Developers List" <de...@struts.apache.org>
Sent: Wed, 1 Feb 2006 15:43:57 -0500 (EST)
Subject: Re: Help adding Struts to AJAX impl

> On Wed, February 1, 2006 3:35 pm, bryan@xoscript.org said:
> > I would need to write an AJAXAction that could in turn be extended by the
> > coder so that I could control the response back from the servlet. Ok I
> > just
> > thought of a gotcha for this approach. If the client is expecting a
> > specific
> > xml response I am not sure how I would allow the user to forward to other
> > actions and still maintain control unless all actions were extended from
> > AJAXAction and I really don't like that way that implies a re-write of an
> > existing application.
> 
> I would say that what is likely to be generating the data that forms your
> XML response in a properly-architected application is not likely to be in
> the Actions, and hence forwarding isn't a concern.
> 
> As an example, and understand that I'm not familiar with your library so
> I'm going to perhaps not a complete understanding... let's say I want the
> response from the server to represent a list of account holders:
> 
> <accountHolders>
>   <accountHolder>
>     <firstName>Frank</firstName>
>     <lastName>Zammetti</lastName>
>     <accountBalance>$1,000,000,000,000.00</accountBalance>
>   </accountHoldeR>
> </accountHolders>
> 
> (Oh how I WISH!! LOL)
> 
> Anyway... if things are written as is generally accepted as being best,
> the data in there, which maybe comes from a database, is retrieved not
> directly from the Action but from some business delegate.  So, your
> AJAXAction should not dispatch an incoming request to another Action that
> just so happens to use that delegate, but it should instead call on the
> business delegate directly.
> 
> So, in my mind at least, a developer wouldn't have to extend AJAXAction
> because only a single AJAXAction instance would be present in the app, and
> it would be the target of all the incoming AJAX requests.  Unless your
> thinking is that the Action would be responsible for creating the XML, in
> which case you might want to let the developer be in control of that, then
> extending AJAXAction is probaly the right answer.  In that case, I would
> simply say that either (a) forwards are not allowed, which implies the XML
> must be formed in the Action itself or (b) forwards to JSPs that render
> the XML are all that are allowed (this is demonstrated in AjaxTags in Java
> Web Parts by the way).
> 
> It of course comes down to how your library works, and how you want it to
> work.
> 
> > Thoughts?
> 
> Those above :)  And that I'm getting hungry ;)
> 
> > Bryan LaPlante
> 
> Frank
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
------- End of Original Message -------


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "bryan.laplante" <br...@syncredit.com>.
the way my client side api would expect to see that data would be like so.

<proxy-object>
  <class-object name="java.lang.String">
      <accountHolders>
        <accountHolder>
          <firstName>Frank</firstName>
          <lastName>Zammetti</lastName>
         <accountBalance>$1,000,000,000,000.00</accountBalance>
        </accountHoldeR>
      </accountHolders>
  </class-object>
</proxy-object>

More than likely the user would simply return a lazy version of the
accountHolders object in which case the <class-object> would go on to describe
the <method-object>'s and so on as preparation for the next method call. My
api is built on the concept that you are writing an application and not a web
page, however using web pages as a struts application would be a really handy
way of returning static html for forms and such. I'll think on that a while
and see what I come up with. I appreciate the collaboration, you are an easy
architect to understand.


Bryan

---------- Original Message -----------
From: "Frank W. Zammetti" <fz...@omnytex.com>
To: "Struts Developers List" <de...@struts.apache.org>
Cc: "Struts Developers List" <de...@struts.apache.org>
Sent: Wed, 1 Feb 2006 15:43:57 -0500 (EST)
Subject: Re: Help adding Struts to AJAX impl

> On Wed, February 1, 2006 3:35 pm, bryan@xoscript.org said:
> > I would need to write an AJAXAction that could in turn be extended by the
> > code r so that I could control the response back from the servlet. Ok I
> > just
> > thought of a gotcha for this approach. If the client is expecting a
> > specific
> > xml response I am not sure how I would allow the user to forward to other
> > actions and still maintain control unless all actions were extended from
> > AJAXAction and I really don't like that way that implies a re-write of an
> > existing application.
> 
> I would say that what is likely to be generating the data that forms your
> XML response in a properly-architected application is not likely to be in
> the Actions, and hence forwarding isn't a concern.
> 
> As an example, and understand that I'm not familiar with your library so
> I'm going to perhaps not a complete understanding... let's say I want the
> response from the server to represent a list of account holders:
> 
> <accountHolders>
>   <accountHolder>
>     <firstName>Frank</firstName>
>     <lastName>Zammetti</lastName>
>     <accountBalance>$1,000,000,000,000.00</accountBalance>
>   </accountHoldeR>
> </accountHolders>
> 
> (Oh how I WISH!! LOL)
> 
> Anyway... if things are written as is generally accepted as being best,
> the data in there, which maybe comes from a database, is retrieved not
> directly from the Action but from some business delegate.  So, your
> AJAXAction should not dispatch an incoming request to another Action that
> just so happens to use that delegate, but it should instead call on the
> business delegate directly.
> 
> So, in my mind at least, a developer wouldn't have to extend AJAXAction
> because only a single AJAXAction instance would be present in the app, and
> it would be the target of all the incoming AJAX requests.  Unless your
> thinking is that the Action would be responsible for creating the XML, in
> which case you might want to let the developer be in control of that, then
> extending AJAXAction is probaly the right answer.  In that case, I would
> simply say that either (a) forwards are not allowed, which implies the XML
> must be formed in the Action itself or (b) forwards to JSPs that render
> the XML are all that are allowed (this is demonstrated in AjaxTags in Java
> Web Parts by the way).
> 
> It of course comes down to how your library works, and how you want it to
> work.
> 
> > Thoughts?
> 
> Those above :)  And that I'm getting hungry ;)
> 
> > Bryan LaPlante
> 
> Frank
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
------- End of Original Message -------

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
What I should have said too is that if you want to discuss this further, 
feel free to contact me off-list, or start a new thread to explore it. 
We don't want to hijack the original thread :)

Frank

Frank W. Zammetti wrote:
> No Wendy, you are correct in your explanation :)  I see Ajax in Action 
> is serving you well :)
> 
> I wouldn't expect it to be the best answer though because that parameter 
> blocks *all* Javascript, not just further XMLHttpRequest's.
> 
> What you will probably want to do Michael is build up a queue on the 
> client and write some code to ensure the order the handlers fire.  This 
> could be pretty tricky to say the least.
> 
> Take a look at the RequestSender tag in AjaxTags in Java Web Parts... 
> AjaxTags builds up such a queue so that multiple requests can fire 
> simultaneously without stepping on each other.  I suspect you would be 
> able to extend this to ensure firing order.  Off the top of my head, I 
> would think you would need to set up a timer, and when the responses 
> come back, instead of processing them on the spot in the callback, 
> instead set a flag in the call structure that says "yes, this request 
> completed, but don't process it until the previous one completes"... 
> fire the timer every half a second or something like that to examine all 
> the call structures in the queue and fire them as appropriate.
> 
> Probably not a trivial exercise, but should be doable.
> 
> Frank
> 
> 
> Wendy Smoak wrote:
>> On 2/1/06, Michael Jouravlev <jm...@gmail.com> wrote:
>>
>>> Hi, Ajax gurus, I have an OT question: how to ensure the proper order
>>> of several XHRs? I found how to create several XHRs simultaneously,
>>> but I have a requirement: to wait for the first request to return
>>> before firing the second,
>>
>> (Hardly an expert but...) the third parameter of
>> XMLHttpRequest.open(...) is a flag that says whether the request
>> should be asynchronous.  It's usually true.  Set it to false and I
>> think it will block until the response is received.  Frank will now
>> correct me if I'm wrong. :)
>>
>> And lets move to the user list if this gets any further off topic, 
>> shall we?
>>
>> -- 
>> Wendy
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>>
>>
>>
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by Bryan LaPlante <br...@xoscript.org>.
This is an interesting issue that you all are discussing here because it is
a problem that had to solve for my own api. Let me tell you what I did and
then you can apply it to your situation as appropriate. On the JavaScript
side I created Objects to represent PageContext, Request, Response,
Listener, and EventObject. All of my of my method calls back to the server
use the writer obtained from request to write xml to the post or get method
of my request object. If I choose not to wait on the return of the method
call then I just tell the request to execute asynchronously and the post
gets fired via a setTimeout so that control is returned to my js object. If
I chose to do this and I want a call back for the return object I call the
request object's addListener method and hand it a js class that implements
EventObject whereby the fireEvent method is called. Ok sorry for the long
explanation. In a nut shell you just want to use some sort of a callback
method and chain your method calls in a certain order. If you want the
JavaScript that I am talking about you can download it at
http://www.xoscript.org just follow the setup configuration and run the
application tag one time and you will see the objects I am talking about
along with the rest of java.util.* written in js.

Ok, back to the original conversation. I created the AJAXAction and I have
one concern. On the line below and just before this line of code.

ProxyObjectFactory.writeProxyObject(response.getWriter(), o);

I need to figure out how I can call an action class's execute method and
safely pass it the current mapping and request and response wrappers
allowing the user to call forward as many time as they like. Then I would
take the resulting data writen to the response and add it to the xml in a
way that the client can feel as though they have just called a method on the
server and assigned the returned string to their own veriable. Long story
short, can I do an include from an Action class?

Here is what the AJAXAction would look like.

package org.apache.struts.webapp.example.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.xoscript.server.HttpMetaData;
import org.xoscript.service.LogFactory;
import org.xoscript.service.LogProvider;
import org.xoscript.service.ProxyObject;
import org.xoscript.service.ProxyObjectFactory;
import org.xoscript.service.XOService;
import org.xoscript.service.XOServiceFactory;

public class AjaxAction extends Action {

 private static LogProvider log = LogFactory.getLogProvider();
 private static XOService xoService = null;

    public ActionForward execute(ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
 throws Exception {

     ActionForward forward = null;

  if (log.isInfoEnabled()) {
   log.info("begin processRequest ------------------------------>: ");
  }

  try {
   /**
    * The (POJO)'s method call invoked by xoService below
    * can retrieve this meta data object from the
    * XOServiceFactory to get information about the
    * request and response objects
    */
   xoService = XOServiceFactory.getService();
   HttpMetaData metaData = new HttpMetaData();
   response.setContentType("text/xml; charset=ISO-8859-1");
   metaData.setRequest(request);
   metaData.setResponse(response);
   metaData.setContext(null);
   XOServiceFactory.setMetaData(metaData);

   /**
    * The xml is read in and a ProxoyObject is created.
    * The ProxyObject now contains the lookup information
    * for the POJO and what method and argument should be
    * invoked. The return value of the method is stored as
    * an Object.
    */
   Object o = xoService.invoke((ProxyObject)
    ProxyObjectFactory.readProxyObject(request.getReader()));

   /**
    * If the return value of the object is null. A Void class
    * is put in it's place.
    */
   if(o == null){
    o = Void.TYPE;
    if (log.isInfoEnabled()) {
     log.info("object was null returning void");
    }
   }

   /**
    * Here is the point at which I need to decide how to handle
    * forwards. The following Writer is prepaired with the xml
    * representing the returned object. If I return an ActionForward
    * from this method, then the ProxyObject xml will never
    * get created. Some how I need to cause an include to happen here
    * and give the user a way to pass back an ActionForward from
    * their method call if they want to send the result of a jsp page
    * back to the calling JavaScript as a string or optionaly return
    * an object of their choosing.
    */

   ProxyObjectFactory.writeProxyObject(response.getWriter(), o);

   metaData = null;
  } catch (Exception e) {
   try {
    /*
     * In the event that an exception is thrown, the Throwable
     * is wrapped in a ProxyObject and writen back to the
     * browser.
     */
    ProxyObjectFactory.writeProxyObject(response.getWriter(), e);
    if (log.isDebugEnabled()) {
     log.debug(e);
    }
   } catch (Exception e1) {
    if (log.isDebugEnabled()) {
     log.debug(e1);
    }
   }
  }finally{
   XOServiceFactory.destroy();
  }

  return forward;
    }

}

----- Original Message -----
From: "Frank W. Zammetti" <fz...@omnytex.com>
To: "Struts Developers List" <de...@struts.apache.org>
Sent: Wednesday, February 01, 2006 11:59 PM
Subject: Re: Help adding Struts to AJAX impl


>
> Laurie Harper wrote:
> > Sounds like it'd be a lot easier to just fire the first request with a
> > handler function that fires the next request, and so on, using
> > onreadystatechange.
>
> I would agree with that, *IF* the requests being sent are always the
> same and *IF* they are always in the same order.  I suppose you could
> have branching logic in the handler if the variations aren't numerous,
> but a more general-purpose approach might be better, such as the
> suggestion I made about the queue and the timer firing calls off the
stack.
>
> Frank
>
> > L.
> >
> > Frank W. Zammetti wrote:
> >> No Wendy, you are correct in your explanation :)  I see Ajax in Action
> >> is serving you well :)
> >>
> >> I wouldn't expect it to be the best answer though because that
> >> parameter blocks *all* Javascript, not just further XMLHttpRequest's.
> >>
> >> What you will probably want to do Michael is build up a queue on the
> >> client and write some code to ensure the order the handlers fire.
> >> This could be pretty tricky to say the least.
> >>
> >> Take a look at the RequestSender tag in AjaxTags in Java Web Parts...
> >> AjaxTags builds up such a queue so that multiple requests can fire
> >> simultaneously without stepping on each other.  I suspect you would be
> >> able to extend this to ensure firing order.  Off the top of my head, I
> >> would think you would need to set up a timer, and when the responses
> >> come back, instead of processing them on the spot in the callback,
> >> instead set a flag in the call structure that says "yes, this request
> >> completed, but don't process it until the previous one completes"...
> >> fire the timer every half a second or something like that to examine
> >> all the call structures in the queue and fire them as appropriate.
> >>
> >> Probably not a trivial exercise, but should be doable.
> >>
> >> Frank
> >>
> >>
> >> Wendy Smoak wrote:
> >>> On 2/1/06, Michael Jouravlev <jm...@gmail.com> wrote:
> >>>
> >>>> Hi, Ajax gurus, I have an OT question: how to ensure the proper order
> >>>> of several XHRs? I found how to create several XHRs simultaneously,
> >>>> but I have a requirement: to wait for the first request to return
> >>>> before firing the second,
> >>>
> >>> (Hardly an expert but...) the third parameter of
> >>> XMLHttpRequest.open(...) is a flag that says whether the request
> >>> should be asynchronous.  It's usually true.  Set it to false and I
> >>> think it will block until the response is received.  Frank will now
> >>> correct me if I'm wrong. :)
> >>>
> >>> And lets move to the user list if this gets any further off topic,
> >>> shall we?
> >>>
> >>> --
> >>> Wendy
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: dev-help@struts.apache.org
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
> >
> >
> >
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Laurie Harper wrote:
> Sounds like it'd be a lot easier to just fire the first request with a 
> handler function that fires the next request, and so on, using 
> onreadystatechange.

I would agree with that, *IF* the requests being sent are always the 
same and *IF* they are always in the same order.  I suppose you could 
have branching logic in the handler if the variations aren't numerous, 
but a more general-purpose approach might be better, such as the 
suggestion I made about the queue and the timer firing calls off the stack.

Frank

> L.
> 
> Frank W. Zammetti wrote:
>> No Wendy, you are correct in your explanation :)  I see Ajax in Action 
>> is serving you well :)
>>
>> I wouldn't expect it to be the best answer though because that 
>> parameter blocks *all* Javascript, not just further XMLHttpRequest's.
>>
>> What you will probably want to do Michael is build up a queue on the 
>> client and write some code to ensure the order the handlers fire.  
>> This could be pretty tricky to say the least.
>>
>> Take a look at the RequestSender tag in AjaxTags in Java Web Parts... 
>> AjaxTags builds up such a queue so that multiple requests can fire 
>> simultaneously without stepping on each other.  I suspect you would be 
>> able to extend this to ensure firing order.  Off the top of my head, I 
>> would think you would need to set up a timer, and when the responses 
>> come back, instead of processing them on the spot in the callback, 
>> instead set a flag in the call structure that says "yes, this request 
>> completed, but don't process it until the previous one completes"... 
>> fire the timer every half a second or something like that to examine 
>> all the call structures in the queue and fire them as appropriate.
>>
>> Probably not a trivial exercise, but should be doable.
>>
>> Frank
>>
>>
>> Wendy Smoak wrote:
>>> On 2/1/06, Michael Jouravlev <jm...@gmail.com> wrote:
>>>
>>>> Hi, Ajax gurus, I have an OT question: how to ensure the proper order
>>>> of several XHRs? I found how to create several XHRs simultaneously,
>>>> but I have a requirement: to wait for the first request to return
>>>> before firing the second,
>>>
>>> (Hardly an expert but...) the third parameter of
>>> XMLHttpRequest.open(...) is a flag that says whether the request
>>> should be asynchronous.  It's usually true.  Set it to false and I
>>> think it will block until the response is received.  Frank will now
>>> correct me if I'm wrong. :)
>>>
>>> And lets move to the user list if this gets any further off topic, 
>>> shall we?
>>>
>>> -- 
>>> Wendy
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>
>>>
>>>
>>>
>>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by Laurie Harper <la...@holoweb.net>.
Sounds like it'd be a lot easier to just fire the first request with a 
handler function that fires the next request, and so on, using 
onreadystatechange.

L.

Frank W. Zammetti wrote:
> No Wendy, you are correct in your explanation :)  I see Ajax in Action 
> is serving you well :)
> 
> I wouldn't expect it to be the best answer though because that parameter 
> blocks *all* Javascript, not just further XMLHttpRequest's.
> 
> What you will probably want to do Michael is build up a queue on the 
> client and write some code to ensure the order the handlers fire.  This 
> could be pretty tricky to say the least.
> 
> Take a look at the RequestSender tag in AjaxTags in Java Web Parts... 
> AjaxTags builds up such a queue so that multiple requests can fire 
> simultaneously without stepping on each other.  I suspect you would be 
> able to extend this to ensure firing order.  Off the top of my head, I 
> would think you would need to set up a timer, and when the responses 
> come back, instead of processing them on the spot in the callback, 
> instead set a flag in the call structure that says "yes, this request 
> completed, but don't process it until the previous one completes"... 
> fire the timer every half a second or something like that to examine all 
> the call structures in the queue and fire them as appropriate.
> 
> Probably not a trivial exercise, but should be doable.
> 
> Frank
> 
> 
> Wendy Smoak wrote:
>> On 2/1/06, Michael Jouravlev <jm...@gmail.com> wrote:
>>
>>> Hi, Ajax gurus, I have an OT question: how to ensure the proper order
>>> of several XHRs? I found how to create several XHRs simultaneously,
>>> but I have a requirement: to wait for the first request to return
>>> before firing the second,
>>
>> (Hardly an expert but...) the third parameter of
>> XMLHttpRequest.open(...) is a flag that says whether the request
>> should be asynchronous.  It's usually true.  Set it to false and I
>> think it will block until the response is received.  Frank will now
>> correct me if I'm wrong. :)
>>
>> And lets move to the user list if this gets any further off topic, 
>> shall we?
>>
>> -- 
>> Wendy
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>>
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
No Wendy, you are correct in your explanation :)  I see Ajax in Action 
is serving you well :)

I wouldn't expect it to be the best answer though because that parameter 
blocks *all* Javascript, not just further XMLHttpRequest's.

What you will probably want to do Michael is build up a queue on the 
client and write some code to ensure the order the handlers fire.  This 
could be pretty tricky to say the least.

Take a look at the RequestSender tag in AjaxTags in Java Web Parts... 
AjaxTags builds up such a queue so that multiple requests can fire 
simultaneously without stepping on each other.  I suspect you would be 
able to extend this to ensure firing order.  Off the top of my head, I 
would think you would need to set up a timer, and when the responses 
come back, instead of processing them on the spot in the callback, 
instead set a flag in the call structure that says "yes, this request 
completed, but don't process it until the previous one completes"... 
fire the timer every half a second or something like that to examine all 
the call structures in the queue and fire them as appropriate.

Probably not a trivial exercise, but should be doable.

Frank


Wendy Smoak wrote:
> On 2/1/06, Michael Jouravlev <jm...@gmail.com> wrote:
> 
>> Hi, Ajax gurus, I have an OT question: how to ensure the proper order
>> of several XHRs? I found how to create several XHRs simultaneously,
>> but I have a requirement: to wait for the first request to return
>> before firing the second,
> 
> (Hardly an expert but...) the third parameter of
> XMLHttpRequest.open(...) is a flag that says whether the request
> should be asynchronous.  It's usually true.  Set it to false and I
> think it will block until the response is received.  Frank will now
> correct me if I'm wrong. :)
> 
> And lets move to the user list if this gets any further off topic, shall we?
> 
> --
> Wendy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by Wendy Smoak <ws...@gmail.com>.
On 2/1/06, Michael Jouravlev <jm...@gmail.com> wrote:

> Hi, Ajax gurus, I have an OT question: how to ensure the proper order
> of several XHRs? I found how to create several XHRs simultaneously,
> but I have a requirement: to wait for the first request to return
> before firing the second,

(Hardly an expert but...) the third parameter of
XMLHttpRequest.open(...) is a flag that says whether the request
should be asynchronous.  It's usually true.  Set it to false and I
think it will block until the response is received.  Frank will now
correct me if I'm wrong. :)

And lets move to the user list if this gets any further off topic, shall we?

--
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by Ian Roughley <ia...@fdar.com>.
We are using the dojo toolkit in WebWork - this allows client side 
events.  So, from the first component you would specify a "notifyTopic" 
name (arbitrary), and then on the second component specify the same name 
for the "listenTopic".  Topics can also be bound to specific javascript 
functions in the page.  This seems to be working well, without too much 
complexity.

/Ian

-- 
>From Down & Around, Inc.
Innovative IT Solutions
Software Architecture * Design * Development
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
web:      www.fdar.com  
email     ian@fdar.com  
phone:    617.821.5430
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Michael Jouravlev wrote:

>Hi, Ajax gurus, I have an OT question: how to ensure the proper order
>of several XHRs? I found how to create several XHRs simultaneously,
>but I have a requirement: to wait for the first request to return
>before firing the second, because I need second request to pick up
>server state updated by first request. Got any advice? Or the only
>thing is to reorder/synchronize them on the server?
>
>Michael J.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org
>
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by Michael Jouravlev <jm...@gmail.com>.
Hi, Ajax gurus, I have an OT question: how to ensure the proper order
of several XHRs? I found how to create several XHRs simultaneously,
but I have a requirement: to wait for the first request to return
before firing the second, because I need second request to pick up
server state updated by first request. Got any advice? Or the only
thing is to reorder/synchronize them on the server?

Michael J.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Wed, February 1, 2006 3:35 pm, bryan@xoscript.org said:
> I would need to write an AJAXAction that could in turn be extended by the
> coder so that I could control the response back from the servlet. Ok I
> just
> thought of a gotcha for this approach. If the client is expecting a
> specific
> xml response I am not sure how I would allow the user to forward to other
> actions and still maintain control unless all actions were extended from
> AJAXAction and I really don't like that way that implies a re-write of an
> existing application.

I would say that what is likely to be generating the data that forms your
XML response in a properly-architected application is not likely to be in
the Actions, and hence forwarding isn't a concern.

As an example, and understand that I'm not familiar with your library so
I'm going to perhaps not a complete understanding... let's say I want the
response from the server to represent a list of account holders:

<accountHolders>
  <accountHolder>
    <firstName>Frank</firstName>
    <lastName>Zammetti</lastName>
    <accountBalance>$1,000,000,000,000.00</accountBalance>
  </accountHoldeR>
</accountHolders>

(Oh how I WISH!! LOL)

Anyway... if things are written as is generally accepted as being best,
the data in there, which maybe comes from a database, is retrieved not
directly from the Action but from some business delegate.  So, your
AJAXAction should not dispatch an incoming request to another Action that
just so happens to use that delegate, but it should instead call on the
business delegate directly.

So, in my mind at least, a developer wouldn't have to extend AJAXAction
because only a single AJAXAction instance would be present in the app, and
it would be the target of all the incoming AJAX requests.  Unless your
thinking is that the Action would be responsible for creating the XML, in
which case you might want to let the developer be in control of that, then
extending AJAXAction is probaly the right answer.  In that case, I would
simply say that either (a) forwards are not allowed, which implies the XML
must be formed in the Action itself or (b) forwards to JSPs that render
the XML are all that are allowed (this is demonstrated in AjaxTags in Java
Web Parts by the way).

It of course comes down to how your library works, and how you want it to
work.

> Thoughts?

Those above :)  And that I'm getting hungry ;)

> Bryan LaPlante

Frank

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "bryan@xoscript.org" <br...@xoscript.org>.
Using a custom action? Now that is a good idea. That would solve some problems
on a couple of levels such as how to lightly couple the struts classes into
mine such that a non-struts user would not be required to add the struts
required jars to the classpath.

Now just thinking out loud to take advantage of your knowledge while I have
you. I could set the servleturl of my application tag shown here at the bottom
of this url.
http://www.xoscript.org/opencms/opencms/documentation/setupconfig.html

I would need to write an AJAXAction that could in turn be extended by the
coder so that I could control the response back from the servlet. Ok I just
thought of a gotcha for this approach. If the client is expecting a specific
xml response I am not sure how I would allow the user to forward to other
actions and still maintain control unless all actions were extended from
AJAXAction and I really don't like that way that implies a re-write of an
existing application.

Thoughts?


Bryan LaPlante

---------- Original Message -----------
From: "Frank W. Zammetti" <fz...@omnytex.com>
To: "Struts Developers List" <de...@struts.apache.org>
Cc: "Struts Developers List" <de...@struts.apache.org>
Sent: Wed, 1 Feb 2006 14:46:34 -0500 (EST)
Subject: Re: Help adding Struts to AJAX impl

> Actually, that's another way to go, a Filter.  However, I was actually
> referring to the fact that Struts 1.3 uses a composable request processor
> based around the CoR pattern.  With that, you can modify the series of
> steps (Commands) that get executed with each request.  This is within the
> context of ActionServlet though, so you get access to all the Struts
> internals this way.  It soundslike adding a Command or two to the
> processing chain would allow you to do what you need.  But, if you wanted
> to support pre-1.3 as well (and I would think you would since 1.3 isn't
> officially out yet) then you'd have to go the custom RP route (although,
> there would be nothing to stop you from simply executing a chain from the
> RP, so at least your Commands could theoretically be identical for both
> versions).
> 
> Question: is there any way to do what you require within an Action?  I
> just *very* briefly skimmed over the doc you referenced here, and it seems
> like you might be able to get away with it.  If you have a specific Action
> that does what your servlet does, invokes the referenced class method and
> all, would that suffice?  That way you could avoid all the Struts
> customization entirely.
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> 
> On Wed, February 1, 2006 2:35 pm, bryan@xoscript.org said:
> > Yes sir you are right on the money. So you are saying I should use a
> > FilterChain to process calles to the ActionServlet and prepare the request
> > per
> > the needs of my ajax call before action servlet gets ahold of it. The only
> > problem with that is that I have a specific xml struture explained here
> > http://www.xoscript.org/opencms/opencms/documentation/howitworks.html that
> > I
> > need to rely on in the returned PrintWriter. I have a request and response
> > wrapper that I can give to an RequestProcessor and offer it a dummy
> > PrintWriter when it writes to response.getOut(). One I get the output back
> > and
> > can write it to the appropriate xml structure and hand it back to the
> > client
> > javascript that called the method.
> >
> > I guess I should ask if I am understanding your solution or am I off base.
> >
> > Bryan LaPlante
> >
> > ---------- Original Message -----------
> > From: "Frank W. Zammetti" <fz...@omnytex.com>
> > To: "Struts Developers List" <de...@struts.apache.org>
> > Cc: "Struts Developers List" <de...@struts.apache.org>
> > Sent: Wed, 1 Feb 2006 10:22:27 -0500 (EST)
> > Subject: Re: Help adding Struts to AJAX impl
> >
> >> Hi Bryan,
> >>
> >> I'm not sure I'm clear on what your trying to do... it sounds like you
> >> have a separate servlet running along side ActionServlet that receives
> >> your AJAX requests, and this servlet you want to call Actions, is that
> >> correct?
> >>
> >> If so, I would suggest perhaps a better approach is to modify the
> >> request
> >> processing chain (in 1.3) to recognize an AJAX request (perhaps some
> >> specific parameter) and change the request accordingly.  If you want to
> >> support pre-1.3, your talking about a custom RequestProcessor... both of
> >> these are done in my Struts Web Services project
> >> (http://sourceforge.net/projects/strutsws).
> >>
> >> Or am I off-base to begin with? :)
> >>
> >> --
> >> Frank W. Zammetti
> >> Founder and Chief Software Architect
> >> Omnytex Technologies
> >> http://www.omnytex.com
> >> AIM: fzammetti
> >> Yahoo: fzammetti
> >> MSN: fzammetti@hotmail.com
> >>
> >> On Wed, February 1, 2006 9:08 am, Bryan LaPlante said:
> >> > I had a chance to look at this in more detail yesterday. It appears
> >> that I
> >> > will need to write a class to load up all the resources the same way
> >> the
> >> > init method in ActionServlet does. Am I in the right place to ask for
> >> help
> >> > understanding the API? It has been roughly a week and no reply.
> >> >
> >> > ----- Original Message -----
> >> > From: <br...@xoscript.org>
> >> > To: <de...@struts.apache.org>
> >> > Sent: Friday, January 27, 2006 1:27 PM
> >> > Subject: Help adding Struts to AJAX impl
> >> >
> >> >
> >> >> Hello fellow developers,
> >> >>
> >> >> I am new to your list. I have enjoyed using Struts for about 3 years
> >> >> now.
> >> > I
> >> >> have searched the dev archive concerning my current task and I am not
> >> >> sure
> >> > how
> >> >> to word my query. I am coming up with a lot of results labeled as a
> >> >> commit
> >> > to
> >> >> your code base.
> >> >>
> >> >> I have an AJAX implementation at http://www.xoscript.org/ and I want
> >> to
> >> > build
> >> >> support for Struts into the API. In a nutshell I need to find a
> >> factory
> >> > class
> >> >> in Struts that will allow me to obtain the current configuration so
> >> that
> >> >> I
> >> > can
> >> >> allow my users to pass an appropriate ActionMapping at runtime. Below
> >> is
> >> > the
> >> >> basic layout of the process. For more details about how xoscript
> >> works
> >> > visit
> >> >> the getting started and how it works links from the site above.
> >> >>
> >> >> A UerDefinedClass calls a UerDefinedActionClass.execute passing
> >> request
> >> > and
> >> >> response obtained from the AJAX API. The user will also need to pass
> >> an
> >> >> ActionMapping and an ActionForm to the execute method. I am trying to
> >> >> find
> >> > a
> >> >> way to get to this line in ActionServlet but I can not violate the
> >> >> getServletContext from one servlet to another. The over all concern
> >> is
> >> > that I
> >> >> am trying to keep my OutputStream from the response formatted in a
> >> >> certain
> >> > way
> >> >> and I can not just forward the request to the ActionServlet.
> >> >>
> >> >> ModuleUtils.getInstance().selectModule(request, getServletContext());
> >> >>        ModuleConfig config = getModuleConfig(request);
> >> >>
> >> >> Any help would be greatly appreciated.
> >> >>
> >> >> Bryan LaPlante
> >> >>
> >> >>
> >> >> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> >> For additional commands, e-mail: dev-help@struts.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> > For additional commands, e-mail: dev-help@struts.apache.org
> >> >
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: dev-help@struts.apache.org
> > ------- End of Original Message -------
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
------- End of Original Message -------

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Actually, that's another way to go, a Filter.  However, I was actually
referring to the fact that Struts 1.3 uses a composable request processor
based around the CoR pattern.  With that, you can modify the series of
steps (Commands) that get executed with each request.  This is within the
context of ActionServlet though, so you get access to all the Struts
internals this way.  It soundslike adding a Command or two to the
processing chain would allow you to do what you need.  But, if you wanted
to support pre-1.3 as well (and I would think you would since 1.3 isn't
officially out yet) then you'd have to go the custom RP route (although,
there would be nothing to stop you from simply executing a chain from the
RP, so at least your Commands could theoretically be identical for both
versions).

Question: is there any way to do what you require within an Action?  I
just *very* briefly skimmed over the doc you referenced here, and it seems
like you might be able to get away with it.  If you have a specific Action
that does what your servlet does, invokes the referenced class method and
all, would that suffice?  That way you could avoid all the Struts
customization entirely.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

On Wed, February 1, 2006 2:35 pm, bryan@xoscript.org said:
> Yes sir you are right on the money. So you are saying I should use a
> FilterChain to process calles to the ActionServlet and prepare the request
> per
> the needs of my ajax call before action servlet gets ahold of it. The only
> problem with that is that I have a specific xml struture explained here
> http://www.xoscript.org/opencms/opencms/documentation/howitworks.html that
> I
> need to rely on in the returned PrintWriter. I have a request and response
> wrapper that I can give to an RequestProcessor and offer it a dummy
> PrintWriter when it writes to response.getOut(). One I get the output back
> and
> can write it to the appropriate xml structure and hand it back to the
> client
> javascript that called the method.
>
> I guess I should ask if I am understanding your solution or am I off base.
>
> Bryan LaPlante
>
> ---------- Original Message -----------
> From: "Frank W. Zammetti" <fz...@omnytex.com>
> To: "Struts Developers List" <de...@struts.apache.org>
> Cc: "Struts Developers List" <de...@struts.apache.org>
> Sent: Wed, 1 Feb 2006 10:22:27 -0500 (EST)
> Subject: Re: Help adding Struts to AJAX impl
>
>> Hi Bryan,
>>
>> I'm not sure I'm clear on what your trying to do... it sounds like you
>> have a separate servlet running along side ActionServlet that receives
>> your AJAX requests, and this servlet you want to call Actions, is that
>> correct?
>>
>> If so, I would suggest perhaps a better approach is to modify the
>> request
>> processing chain (in 1.3) to recognize an AJAX request (perhaps some
>> specific parameter) and change the request accordingly.  If you want to
>> support pre-1.3, your talking about a custom RequestProcessor... both of
>> these are done in my Struts Web Services project
>> (http://sourceforge.net/projects/strutsws).
>>
>> Or am I off-base to begin with? :)
>>
>> --
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
>> AIM: fzammetti
>> Yahoo: fzammetti
>> MSN: fzammetti@hotmail.com
>>
>> On Wed, February 1, 2006 9:08 am, Bryan LaPlante said:
>> > I had a chance to look at this in more detail yesterday. It appears
>> that I
>> > will need to write a class to load up all the resources the same way
>> the
>> > init method in ActionServlet does. Am I in the right place to ask for
>> help
>> > understanding the API? It has been roughly a week and no reply.
>> >
>> > ----- Original Message -----
>> > From: <br...@xoscript.org>
>> > To: <de...@struts.apache.org>
>> > Sent: Friday, January 27, 2006 1:27 PM
>> > Subject: Help adding Struts to AJAX impl
>> >
>> >
>> >> Hello fellow developers,
>> >>
>> >> I am new to your list. I have enjoyed using Struts for about 3 years
>> >> now.
>> > I
>> >> have searched the dev archive concerning my current task and I am not
>> >> sure
>> > how
>> >> to word my query. I am coming up with a lot of results labeled as a
>> >> commit
>> > to
>> >> your code base.
>> >>
>> >> I have an AJAX implementation at http://www.xoscript.org/ and I want
>> to
>> > build
>> >> support for Struts into the API. In a nutshell I need to find a
>> factory
>> > class
>> >> in Struts that will allow me to obtain the current configuration so
>> that
>> >> I
>> > can
>> >> allow my users to pass an appropriate ActionMapping at runtime. Below
>> is
>> > the
>> >> basic layout of the process. For more details about how xoscript
>> works
>> > visit
>> >> the getting started and how it works links from the site above.
>> >>
>> >> A UerDefinedClass calls a UerDefinedActionClass.execute passing
>> request
>> > and
>> >> response obtained from the AJAX API. The user will also need to pass
>> an
>> >> ActionMapping and an ActionForm to the execute method. I am trying to
>> >> find
>> > a
>> >> way to get to this line in ActionServlet but I can not violate the
>> >> getServletContext from one servlet to another. The over all concern
>> is
>> > that I
>> >> am trying to keep my OutputStream from the response formatted in a
>> >> certain
>> > way
>> >> and I can not just forward the request to the ActionServlet.
>> >>
>> >> ModuleUtils.getInstance().selectModule(request, getServletContext());
>> >>        ModuleConfig config = getModuleConfig(request);
>> >>
>> >> Any help would be greatly appreciated.
>> >>
>> >> Bryan LaPlante
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: dev-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: dev-help@struts.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
> ------- End of Original Message -------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "bryan@xoscript.org" <br...@xoscript.org>.
Yes sir you are right on the money. So you are saying I should use a
FilterChain to process calles to the ActionServlet and prepare the request per
the needs of my ajax call before action servlet gets ahold of it. The only
problem with that is that I have a specific xml struture explained here
http://www.xoscript.org/opencms/opencms/documentation/howitworks.html that I
need to rely on in the returned PrintWriter. I have a request and response
wrapper that I can give to an RequestProcessor and offer it a dummy
PrintWriter when it writes to response.getOut(). One I get the output back and
can write it to the appropriate xml structure and hand it back to the client
javascript that called the method.

I guess I should ask if I am understanding your solution or am I off base. 

Bryan LaPlante

---------- Original Message -----------
From: "Frank W. Zammetti" <fz...@omnytex.com>
To: "Struts Developers List" <de...@struts.apache.org>
Cc: "Struts Developers List" <de...@struts.apache.org>
Sent: Wed, 1 Feb 2006 10:22:27 -0500 (EST)
Subject: Re: Help adding Struts to AJAX impl

> Hi Bryan,
> 
> I'm not sure I'm clear on what your trying to do... it sounds like you
> have a separate servlet running along side ActionServlet that receives
> your AJAX requests, and this servlet you want to call Actions, is that
> correct?
> 
> If so, I would suggest perhaps a better approach is to modify the request
> processing chain (in 1.3) to recognize an AJAX request (perhaps some
> specific parameter) and change the request accordingly.  If you want to
> support pre-1.3, your talking about a custom RequestProcessor... both of
> these are done in my Struts Web Services project
> (http://sourceforge.net/projects/strutsws).
> 
> Or am I off-base to begin with? :)
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
> 
> On Wed, February 1, 2006 9:08 am, Bryan LaPlante said:
> > I had a chance to look at this in more detail yesterday. It appears that I
> > will need to write a class to load up all the resources the same way the
> > init method in ActionServlet does. Am I in the right place to ask for help
> > understanding the API? It has been roughly a week and no reply.
> >
> > ----- Original Message -----
> > From: <br...@xoscript.org>
> > To: <de...@struts.apache.org>
> > Sent: Friday, January 27, 2006 1:27 PM
> > Subject: Help adding Struts to AJAX impl
> >
> >
> >> Hello fellow developers,
> >>
> >> I am new to your list. I have enjoyed using Struts for about 3 years
> >> now.
> > I
> >> have searched the dev archive concerning my current task and I am not
> >> sure
> > how
> >> to word my query. I am coming up with a lot of results labeled as a
> >> commit
> > to
> >> your code base.
> >>
> >> I have an AJAX implementation at http://www.xoscript.org/ and I want to
> > build
> >> support for Struts into the API. In a nutshell I need to find a factory
> > class
> >> in Struts that will allow me to obtain the current configuration so that
> >> I
> > can
> >> allow my users to pass an appropriate ActionMapping at runtime. Below is
> > the
> >> basic layout of the process. For more details about how xoscript works
> > visit
> >> the getting started and how it works links from the site above.
> >>
> >> A UerDefinedClass calls a UerDefinedActionClass.execute passing request
> > and
> >> response obtained from the AJAX API. The user will also need to pass an
> >> ActionMapping and an ActionForm to the execute method. I am trying to
> >> find
> > a
> >> way to get to this line in ActionServlet but I can not violate the
> >> getServletContext from one servlet to another. The over all concern is
> > that I
> >> am trying to keep my OutputStream from the response formatted in a
> >> certain
> > way
> >> and I can not just forward the request to the ActionServlet.
> >>
> >> ModuleUtils.getInstance().selectModule(request, getServletContext());
> >>        ModuleConfig config = getModuleConfig(request);
> >>
> >> Any help would be greatly appreciated.
> >>
> >> Bryan LaPlante
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: dev-help@struts.apache.org
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
------- End of Original Message -------


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Help adding Struts to AJAX impl

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Hi Bryan,

I'm not sure I'm clear on what your trying to do... it sounds like you
have a separate servlet running along side ActionServlet that receives
your AJAX requests, and this servlet you want to call Actions, is that
correct?

If so, I would suggest perhaps a better approach is to modify the request
processing chain (in 1.3) to recognize an AJAX request (perhaps some
specific parameter) and change the request accordingly.  If you want to
support pre-1.3, your talking about a custom RequestProcessor... both of
these are done in my Struts Web Services project
(http://sourceforge.net/projects/strutsws).

Or am I off-base to begin with? :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

On Wed, February 1, 2006 9:08 am, Bryan LaPlante said:
> I had a chance to look at this in more detail yesterday. It appears that I
> will need to write a class to load up all the resources the same way the
> init method in ActionServlet does. Am I in the right place to ask for help
> understanding the API? It has been roughly a week and no reply.
>
> ----- Original Message -----
> From: <br...@xoscript.org>
> To: <de...@struts.apache.org>
> Sent: Friday, January 27, 2006 1:27 PM
> Subject: Help adding Struts to AJAX impl
>
>
>> Hello fellow developers,
>>
>> I am new to your list. I have enjoyed using Struts for about 3 years
>> now.
> I
>> have searched the dev archive concerning my current task and I am not
>> sure
> how
>> to word my query. I am coming up with a lot of results labeled as a
>> commit
> to
>> your code base.
>>
>> I have an AJAX implementation at http://www.xoscript.org/ and I want to
> build
>> support for Struts into the API. In a nutshell I need to find a factory
> class
>> in Struts that will allow me to obtain the current configuration so that
>> I
> can
>> allow my users to pass an appropriate ActionMapping at runtime. Below is
> the
>> basic layout of the process. For more details about how xoscript works
> visit
>> the getting started and how it works links from the site above.
>>
>> A UerDefinedClass calls a UerDefinedActionClass.execute passing request
> and
>> response obtained from the AJAX API. The user will also need to pass an
>> ActionMapping and an ActionForm to the execute method. I am trying to
>> find
> a
>> way to get to this line in ActionServlet but I can not violate the
>> getServletContext from one servlet to another. The over all concern is
> that I
>> am trying to keep my OutputStream from the response formatted in a
>> certain
> way
>> and I can not just forward the request to the ActionServlet.
>>
>> ModuleUtils.getInstance().selectModule(request, getServletContext());
>>        ModuleConfig config = getModuleConfig(request);
>>
>> Any help would be greatly appreciated.
>>
>> Bryan LaPlante
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org