You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fireapple <ta...@gmail.com> on 2009/07/09 18:03:14 UTC

S2: Ajax tags -- how to return a message to a specific DIV?

I wonder if this is durable with S2:

JSP form:
this form has a button FINALIZE, if all goes well - the result SUCCESS
should be seen in placeA on the page and if it fails the result FAILURE
should be seen in placeB (a different place on the page);
the SUCCESS/FAILURE are just messages but they must be seen on different
places on the page.
(note that the page is using AJAX tags)

<code>
<s:submit value="finalize"  action="test_ finalize" theme="ajax"
targets="target_id_success, target_id_failure"  showLoadingText="false"
indicator="loadingImage"/>
.
.

<!-- placeA -->
<s:div id="target_id_success" theme="ajax">
</div>
.
.
<!-- placeB -->
<s:div id="target_id_failure" theme="ajax">
</div>
</code>

So, say the end user clicks the finalize button and activates the
finalize-action-method. How can I instruct in the action that for if all
goes well - show the success message on DIV target_id_success,
and if something went wrong - show the FAILURE message on DIV:
target_id_failure. 

<code>
public String finalize()
{
     
     //something went wrong
     addActionError("error...sorry"); //this error should be seen only in
DIV target_id_failure
     return "error-message";

      //if all is OK
      addActionMessage("good job"); //this message should be seen only on
DIV target_id_success
      return "success-message";
}
</code>

Many thanks!

-- 
View this message in context: http://www.nabble.com/S2%3A-Ajax-tags----how-to-return-a-message-to-a-specific-DIV--tp24412933p24412933.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: S2: Ajax tags -- how to return a message to a specific DIV?

Posted by Paweł Wielgus <po...@gmail.com>.
Hi fireapple,
as for me You should not do it in action,
precisely action should not decide what div to be updated,
just perform action and return some result - success or error.
What i would do is to place this logic inside $ajax(...) call from
jquery [which i use]
so that other programmers could read it when they will change that
behaviour on the page or in js file.

But that is just my opinion.

Best greetings,
Paweł Wielgus.

2009/7/9 fireapple <ta...@gmail.com>:
>
> I wonder if this is durable with S2:
>
> JSP form:
> this form has a button FINALIZE, if all goes well - the result SUCCESS
> should be seen in placeA on the page and if it fails the result FAILURE
> should be seen in placeB (a different place on the page);
> the SUCCESS/FAILURE are just messages but they must be seen on different
> places on the page.
> (note that the page is using AJAX tags)
>
> <code>
> <s:submit value="finalize"  action="test_ finalize" theme="ajax"
> targets="target_id_success, target_id_failure"  showLoadingText="false"
> indicator="loadingImage"/>
> .
> .
>
> <!-- placeA -->
> <s:div id="target_id_success" theme="ajax">
> </div>
> .
> .
> <!-- placeB -->
> <s:div id="target_id_failure" theme="ajax">
> </div>
> </code>
>
> So, say the end user clicks the finalize button and activates the
> finalize-action-method. How can I instruct in the action that for if all
> goes well - show the success message on DIV target_id_success,
> and if something went wrong - show the FAILURE message on DIV:
> target_id_failure.
>
> <code>
> public String finalize()
> {
>
>     //something went wrong
>     addActionError("error...sorry"); //this error should be seen only in
> DIV target_id_failure
>     return "error-message";
>
>      //if all is OK
>      addActionMessage("good job"); //this message should be seen only on
> DIV target_id_success
>      return "success-message";
> }
> </code>
>
> Many thanks!
>
> --
> View this message in context: http://www.nabble.com/S2%3A-Ajax-tags----how-to-return-a-message-to-a-specific-DIV--tp24412933p24412933.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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