Struts2.x ActionError And ActionMessage

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Struts2.x ActionError And ActionMessage

Dhulipudi, Sivannarayana
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 [[hidden email]]
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 <[hidden email]>:
> 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: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Struts2.x ActionError And ActionMessage

adam brin
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 <[hidden email]> 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 [[hidden email]]
> 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 <[hidden email]>:
>> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Struts2.x ActionError And ActionMessage

Paul Zepernick
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:[hidden email]]
Sent: Thursday, November 16, 2017 10:19 AM
To: Struts Users Mailing List <[hidden email]>
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 <[hidden email]> 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 [[hidden email]]
> 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 <[hidden email]>:
>> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




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: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Struts2.x ActionError And ActionMessage

Dhulipudi, Sivannarayana
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 [[hidden email]]
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:[hidden email]]
Sent: Thursday, November 16, 2017 10:19 AM
To: Struts Users Mailing List <[hidden email]>
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 <[hidden email]> 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 [[hidden email]]
> 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 <[hidden email]>:
>> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Struts2.x ActionError And ActionMessage

Paul Zepernick
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:[hidden email]]
Sent: Thursday, November 16, 2017 11:39 AM
To: Struts Users Mailing List <[hidden email]>
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 [[hidden email]]
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:[hidden email]]
Sent: Thursday, November 16, 2017 10:19 AM
To: Struts Users Mailing List <[hidden email]>
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 <[hidden email]> 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 [[hidden email]]
> 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 <[hidden email]>:
>> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




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: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Struts2.x ActionError And ActionMessage

Yasser Zamani-2
In reply to this post by Dhulipudi, Sivannarayana


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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Struts2.x ActionError And ActionMessage

Yasser Zamani-2
In reply to this post by Dhulipudi, Sivannarayana


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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

AW: Struts2.x ActionError And ActionMessage

Christoph.Nenning
In reply to this post by Dhulipudi, Sivannarayana
>
> 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 [[hidden email]]
> 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:[hidden email]]
> Sent: Thursday, November 16, 2017 10:19 AM
> To: Struts Users Mailing List <[hidden email]>
> 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
> <[hidden email]> 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 [[hidden email]]
> > 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 <[hidden email]>:
> >> 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: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
>
> 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: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Struts2.x ActionError And ActionMessage

Lukasz Lenart
In reply to this post by Dhulipudi, Sivannarayana
2017-11-16 16:15 GMT+01:00 Dhulipudi, Sivannarayana
<[hidden email]>:
> 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: [hidden email]
For additional commands, e-mail: [hidden email]