You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by kedgecomb <ke...@yahoo.com> on 2007/02/13 19:28:39 UTC

Mixing Struts2 ajax functions with actionErrors and actionMessages

I have been using the actionErrors and actionMessage features of Struts2 for
some time and they have worked well for providing user feedback, (e.g.;
"Business Center deleted successfully", "User already exists with this ID",
etc.).  I add the error or the message in the action class like so:


    public String add() throws Exception {
    	
    	try {
		service.addUser(user);
		users = service.getAllUsers();
    		
    	} catch(PersistenceExistsException ee) {
    		addActionError(getText("user.alreadyExists"));
    		return Action.INPUT;
    		
    	} catch(PersistenceNotFoundException nfe) {
        	this.addActionError(getText("global.unableToProcessRequest"));
    		return Action.INPUT;
    	}
	addActionMessage(getText("user.addSuccess"));
        return SUCCESS;
    }

This had the effect of deleting a user, refreshing the list of all users,
and sending a success message if all went well.
If something went wrong, a descriptive error would be displayed just above
the list of users.

It worked well until I began to incorporate the AJAX tags into the mix.  I
use a s:div to display the list of users:

<tr>
	<td colspan="2">
		<s:div id="users" theme="ajax" href="userAdmin.do" listenTopics="delete"
>loading...</s:div>
	</td>
</tr>

The JSP fragment that is returned to this div contains the list of users. 
This also worked well.  But the JSP also contains the actionError and
actionMessage tags:

<tr>
	<td colspan="4" class="PageStatus">
		<font color="#FF0000"><s:actionerror/></font>
	</td>
</tr>
<tr>
	<td colspan="4" class="PageStatus">
		<font color="#00FF00"><s:actionmessage/></font>
	</td>
</tr>

The problem is that these tags are never populated while using the AJAX
feature.  Neither errors nor messages are displayed at any time.  If I use
the same url that the s:div tag uses, and key it into the browser address,
the row is added or deleted and the message displays correctly, (using the
exact same jsp).  When I use an ajax link:

<s:url id="removeUrl" action="removeUser">
	<s:param name="userId" value="userId" />
</s:url>
<s:a href="%{removeUrl}" theme="ajax" notifyTopics="delete" ><s:text
name="global.delete"/></s:a>

the correct user is deleted, the div is refreshed with the new list of
users, but no message displays.


Are the message tags handled differently when using AJAX?


-- 
View this message in context: http://www.nabble.com/Mixing-Struts2-ajax-functions-with-actionErrors-and-actionMessages-tf3222408.html#a8950048
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] Mixing Struts2 ajax functions with actionErrors and actionMessages

Posted by kedgecomb <ke...@yahoo.com>.
I replaced the tags with plain text and it displays when I call the url
directly and asynchronously.



Musachy Barroso-2 wrote:
> 
> That should be it. Just to make sure it is not related to the errors or 
> the messages, replace the <s:actionmessage/> with some fixed text, and 
> see if that text is showing up.
> 
> musachy
> 
> kedgecomb wrote:
>> I am using a single taglib directive:
>>
>> 	<%@ taglib prefix="s" uri="/struts-tags" %>
>>
>> Is there something else I need?  Also, I get the messages correctly if I
>> call the url directly, (not using an async call).
>>
>> I will try the Firebug suggestion.
>>
>>
>>
>>
>> Musachy Barroso-2 wrote:
>>   
>>> The ajax request is handled just like any other request (its 
>>> asynchronous nature is only related to the client). So whatever the 
>>> action outputs, it will be sent to the client and inserted inside the 
>>> div. Use Firebug to see what is the return of the ajax call, plus make 
>>> sure the jsp fragment has all the required taglib directives.
>>>
>>> regards
>>> musachy
>>>
>>> kedgecomb wrote:
>>>     
>>>> I have been using the actionErrors and actionMessage features of
>>>> Struts2
>>>> for
>>>> some time and they have worked well for providing user feedback, (e.g.;
>>>> "Business Center deleted successfully", "User already exists with this
>>>> ID",
>>>> etc.).  I add the error or the message in the action class like so:
>>>>
>>>>
>>>>     public String add() throws Exception {
>>>>     	
>>>>     	try {
>>>> 		service.addUser(user);
>>>> 		users = service.getAllUsers();
>>>>     		
>>>>     	} catch(PersistenceExistsException ee) {
>>>>     		addActionError(getText("user.alreadyExists"));
>>>>     		return Action.INPUT;
>>>>     		
>>>>     	} catch(PersistenceNotFoundException nfe) {
>>>>         	this.addActionError(getText("global.unableToProcessRequest"));
>>>>     		return Action.INPUT;
>>>>     	}
>>>> 	addActionMessage(getText("user.addSuccess"));
>>>>         return SUCCESS;
>>>>     }
>>>>
>>>> This had the effect of deleting a user, refreshing the list of all
>>>> users,
>>>> and sending a success message if all went well.
>>>> If something went wrong, a descriptive error would be displayed just
>>>> above
>>>> the list of users.
>>>>
>>>> It worked well until I began to incorporate the AJAX tags into the mix. 
>>>> I
>>>> use a s:div to display the list of users:
>>>>
>>>> <tr>
>>>> 	<td colspan="2">
>>>> 		<s:div id="users" theme="ajax" href="userAdmin.do"
>>>> listenTopics="delete"
>>>>   
>>>>       
>>>>> loading...</s:div>
>>>>>     
>>>>>         
>>>> 	</td>
>>>> </tr>
>>>>
>>>> The JSP fragment that is returned to this div contains the list of
>>>> users. 
>>>> This also worked well.  But the JSP also contains the actionError and
>>>> actionMessage tags:
>>>>
>>>> <tr>
>>>> 	<td colspan="4" class="PageStatus">
>>>> 		<font color="#FF0000"><s:actionerror/></font>
>>>> 	</td>
>>>> </tr>
>>>> <tr>
>>>> 	<td colspan="4" class="PageStatus">
>>>> 		<font color="#00FF00"><s:actionmessage/></font>
>>>> 	</td>
>>>> </tr>
>>>>
>>>> The problem is that these tags are never populated while using the AJAX
>>>> feature.  Neither errors nor messages are displayed at any time.  If I
>>>> use
>>>> the same url that the s:div tag uses, and key it into the browser
>>>> address,
>>>> the row is added or deleted and the message displays correctly, (using
>>>> the
>>>> exact same jsp).  When I use an ajax link:
>>>>
>>>> <s:url id="removeUrl" action="removeUser">
>>>> 	<s:param name="userId" value="userId" />
>>>> </s:url>
>>>> <s:a href="%{removeUrl}" theme="ajax" notifyTopics="delete" ><s:text
>>>> name="global.delete"/></s:a>
>>>>
>>>> the correct user is deleted, the div is refreshed with the new list of
>>>> users, but no message displays.
>>>>
>>>>
>>>> Are the message tags handled differently when using AJAX?
>>>>
>>>>
>>>>   
>>>>       
>>> ---------------------------------------------------------------------
>>> 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
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Mixing-Struts2-ajax-functions-with-actionErrors-and-actionMessages-tf3222408.html#a8958123
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] Mixing Struts2 ajax functions with actionErrors and actionMessages

Posted by Musachy Barroso <mb...@wfscorp.com>.
That should be it. Just to make sure it is not related to the errors or 
the messages, replace the <s:actionmessage/> with some fixed text, and 
see if that text is showing up.

musachy

kedgecomb wrote:
> I am using a single taglib directive:
>
> 	<%@ taglib prefix="s" uri="/struts-tags" %>
>
> Is there something else I need?  Also, I get the messages correctly if I
> call the url directly, (not using an async call).
>
> I will try the Firebug suggestion.
>
>
>
>
> Musachy Barroso-2 wrote:
>   
>> The ajax request is handled just like any other request (its 
>> asynchronous nature is only related to the client). So whatever the 
>> action outputs, it will be sent to the client and inserted inside the 
>> div. Use Firebug to see what is the return of the ajax call, plus make 
>> sure the jsp fragment has all the required taglib directives.
>>
>> regards
>> musachy
>>
>> kedgecomb wrote:
>>     
>>> I have been using the actionErrors and actionMessage features of Struts2
>>> for
>>> some time and they have worked well for providing user feedback, (e.g.;
>>> "Business Center deleted successfully", "User already exists with this
>>> ID",
>>> etc.).  I add the error or the message in the action class like so:
>>>
>>>
>>>     public String add() throws Exception {
>>>     	
>>>     	try {
>>> 		service.addUser(user);
>>> 		users = service.getAllUsers();
>>>     		
>>>     	} catch(PersistenceExistsException ee) {
>>>     		addActionError(getText("user.alreadyExists"));
>>>     		return Action.INPUT;
>>>     		
>>>     	} catch(PersistenceNotFoundException nfe) {
>>>         	this.addActionError(getText("global.unableToProcessRequest"));
>>>     		return Action.INPUT;
>>>     	}
>>> 	addActionMessage(getText("user.addSuccess"));
>>>         return SUCCESS;
>>>     }
>>>
>>> This had the effect of deleting a user, refreshing the list of all users,
>>> and sending a success message if all went well.
>>> If something went wrong, a descriptive error would be displayed just
>>> above
>>> the list of users.
>>>
>>> It worked well until I began to incorporate the AJAX tags into the mix. 
>>> I
>>> use a s:div to display the list of users:
>>>
>>> <tr>
>>> 	<td colspan="2">
>>> 		<s:div id="users" theme="ajax" href="userAdmin.do"
>>> listenTopics="delete"
>>>   
>>>       
>>>> loading...</s:div>
>>>>     
>>>>         
>>> 	</td>
>>> </tr>
>>>
>>> The JSP fragment that is returned to this div contains the list of users. 
>>> This also worked well.  But the JSP also contains the actionError and
>>> actionMessage tags:
>>>
>>> <tr>
>>> 	<td colspan="4" class="PageStatus">
>>> 		<font color="#FF0000"><s:actionerror/></font>
>>> 	</td>
>>> </tr>
>>> <tr>
>>> 	<td colspan="4" class="PageStatus">
>>> 		<font color="#00FF00"><s:actionmessage/></font>
>>> 	</td>
>>> </tr>
>>>
>>> The problem is that these tags are never populated while using the AJAX
>>> feature.  Neither errors nor messages are displayed at any time.  If I
>>> use
>>> the same url that the s:div tag uses, and key it into the browser
>>> address,
>>> the row is added or deleted and the message displays correctly, (using
>>> the
>>> exact same jsp).  When I use an ajax link:
>>>
>>> <s:url id="removeUrl" action="removeUser">
>>> 	<s:param name="userId" value="userId" />
>>> </s:url>
>>> <s:a href="%{removeUrl}" theme="ajax" notifyTopics="delete" ><s:text
>>> name="global.delete"/></s:a>
>>>
>>> the correct user is deleted, the div is refreshed with the new list of
>>> users, but no message displays.
>>>
>>>
>>> Are the message tags handled differently when using AJAX?
>>>
>>>
>>>   
>>>       
>> ---------------------------------------------------------------------
>> 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


RE: Struts 1.3 pain

Posted by "Chaudhary, Harsh" <HC...@amfam.com>.
I will try that.
Thanks a lot for your input.

Harsh.

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Tuesday, February 13, 2007 5:05 PM
To: Struts Users Mailing List
Subject: Re: Struts 1.3 pain


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Harsh,

Chaudhary, Harsh wrote:
> There is no specific reason, But we have one custom validation, So is
it
> good practice to revamp the entire the validator.xml file then?

Well, there's no reason to put everything into one file. I had this same
problem (upgrading between commons-validator releases, and from Struts
1.2 to 1.3), and then I read that you can use more than one file.

Now, I have this in my struts-config.xml:

    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
            value="/org/apache/struts/validator/validator-rules.xml,
            /WEB-INF/my-validator-rules.xml,
            ..." />
    </plug-in>

Note that you can use the stock validator-rules.xml file directly from
within the JAR file that it comes with.

Just add your own rules file after that. Then, at least, you only have
to update your own file (and source files as well) when you upgrade.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF0kQj9CaO5/Lv0PARAuzPAKClljgIqBGsTdPN/zrlVypgqKQoRQCgs+P2
fk4WAxDk8zAQaYY/8LEj9eg=
=8C+F
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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


Re: Struts 1.3 pain

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Harsh,

Chaudhary, Harsh wrote:
> There is no specific reason, But we have one custom validation, So is it
> good practice to revamp the entire the validator.xml file then?

Well, there's no reason to put everything into one file. I had this same
problem (upgrading between commons-validator releases, and from Struts
1.2 to 1.3), and then I read that you can use more than one file.

Now, I have this in my struts-config.xml:

    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
            value="/org/apache/struts/validator/validator-rules.xml,
            /WEB-INF/my-validator-rules.xml,
            ..." />
    </plug-in>

Note that you can use the stock validator-rules.xml file directly from
within the JAR file that it comes with.

Just add your own rules file after that. Then, at least, you only have
to update your own file (and source files as well) when you upgrade.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF0kQj9CaO5/Lv0PARAuzPAKClljgIqBGsTdPN/zrlVypgqKQoRQCgs+P2
fk4WAxDk8zAQaYY/8LEj9eg=
=8C+F
-----END PGP SIGNATURE-----

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


RE: Struts 1.3 pain

Posted by "Chaudhary, Harsh" <HC...@amfam.com>.
There is no specific reason, But we have one custom validation, So is it
good practice to revamp the entire the validator.xml file then?

Any other gotchas from someone who has migrated a 1.2 app to 1.3?

Harsh.

-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net] 
Sent: Tuesday, February 13, 2007 4:10 PM
To: Struts Users Mailing List
Subject: Re: Struts 1.3 pain


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chaudhary,

Chaudhary, Harsh wrote:
> I am trying to convert a Struts 1.2 app to Struts 1.3.

[snip]

> I have the validator.xml, validator-rules.xml and errors.properties
> intact from my Struts 1.2 version.

Is there a reason to keep your old validator.xml file? Why not just
overwrite the one you have with the new one?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF0jdC9CaO5/Lv0PARAucpAKCRudkIjz5pyv24P7GQeqdssmi9FwCdHfIg
I6fYBhZTOfBGwZuLbLNVrjE=
=673S
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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


Re: Struts 1.3 pain

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chaudhary,

Chaudhary, Harsh wrote:
> I am trying to convert a Struts 1.2 app to Struts 1.3.

[snip]

> I have the validator.xml, validator-rules.xml and errors.properties
> intact from my Struts 1.2 version.

Is there a reason to keep your old validator.xml file? Why not just
overwrite the one you have with the new one?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF0jdC9CaO5/Lv0PARAucpAKCRudkIjz5pyv24P7GQeqdssmi9FwCdHfIg
I6fYBhZTOfBGwZuLbLNVrjE=
=673S
-----END PGP SIGNATURE-----

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


Struts 1.3 pain

Posted by "Chaudhary, Harsh" <HC...@amfam.com>.
I am trying to convert a Struts 1.2 app to Struts 1.3.

Method definitions for custom validation in validator-rules.xml

Struts 1.2 Version

<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
javax.servlet.http.HttpServletRequest"
msg="errors.required"/>

Struts 1.3 Version

<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
>>>>>>>>>org.apache.commons.validator.Validator,<<<<<<<<<
javax.servlet.http.HttpServletRequest"
msg="errors.required"/> 

 

In Struts 1.2 version I did not have to pass the Validator object for
the required field. But with 1.3 am being forced to do so, if not I get
a No Such Method Exception. Now that I have tweaked the "required"
validator, when I try to run my struts application, am getting a
org.apache.commons.validator.ValidatorException: No such validation
method: null exception. Digging into the error stack trace it says
java.lang.NullPointerException: No message resources found for bundle:
org.apache.struts.action.MESSAGE

I have the validator.xml, validator-rules.xml and errors.properties
intact from my Struts 1.2 version.

Any thoughts or ideas of what am doing wrong.

Harsh.

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


Re: [S2] Mixing Struts2 ajax functions with actionErrors and actionMessages

Posted by kedgecomb <ke...@yahoo.com>.
I am using a single taglib directive:

	<%@ taglib prefix="s" uri="/struts-tags" %>

Is there something else I need?  Also, I get the messages correctly if I
call the url directly, (not using an async call).

I will try the Firebug suggestion.




Musachy Barroso-2 wrote:
> 
> The ajax request is handled just like any other request (its 
> asynchronous nature is only related to the client). So whatever the 
> action outputs, it will be sent to the client and inserted inside the 
> div. Use Firebug to see what is the return of the ajax call, plus make 
> sure the jsp fragment has all the required taglib directives.
> 
> regards
> musachy
> 
> kedgecomb wrote:
>> I have been using the actionErrors and actionMessage features of Struts2
>> for
>> some time and they have worked well for providing user feedback, (e.g.;
>> "Business Center deleted successfully", "User already exists with this
>> ID",
>> etc.).  I add the error or the message in the action class like so:
>>
>>
>>     public String add() throws Exception {
>>     	
>>     	try {
>> 		service.addUser(user);
>> 		users = service.getAllUsers();
>>     		
>>     	} catch(PersistenceExistsException ee) {
>>     		addActionError(getText("user.alreadyExists"));
>>     		return Action.INPUT;
>>     		
>>     	} catch(PersistenceNotFoundException nfe) {
>>         	this.addActionError(getText("global.unableToProcessRequest"));
>>     		return Action.INPUT;
>>     	}
>> 	addActionMessage(getText("user.addSuccess"));
>>         return SUCCESS;
>>     }
>>
>> This had the effect of deleting a user, refreshing the list of all users,
>> and sending a success message if all went well.
>> If something went wrong, a descriptive error would be displayed just
>> above
>> the list of users.
>>
>> It worked well until I began to incorporate the AJAX tags into the mix. 
>> I
>> use a s:div to display the list of users:
>>
>> <tr>
>> 	<td colspan="2">
>> 		<s:div id="users" theme="ajax" href="userAdmin.do"
>> listenTopics="delete"
>>   
>>> loading...</s:div>
>>>     
>> 	</td>
>> </tr>
>>
>> The JSP fragment that is returned to this div contains the list of users. 
>> This also worked well.  But the JSP also contains the actionError and
>> actionMessage tags:
>>
>> <tr>
>> 	<td colspan="4" class="PageStatus">
>> 		<font color="#FF0000"><s:actionerror/></font>
>> 	</td>
>> </tr>
>> <tr>
>> 	<td colspan="4" class="PageStatus">
>> 		<font color="#00FF00"><s:actionmessage/></font>
>> 	</td>
>> </tr>
>>
>> The problem is that these tags are never populated while using the AJAX
>> feature.  Neither errors nor messages are displayed at any time.  If I
>> use
>> the same url that the s:div tag uses, and key it into the browser
>> address,
>> the row is added or deleted and the message displays correctly, (using
>> the
>> exact same jsp).  When I use an ajax link:
>>
>> <s:url id="removeUrl" action="removeUser">
>> 	<s:param name="userId" value="userId" />
>> </s:url>
>> <s:a href="%{removeUrl}" theme="ajax" notifyTopics="delete" ><s:text
>> name="global.delete"/></s:a>
>>
>> the correct user is deleted, the div is refreshed with the new list of
>> users, but no message displays.
>>
>>
>> Are the message tags handled differently when using AJAX?
>>
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Mixing-Struts2-ajax-functions-with-actionErrors-and-actionMessages-tf3222408.html#a8950953
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: Mixing Struts2 ajax functions with actionErrors and actionMessages

Posted by Musachy Barroso <mb...@wfscorp.com>.
The ajax request is handled just like any other request (its 
asynchronous nature is only related to the client). So whatever the 
action outputs, it will be sent to the client and inserted inside the 
div. Use Firebug to see what is the return of the ajax call, plus make 
sure the jsp fragment has all the required taglib directives.

regards
musachy

kedgecomb wrote:
> I have been using the actionErrors and actionMessage features of Struts2 for
> some time and they have worked well for providing user feedback, (e.g.;
> "Business Center deleted successfully", "User already exists with this ID",
> etc.).  I add the error or the message in the action class like so:
>
>
>     public String add() throws Exception {
>     	
>     	try {
> 		service.addUser(user);
> 		users = service.getAllUsers();
>     		
>     	} catch(PersistenceExistsException ee) {
>     		addActionError(getText("user.alreadyExists"));
>     		return Action.INPUT;
>     		
>     	} catch(PersistenceNotFoundException nfe) {
>         	this.addActionError(getText("global.unableToProcessRequest"));
>     		return Action.INPUT;
>     	}
> 	addActionMessage(getText("user.addSuccess"));
>         return SUCCESS;
>     }
>
> This had the effect of deleting a user, refreshing the list of all users,
> and sending a success message if all went well.
> If something went wrong, a descriptive error would be displayed just above
> the list of users.
>
> It worked well until I began to incorporate the AJAX tags into the mix.  I
> use a s:div to display the list of users:
>
> <tr>
> 	<td colspan="2">
> 		<s:div id="users" theme="ajax" href="userAdmin.do" listenTopics="delete"
>   
>> loading...</s:div>
>>     
> 	</td>
> </tr>
>
> The JSP fragment that is returned to this div contains the list of users. 
> This also worked well.  But the JSP also contains the actionError and
> actionMessage tags:
>
> <tr>
> 	<td colspan="4" class="PageStatus">
> 		<font color="#FF0000"><s:actionerror/></font>
> 	</td>
> </tr>
> <tr>
> 	<td colspan="4" class="PageStatus">
> 		<font color="#00FF00"><s:actionmessage/></font>
> 	</td>
> </tr>
>
> The problem is that these tags are never populated while using the AJAX
> feature.  Neither errors nor messages are displayed at any time.  If I use
> the same url that the s:div tag uses, and key it into the browser address,
> the row is added or deleted and the message displays correctly, (using the
> exact same jsp).  When I use an ajax link:
>
> <s:url id="removeUrl" action="removeUser">
> 	<s:param name="userId" value="userId" />
> </s:url>
> <s:a href="%{removeUrl}" theme="ajax" notifyTopics="delete" ><s:text
> name="global.delete"/></s:a>
>
> the correct user is deleted, the div is refreshed with the new list of
> users, but no message displays.
>
>
> Are the message tags handled differently when using AJAX?
>
>
>   


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