That CodeExecuter is nice!

With dojo.io.bind() I use DWRUtil.setValue() to load the response into my <div>,
which doesn't execute any <script> tags.

I've had to use a hack-around to include JSPs, hence evaluating javascript. Bad stuff!

About below, I'm talking about when my MyForm (extends ActionForm, not Action) returns an ActionErrors object as it is configured in the example struts-config below.

Like if "to"  parameter was supposed to be a valid email address and someone
entered: blah blah blah

Will this be handled normally, like a Non-Ajax struts action app, returning the
input mapping to display the errors, or whatever else.

-Joe




-----------------------------------------------------------------------------------

WEB DESIGN BY DRAEGOONZ

Joseph "DraegoonZ" McGranaghan

http://www.draegoonZ.com

603-620-0854

[EMAIL PROTECTED]




From: "Frank W. Zammetti" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: Struts and AJAX
Date: Mon, 03 Jul 2006 15:38:17 -0400

draegoon Z wrote:
Sounds great so far, but I think I lost you on the first part.
Let's work through a simple problem...

Let's say I have in my struts-config:

<action path="/my_action" forward="tile.my_action" />
<action path="/success" forward="tile.success" />
<action path="/error" forward="tile.error" />

<action name="MyForm" path="/process_my_action" input="/my_action.do" scope="request" type="com.draegoonZ.action.MyAction">
    <forward name="success" path="/success.do" />
    <forward name="error" path="/error.do" />
</action>

First, what happens if MyForm just simply returns an ActionError?

MyForm, which I assume extends from Action, would have to return an ActionForward, or null... if null, then the response would have to be fully formed by the Action, otherwise it presumably returns a forward to a JSP that renders some response. That JSP would have to make use of the ActionErrors, and render a response appropriate for what you want to happen on the client, whether that's updating a <div>, popping an alert(), or something else.

I feel like I'm not understanding what your getting at though :)

Second, what if MyAction has ActionErrors and forwards to its 'error' page?

Same basic answer as above... you wouldn't, in all probability, reuse the same JSP as rendered the form, as is typical in Struts apps. In this case, you would probably be submitting to some mapping that is expressly set up to handle the AJAX request. That means that the input attribute would make to some JSP that renders the response appropriate for the error condition (the same basic mechanism as described above).

Are you saying that APT gets the response (JSP,text,HTML, whatever) and matches
the regex to that entire response string?

That's correct, it executes the regex against responseText of XMLHttpRequest.

If so, how do you advise setting flags in the response to ensure the proper responseHandler
is called without neccessarily displaying the flag itself. Like,

THIS_IS_MY_UGLY_FLAG_BEFORE_CONTENT_AND_FIRST_IN_THE_RESPONSE:<p>content</p>

I think more than likely you would key off of some text in a real response... i.e., if the error message is something like "To field cannot be blank", then check for something like "/cannot be blank/". If you wanted to do something like you show above, you probably would need to write a custom handler because there would be no opportunity to essentially strip the flag from the response... the post-processing function does not fire until AFTER all the response handlers have fired. I think you've found a good enhancement opportunity :)

Another possibility is to return Javascrpt... APT will always execute any <script> blocks it finds in the response. There is also a standard CodeExecuter response handler that assumes the response is Javascript and executes it even without the <script> block. This would allow you to do whatever you wanted upon return, i.e., flag error fields, whatever.

-Joe

Frank

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to