You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Dhulipudi, Sivannarayana" <si...@cgi.com> on 2017/11/16 15:15:44 UTC

Struts2.x ActionError And ActionMessage

Hi All,

I tried to use struts 2.x  ActionError and ActonMessage classes to do validations. 

I saw a lot examples on internet, in those examples adding errors and messages to actionsupport class like

 addActionErrors() and addActionMessage(). but I want to use ActionError and ActionMessage classes in my project.

I'm not doing validation in action class . please help me someone on this topic. 

Thanks
Siva


________________________________________
From: Lukasz Lenart [lukaszlenart@apache.org]
Sent: Wednesday, November 15, 2017 11:52 PM
To: Struts Users Mailing List
Subject: Re: Migration from Struts1 to Struts2.5

2017-11-15 16:26 GMT+01:00 JK <ja...@gmail.com>:
> struts2-core-2.5.13.jar
> struts2-tiles-plugin-2.3.8.jar
> tiles-core-2.0.6.jar
> tiles-jsp-2.0.6.jar
> tiles-api-2.0.6.jar

You are using a wrong version of Tiles, Struts 2.5.13 and the Struts 2
Tiles plugin based on Tiles 3 - you must use Tiles 3.0.7 at least
http://struts.apache.org/maven/struts2-plugins/struts2-tiles-plugin/dependency-management.html


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
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: Struts2.x ActionError And ActionMessage

Posted by Paul Zepernick <Pa...@healthsmart.com>.
The <s:actionerror/> tag will print out your errors in the jsp page.  Have a look at this tutorial, maybe it will be of some assistance

https://www.mkyong.com/struts2/struts-2-actionerror-actionmessage-example/

-----Original Message-----
From: Dhulipudi, Sivannarayana [mailto:sivannarayana.dhulipudi@cgi.com] 
Sent: Thursday, November 16, 2017 11:39 AM
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: RE: Struts2.x ActionError And ActionMessage

Actually  we are using Apache commons validation frame work along with struts, when ever validation failed, I want to create one action error message and keep that action error in context and display error message in jsp page. 




________________________________________
From: Paul Zepernick [Paul.Zepernick@healthsmart.com]
Sent: Thursday, November 16, 2017 9:28 AM
To: 'Struts Users Mailing List'
Subject: RE: Struts2.x ActionError And ActionMessage

ActionError and ActionMessage are not classes you can utilize stand alone.  Calling addActionError() is actually building a List<String> in the action and same with addActionMessage().  Are you trying to validate a Struts action or something entirely different, since you say the validation is not done in your action class?  Maybe you need to pass the instance of your action class to the class that you have doing the validation?

-----Original Message-----
From: Adam Brin [mailto:abrin@digitalantiquity.org]
Sent: Thursday, November 16, 2017 10:19 AM
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: Struts2.x ActionError And ActionMessage

Hi Siva,
  Can you share an example of what you're doing and what's not working?

thanks,

adam
--
_________________________________________________________
Adam Brin
Director of Technology, Digital Antiquity
480.965.1278

> On Nov 16, 2017, at 8:15 AM, Dhulipudi, Sivannarayana <si...@cgi.com> wrote:
>
> Hi All,
>
> I tried to use struts 2.x  ActionError and ActonMessage classes to do validations.
>
> I saw a lot examples on internet, in those examples adding errors and 
> messages to actionsupport class like
>
> addActionErrors() and addActionMessage(). but I want to use ActionError and ActionMessage classes in my project.
>
> I'm not doing validation in action class . please help me someone on this topic.
>
> Thanks
> Siva
>
>
> ________________________________________
> From: Lukasz Lenart [lukaszlenart@apache.org]
> Sent: Wednesday, November 15, 2017 11:52 PM
> To: Struts Users Mailing List
> Subject: Re: Migration from Struts1 to Struts2.5
>
> 2017-11-15 16:26 GMT+01:00 JK <ja...@gmail.com>:
>> struts2-core-2.5.13.jar
>> struts2-tiles-plugin-2.3.8.jar
>> tiles-core-2.0.6.jar
>> tiles-jsp-2.0.6.jar
>> tiles-api-2.0.6.jar
>
> You are using a wrong version of Tiles, Struts 2.5.13 and the Struts 2 
> Tiles plugin based on Tiles 3 - you must use Tiles 3.0.7 at least 
> http://struts.apache.org/maven/struts2-plugins/struts2-tiles-plugin/de
> pendency-management.html
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> 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
>


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




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

---------------------------------------------------------------------
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: Struts2.x ActionError And ActionMessage

Posted by Yasser Zamani <ya...@apache.org>.

On 11/16/2017 8:09 PM, Dhulipudi, Sivannarayana wrote:
> when ever validation failed, I want to create one action error message and keep that action error in context

Hello Dhulipudi, Welcome!

Could you try below please....

ActionSupport myCurrentActionSupport = (ActionSupport) 
ActionContext.getContext().getValueStack().peek();

myCurrentActionSupport.addActionError("my error");

>  and display error message in jsp page

<s:actionerror/> <!-- in your jsp -->

Regards,
Yasser.

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


AW: Struts2.x ActionError And ActionMessage

Posted by Ch...@bmw.de.
> 
> Actually  we are using Apache commons validation frame work along with
> struts, when ever validation failed, I want to create one action error message
> and keep that action error in context and display error message in jsp page.
> 


Note that actionerrors are global errors. It sounds to me that you should rather use fielderrors. The technical bits (how to access actioncontext) are the same for fielderrors.


Regards,
Christoph


> 
> 
> 
> ________________________________________
> From: Paul Zepernick [Paul.Zepernick@healthsmart.com]
> Sent: Thursday, November 16, 2017 9:28 AM
> To: 'Struts Users Mailing List'
> Subject: RE: Struts2.x ActionError And ActionMessage
> 
> ActionError and ActionMessage are not classes you can utilize stand alone.
> Calling addActionError() is actually building a List<String> in the action and
> same with addActionMessage().  Are you trying to validate a Struts action or
> something entirely different, since you say the validation is not done in your
> action class?  Maybe you need to pass the instance of your action class to the
> class that you have doing the validation?
> 
> -----Original Message-----
> From: Adam Brin [mailto:abrin@digitalantiquity.org]
> Sent: Thursday, November 16, 2017 10:19 AM
> To: Struts Users Mailing List <us...@struts.apache.org>
> Subject: Re: Struts2.x ActionError And ActionMessage
> 
> Hi Siva,
>   Can you share an example of what you're doing and what's not working?
> 
> thanks,
> 
> adam
> --
> _________________________________________________________
> Adam Brin
> Director of Technology, Digital Antiquity
> 480.965.1278
> 
> > On Nov 16, 2017, at 8:15 AM, Dhulipudi, Sivannarayana
> <si...@cgi.com> wrote:
> >
> > Hi All,
> >
> > I tried to use struts 2.x  ActionError and ActonMessage classes to do
> validations.
> >
> > I saw a lot examples on internet, in those examples adding errors and
> > messages to actionsupport class like
> >
> > addActionErrors() and addActionMessage(). but I want to use ActionError
> and ActionMessage classes in my project.
> >
> > I'm not doing validation in action class . please help me someone on this
> topic.
> >
> > Thanks
> > Siva
> >
> >
> > ________________________________________
> > From: Lukasz Lenart [lukaszlenart@apache.org]
> > Sent: Wednesday, November 15, 2017 11:52 PM
> > To: Struts Users Mailing List
> > Subject: Re: Migration from Struts1 to Struts2.5
> >
> > 2017-11-15 16:26 GMT+01:00 JK <ja...@gmail.com>:
> >> struts2-core-2.5.13.jar
> >> struts2-tiles-plugin-2.3.8.jar
> >> tiles-core-2.0.6.jar
> >> tiles-jsp-2.0.6.jar
> >> tiles-api-2.0.6.jar
> >
> > You are using a wrong version of Tiles, Struts 2.5.13 and the Struts 2
> > Tiles plugin based on Tiles 3 - you must use Tiles 3.0.7 at least
> > http://struts.apache.org/maven/struts2-plugins/struts2-tiles-plugin/de
> > pendency-management.html
> >
> >
> > Regards
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > ---------------------------------------------------------------------
> > 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
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 
> Disclaimer: This communication and any files transmitted with it may contain
> information that is privileged, confidential and/or exempt from disclosure
> under applicable law. If you are not the intended recipient, you are hereby
> notified that any disclosure, copying, distribution, or use of the information
> contained herein (including any reliance thereon) is strictly prohibited. If you
> received this communication in error, please immediately contact the sender
> and destroy the material in its entirety, whether in electronic or hard copy
> format. Thank you.
> 
> ---------------------------------------------------------------------
> 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: Struts2.x ActionError And ActionMessage

Posted by Yasser Zamani <ya...@apache.org>.

On 11/17/2017 9:12 AM, Yasser Zamani wrote:
> Hello Dhulipudi, Welcome!
> 
> Could you try below please....
> 
> ActionSupport myCurrentActionSupport = (ActionSupport) 
> ActionContext.getContext().getValueStack().peek();
> 
> myCurrentActionSupport.addActionError("my error");

Please remember if it even works, it's not a good design. I just try to 
know if you have an action context there where you're trying to add an 
error.

A better design maybe is to throw a specific exception if you're in 
lower layers than the action and action is not available there (e.g. 
you're in service layer) then simply catch that in your action and then ....

this.addActionError(e.getMessage());

Or don't catch this specific exception anywhere in actions and use 
global exception handling instead [1].

Regards,
Yasser.

[1] https://struts.apache.org/getting-started/exception-handling.html

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


RE: Struts2.x ActionError And ActionMessage

Posted by "Dhulipudi, Sivannarayana" <si...@cgi.com>.
Actually  we are using Apache commons validation frame work along with struts, when ever validation failed, I want to create one action error message and keep that action error in context and display error message in jsp page. 




________________________________________
From: Paul Zepernick [Paul.Zepernick@healthsmart.com]
Sent: Thursday, November 16, 2017 9:28 AM
To: 'Struts Users Mailing List'
Subject: RE: Struts2.x ActionError And ActionMessage

ActionError and ActionMessage are not classes you can utilize stand alone.  Calling addActionError() is actually building a List<String> in the action and same with addActionMessage().  Are you trying to validate a Struts action or something entirely different, since you say the validation is not done in your action class?  Maybe you need to pass the instance of your action class to the class that you have doing the validation?

-----Original Message-----
From: Adam Brin [mailto:abrin@digitalantiquity.org]
Sent: Thursday, November 16, 2017 10:19 AM
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: Struts2.x ActionError And ActionMessage

Hi Siva,
  Can you share an example of what you’re doing and what’s not working?

thanks,

adam
--
_________________________________________________________
Adam Brin
Director of Technology, Digital Antiquity
480.965.1278

> On Nov 16, 2017, at 8:15 AM, Dhulipudi, Sivannarayana <si...@cgi.com> wrote:
>
> Hi All,
>
> I tried to use struts 2.x  ActionError and ActonMessage classes to do validations.
>
> I saw a lot examples on internet, in those examples adding errors and
> messages to actionsupport class like
>
> addActionErrors() and addActionMessage(). but I want to use ActionError and ActionMessage classes in my project.
>
> I'm not doing validation in action class . please help me someone on this topic.
>
> Thanks
> Siva
>
>
> ________________________________________
> From: Lukasz Lenart [lukaszlenart@apache.org]
> Sent: Wednesday, November 15, 2017 11:52 PM
> To: Struts Users Mailing List
> Subject: Re: Migration from Struts1 to Struts2.5
>
> 2017-11-15 16:26 GMT+01:00 JK <ja...@gmail.com>:
>> struts2-core-2.5.13.jar
>> struts2-tiles-plugin-2.3.8.jar
>> tiles-core-2.0.6.jar
>> tiles-jsp-2.0.6.jar
>> tiles-api-2.0.6.jar
>
> You are using a wrong version of Tiles, Struts 2.5.13 and the Struts 2
> Tiles plugin based on Tiles 3 - you must use Tiles 3.0.7 at least
> http://struts.apache.org/maven/struts2-plugins/struts2-tiles-plugin/de
> pendency-management.html
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> 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
>


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




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

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


RE: Struts2.x ActionError And ActionMessage

Posted by Paul Zepernick <Pa...@healthsmart.com>.
ActionError and ActionMessage are not classes you can utilize stand alone.  Calling addActionError() is actually building a List<String> in the action and same with addActionMessage().  Are you trying to validate a Struts action or something entirely different, since you say the validation is not done in your action class?  Maybe you need to pass the instance of your action class to the class that you have doing the validation?

-----Original Message-----
From: Adam Brin [mailto:abrin@digitalantiquity.org]
Sent: Thursday, November 16, 2017 10:19 AM
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: Struts2.x ActionError And ActionMessage

Hi Siva,
  Can you share an example of what you’re doing and what’s not working?

thanks,

adam
--
_________________________________________________________
Adam Brin
Director of Technology, Digital Antiquity
480.965.1278

> On Nov 16, 2017, at 8:15 AM, Dhulipudi, Sivannarayana <si...@cgi.com> wrote:
>
> Hi All,
>
> I tried to use struts 2.x  ActionError and ActonMessage classes to do validations.
>
> I saw a lot examples on internet, in those examples adding errors and
> messages to actionsupport class like
>
> addActionErrors() and addActionMessage(). but I want to use ActionError and ActionMessage classes in my project.
>
> I'm not doing validation in action class . please help me someone on this topic.
>
> Thanks
> Siva
>
>
> ________________________________________
> From: Lukasz Lenart [lukaszlenart@apache.org]
> Sent: Wednesday, November 15, 2017 11:52 PM
> To: Struts Users Mailing List
> Subject: Re: Migration from Struts1 to Struts2.5
>
> 2017-11-15 16:26 GMT+01:00 JK <ja...@gmail.com>:
>> struts2-core-2.5.13.jar
>> struts2-tiles-plugin-2.3.8.jar
>> tiles-core-2.0.6.jar
>> tiles-jsp-2.0.6.jar
>> tiles-api-2.0.6.jar
>
> You are using a wrong version of Tiles, Struts 2.5.13 and the Struts 2
> Tiles plugin based on Tiles 3 - you must use Tiles 3.0.7 at least
> http://struts.apache.org/maven/struts2-plugins/struts2-tiles-plugin/de
> pendency-management.html
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> 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
>


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




Disclaimer: This communication and any files transmitted with it may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is strictly prohibited. If you received this communication in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.

Re: Struts2.x ActionError And ActionMessage

Posted by Adam Brin <ab...@digitalantiquity.org>.
Hi Siva,
  Can you share an example of what you’re doing and what’s not working?

thanks,

adam
-- 
_________________________________________________________
Adam Brin
Director of Technology, Digital Antiquity
480.965.1278

> On Nov 16, 2017, at 8:15 AM, Dhulipudi, Sivannarayana <si...@cgi.com> wrote:
> 
> Hi All,
> 
> I tried to use struts 2.x  ActionError and ActonMessage classes to do validations. 
> 
> I saw a lot examples on internet, in those examples adding errors and messages to actionsupport class like
> 
> addActionErrors() and addActionMessage(). but I want to use ActionError and ActionMessage classes in my project.
> 
> I'm not doing validation in action class . please help me someone on this topic. 
> 
> Thanks
> Siva
> 
> 
> ________________________________________
> From: Lukasz Lenart [lukaszlenart@apache.org]
> Sent: Wednesday, November 15, 2017 11:52 PM
> To: Struts Users Mailing List
> Subject: Re: Migration from Struts1 to Struts2.5
> 
> 2017-11-15 16:26 GMT+01:00 JK <ja...@gmail.com>:
>> struts2-core-2.5.13.jar
>> struts2-tiles-plugin-2.3.8.jar
>> tiles-core-2.0.6.jar
>> tiles-jsp-2.0.6.jar
>> tiles-api-2.0.6.jar
> 
> You are using a wrong version of Tiles, Struts 2.5.13 and the Struts 2
> Tiles plugin based on Tiles 3 - you must use Tiles 3.0.7 at least
> http://struts.apache.org/maven/struts2-plugins/struts2-tiles-plugin/dependency-management.html
> 
> 
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> 
> ---------------------------------------------------------------------
> 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
> 


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


Re: Struts2.x ActionError And ActionMessage

Posted by Lukasz Lenart <lu...@apache.org>.
2017-11-16 16:15 GMT+01:00 Dhulipudi, Sivannarayana
<si...@cgi.com>:
> Hi All,
>
> I tried to use struts 2.x  ActionError and ActonMessage classes to do validations.
>
> I saw a lot examples on internet, in those examples adding errors and messages to actionsupport class like
>
>  addActionErrors() and addActionMessage(). but I want to use ActionError and ActionMessage classes in my project.
>
> I'm not doing validation in action class . please help me someone on this topic.

ActionError and ActionMessage classes were in Struts 1, there is no
such thing in Struts 2.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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