You should be able to handle this with something like the following

        data.setMessage("this is your error message.")

in the exception handler part of your doBuildTemplate()

you can then use data.setScreenTemplate() to redirect the user to 
whichever error screen you want. currently the default I believe would 
just pull from TurbineResources.getString("template.error")

in your error.vm you should have some code setup with velocity
such as

        #if ( $data.getMessage() )

                <!-- custom error -->
                $data.getMessage()

        #else
                <!-- no message, default error -->
        #end

I have used the error screens in this way when a user
does not validate correctly for certain permissions and
return helpful messages to the user such as they are
trying to access a restricted resource in the
system.

so in my securescreen class for admin functions I have the
following code:

    protected boolean isAuthorized( RunData data )  throws Exception
    {
        boolean isAuthorized = false;

        AccessControlList acl = data.getACL();

        if ( acl.hasRole("admin") )
        {
            isAuthorized = true;

        } else {
            data.setScreenTemplate(
                TurbineResources.getString("template.error"));
            data.setMessage("You do not have access to admin functions.");
            isAuthorized = false;
        }
        return isAuthorized;
    }

This works out pretty nicely for me. I would think you could
probably rework the data.setMessage() to aggregate error messages as well 
if this turns out to be a chain of events that lead to the error, although 
I have not looked into this too heavily. at the moment I just take the 
last error that completes the data.setMessage() and let it override
the super class error messages.

I hope this helps. I'm at the apache con now and will talk to the 
developers at tonights meeting about aggregation of error messages through 
a chain that could then be returned to the error template.

Jeff Painter
[EMAIL PROTECTED]


On Wed, 19 Nov 2003, Naree Song wrote:

> Hello Scott,
> 
> Ok, this is what I want to do.
> Whenever there is an exception and if it was not handled,
> I want the user to be redirected to somewhere instead of being shown
> the java trace stack.
> 
> For example, if the user was trying to access a class that does not exist,
> then they will get this kind of error.
> 
> Horrible Exception: java.lang.ClassNotFoundException:
> Requested Action not found: LoginUsers
>       Turbine looked in the following modules.packages path:
>       [com.me.mepay.modules, org.apache.turbine.flux.modules,
> org.apache.turbine.modules]
> 
>       at
> org.apache.turbine.modules.ActionLoader.getInstance(ActionLoader.java:186)
>       at org.apache.turbine.modules.ActionLoader.exec(ActionLoader.java:134)
>       at
> org.apache.turbine.modules.pages.DefaultPage.doBuild(DefaultPage.java:154)
>       at org.apache.turbine.modules.Page.build(Page.java:91)
>       at org.apache.turbine.modules.PageLoader.exec(PageLoader.java:136)
>       at org.apache.turbine.Turbine.doGet(Turbine.java:796)
> 
> Regards,
> Naree
> --
> Media Equation
> 71 - 73 Thistlethwaite Street
> South Melbourne 3205
> Australia
> Tel:    + 613 9673 8111
> Fax:   + 613 9690 4244
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to