You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "gilbertoca [via click]" <ml...@n2.nabble.com> on 2012/03/12 15:00:26 UTC

Re: Exception handling

Seema wrote
> 
> I want to have a centralized mechanism for showing error messages in my
> pages for exceptions that are thrown to the UI layer. Instead of having a
> single error page across the app, I want to be able to show the error
> message in the same page that caused the error. I tried extending
> ClickServlet and overrided the handleException method where I'm able to
> get the error message corresponding to the exception. I need reference to
> the page object here so that I can set the error message as a bindable,
> but this method only takes the page class as the argument. Can someone
> suggest a solution?
> 

Hi, Seema!

I recommend that you subscribe to the Apache Click mail-list[1].

I've forwarded you question for all community.

Hth,

Gilberto 

[1] http://click.apache.org/docs/click-online.html#mailing-lists


______________________________________
If you reply to this email, your message will be added to the discussion below:
http://click.1134972.n2.nabble.com/Exception-handling-tp7364550p7365359.html
This email was sent by gilbertoca (via Nabble)
To receive all replies by email, subscribe to this discussion: http://click.1134972.n2.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_code&node=7364550&code=ZGV2QGNsaWNrLmFwYWNoZS5vcmd8NzM2NDU1MHw1NzMzMTEwMTU=

Re: Exception handling

Posted by Bob Schellink <sa...@gmail.com>.
Hi Seema,

It might be possible but I haven't done it myself. It might be
possible to construct the same page (using the page class) and use it
instead of the ErrorPage? If you look at the handleException method
you might be able to modify it to your needs?

On the other hand why not use a BorderPage to handle the common error handling?

Hopefully in a future release Click would use an interface instead of
an ErrorPage concept which would have worked nicely for your use case.

regards

Bob

On Tue, Mar 13, 2012 at 3:56 AM, seemarich <se...@gmail.com> wrote:
> hi Bob,
>
> I'm able to catch the exception in my page class and generate a formatted
> error message which I display to the user. This code is common in every page
> and hence I did not want to repeat it in every page class. What I was trying
> to do is handle this centrally by overriding the handleException method of
> ClickServlet and put the error message generation code there and set it into
> a bindable variable of the page object which caused the exception (so that
> it can be displayed to the user). However, I'm not able to navigate to the
> same page and show the message. Is there any way to achieve this?
>
> Thanks,
> Seema
>
> --
> View this message in context: http://click.1134972.n2.nabble.com/Re-Exception-handling-tp7365787p7367351.html
> Sent from the click-development mailing list archive at Nabble.com.

Re: Exception handling

Posted by seemarich <se...@gmail.com>.
hi Bob,

I'm able to catch the exception in my page class and generate a formatted
error message which I display to the user. This code is common in every page
and hence I did not want to repeat it in every page class. What I was trying
to do is handle this centrally by overriding the handleException method of
ClickServlet and put the error message generation code there and set it into
a bindable variable of the page object which caused the exception (so that
it can be displayed to the user). However, I'm not able to navigate to the
same page and show the message. Is there any way to achieve this?

Thanks,
Seema

--
View this message in context: http://click.1134972.n2.nabble.com/Re-Exception-handling-tp7365787p7367351.html
Sent from the click-development mailing list archive at Nabble.com.

Re: Exception handling

Posted by Bob Schellink <sa...@gmail.com>.
Hi Seema,

The Click ErrorPage concept is really meant for exceptions that wasn't anticipated in the 
application, ie RuntimeExceptions. You could always handle checked exceptions explicitly in your 
services and pages ie. create and throw an ApplicationException class.

If you really want to handle RuntimeExceptions in your pages you could stick the exception in the 
session as a flash variable[1][2] and retrieve the message from your page.

regards

Bob

[1]: 
http://click.apache.org/docs/click-api/org/apache/click/Context.html#setFlashAttribute%28java.lang.String,%20java.lang.Object%29
[2]: http://click.avoka.com/click-examples/general/flash.htm



On 12/03/2012 16:00 PM, gilbertoca [via click] wrote:
>     Seema wrote
>     I want to have a centralized mechanism for showing error messages in my pages for exceptions
>     that are thrown to the UI layer. Instead of having a single error page across the app, I want to
>     be able to show the error message in the same page that caused the error. I tried extending
>     ClickServlet and overrided the handleException method where I'm able to get the error message
>     corresponding to the exception. I need reference to the page object here so that I can set the
>     error message as a bindable, but this method only takes the page class as the argument. Can
>     someone suggest a solution?
>
> Hi, Seema!
>
> I recommend that you subscribe to the Apache Click mail-list[1].
>
> I've forwarded you question for all community.
>
> Hth,
>
> Gilberto
>
> [1] http://click.apache.org/docs/click-online.html#mailing-lists
>
> ----------------------------------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion below:
> http://click.1134972.n2.nabble.com/Exception-handling-tp7364550p7365359.html
> This email was sent by gilbertoca
> <http://click.1134972.n2.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=249908> (via Nabble)
> To receive all replies by email, subscribe to this discussion
> <http://click.1134972.n2.nabble.com/template/NamlServlet.jtp?macro=subscribe_by_code&node=7364550&code=ZGV2QGNsaWNrLmFwYWNoZS5vcmd8NzM2NDU1MHw1NzMzMTEwMTU=>