In the former case, which works, you're calling getContext().
getValidationErrors().addGlobalError(..). In the latter case, which does not
work, you're calling getContext().getMessages().add(..). Messages are
displayed by <s:messages/> and errors are displayed by <s:errors/> so it's
not surprising that the error does not display in the latter case. Also note
that messages will show when using a redirect/flash, but validation errors
will not.
-Ben
On Tue, Nov 17, 2009 at 11:07 AM, Potgieter, Derick D <
[email protected]> wrote:
> Hi All,
>
> I need some help on using the* addGlobalError(new
> SimpleError("error"))*function outside of a validation method or i`m just
> missing the point.
>
> When I use the following code:
>
> * @ValidationMethod(on = {"createIntro"})*
> * public void validateAccess(ValidationErrors errors) throws Exception
> {*
> * getContext().getValidationErrors().addGlobalError(new
> SimpleError("error"));*
> * }*
>
> Everything displays fine and my <s:errors/> tag works as expected, nicely
> displaying the error in red.
>
> Here is an example of where i`m trying to use it but fails to display once
> Redirected or Forward`ed:
>
> * @DontValidate*
> * public Resolution createIntro() {*
> * crudMode = Mode.CREATE;*
> * if (!isAuthorizedForCreate()) {*
> * getContext().getMessages().add(new SimpleError("You dont
> have access to create"));*
> * return back();*
> * }*
> * return new ForwardResolution(getCRUDPage());*
> * }*
>
> The page return back to the source resolution but failes to display the
> error. If I replace the code with* getContext().getMessages().add(new
> SimpleMessage("test"))* it displays fine in the <s:messages/> tag.
>
> Not sure if the validation errors get wipes for some strange reason or if
> it is embedded in a @DontValidate method it gets ignored. Any help will be
> appreciated.
>
> Rgds
> Derick
>
> **
>
> **
>
> *Standard Bank email disclaimer and confidentiality note*
>
> Please go to
> http://www.standardbank.co.za/site/homepage/emaildisclaimer.html to read
> our email disclaimer and confidentiality note. Kindly email
> [email protected] (no content or subject line necessary) if
> you cannot view that page and we will email our email disclaimer and
> confidentiality note to you.
>
>
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users