RE: Exception handling wicket 8

2019-02-18 Thread HOPPAN Matúš
Thanks for fast response, ive created quickstart and attached it to JIRA issue
https://issues.apache.org/jira/browse/WICKET-6637

Matus

-Original Message-
From: Martin Grigorov 
Sent: Monday, February 18, 2019 1:49 PM
To: users@wicket.apache.org
Subject: Re: Exception handling wicket 8

Hi,

Sounds like a bug in Wicket.
If you can reproduce it in a quickstart (mini) application then please attach 
it to a ticket in JIRA!
Thanks!

On Mon, Feb 18, 2019 at 2:45 PM HOPPAN Matúš  wrote:

> Hi,
>
> recently we have upgraded our application, from wicket 7.11 to wicket
> 8.3.0.
> With wicket 7 everything seemed to be fine, however in wicket 8 we
> have an issue with handling exception.
> In Application we have in init() method:
> 
> getRequestCycleListeners().add(new
> MyRequestCycleListener());
> 
>
>
> MyRequestCycleListener implements IRequestCycleListener and override
> method
>
>  
> @Override
> public IRequestHandler onException(RequestCycle cycle, Exception ex) {}
>   Optional target = cycle.find(AjaxRequestTarget.class);
>   //this part stopped working since it return Optional.empty(),
> because active RequestHandler
>   //and RequestHandlerScheduledAfterCurrent are both null
> if (target.isPresent()) {
> return target.get();
> }
> IPageRequestHandler last =
> PageRequestHandlerTracker.getLastHandler(RequestCycle.get());
> WebPage page = (WebPage) (last.getPage());
>return new RenderPageRequestHandler(new
> PageProvider(currentPage));
>}
> 
>
> Is this a wicket bug or it was intention to work like this? If it was
> intentended, is there any workaround to get the AjaxRequestTarget? Or
> the approach has changed in wicket 8? Any other ideas?
>
>
> Matus
>
> 
>
> Táto správa je určená iba pre uvedeného príjemcu a môže obsahovať
> dôverné alebo interné informácie. Ak ste ju omylom obdržali,
> upovedomte o tom prosím odosielateľa a vymažte ju. Akýkoľvek iný
> spôsob použitia tohto e-mailu je zakázaný.
>
> This message is for the designated recipient only and may contain
> confidential or internal information. If you have received it in
> error, please notify the sender immediately and delete the original.
> Any other use of the e-mail by you is prohibited.
>



Táto správa je určená iba pre uvedeného príjemcu a môže obsahovať dôverné alebo 
interné informácie. Ak ste ju omylom obdržali, upovedomte o tom prosím 
odosielateľa a vymažte ju. Akýkoľvek iný spôsob použitia tohto e-mailu je 
zakázaný.

This message is for the designated recipient only and may contain confidential 
or internal information. If you have received it in error, please notify the 
sender immediately and delete the original. Any other use of the e-mail by you 
is prohibited.


Re: Exception handling wicket 8

2019-02-18 Thread Martin Grigorov
Hi,

Sounds like a bug in Wicket.
If you can reproduce it in a quickstart (mini) application then please
attach it to a ticket in JIRA!
Thanks!

On Mon, Feb 18, 2019 at 2:45 PM HOPPAN Matúš  wrote:

> Hi,
>
> recently we have upgraded our application, from wicket 7.11 to wicket
> 8.3.0.
> With wicket 7 everything seemed to be fine, however in wicket 8 we have an
> issue
> with handling exception.
> In Application we have in init() method:
> 
> getRequestCycleListeners().add(new
> MyRequestCycleListener());
> 
>
>
> MyRequestCycleListener implements IRequestCycleListener and override method
>
>  
> @Override
> public IRequestHandler onException(RequestCycle cycle, Exception ex) {}
>   Optional target = cycle.find(AjaxRequestTarget.class);
>   //this part stopped working since it return Optional.empty(), because
> active RequestHandler
>   //and RequestHandlerScheduledAfterCurrent are both null
> if (target.isPresent()) {
> return target.get();
> }
> IPageRequestHandler last =
> PageRequestHandlerTracker.getLastHandler(RequestCycle.get());
> WebPage page = (WebPage) (last.getPage());
>return new RenderPageRequestHandler(new
> PageProvider(currentPage));
>}
> 
>
> Is this a wicket bug or it was intention to work like this? If it was
> intentended, is there
> any workaround to get the AjaxRequestTarget? Or the approach has changed
> in wicket 8? Any other ideas?
>
>
> Matus
>
> 
>
> Táto správa je určená iba pre uvedeného príjemcu a môže obsahovať dôverné
> alebo interné informácie. Ak ste ju omylom obdržali, upovedomte o tom
> prosím odosielateľa a vymažte ju. Akýkoľvek iný spôsob použitia tohto
> e-mailu je zakázaný.
>
> This message is for the designated recipient only and may contain
> confidential or internal information. If you have received it in error,
> please notify the sender immediately and delete the original. Any other use
> of the e-mail by you is prohibited.
>


Re: Exception Handling (ajax)

2016-03-09 Thread Sven Meier

Yes, indeed.

Sven

On 09.03.2016 15:43, Lars Törner wrote:

Hi Sven and thanks for your answer!

Ok I see! That's a better solution. I guess it means that I don't have to
set:
getExceptionSettings().setAjaxErrorHandlingStrategy(
AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);

Because we'll never get to the DefaultExceptionMapper (in the case of an
expected unexpected exception).

Cheers
Lars

2016-03-09 10:56 GMT+01:00 Sven Meier :


Hi Lars,


if this is a good or bad way to handle exceptions during ajax requests

I'd keep your IRequestCycleListener and just return new
ErrorCodeRequestHandler(500, message) from there.
No need to fiddle with IExceptionMapper and/or DefaultExceptionMapper.

Have fun
Sven




On 09.03.2016 09:33, Lars Törner wrote:


About exception handling

I would like a fallback for unexcpected exceptions that are thrown during
ajax-calls.

I don't want to redirect to a new page so in my application#init I do:


getExceptionSettings().setAjaxErrorHandlingStrategy(AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);

For the moment I have a request cycle listener for exceptions (added also
in application#init). Which implements #onException but for now does
nothing if an ajax-request is running:
!((WebRequest) requestCycle.getRequest()).isAjax()) -> return null

AjaxErrorStrategy.INVOKE_FAILURE_HANDLER leads to
org.apache.wicket.DefaultExceptionMapper.internalMap(Exception) returns
ErrorCodeRequestHandler(500)

What I would like is to register a global failure handler that via java
script shows a nice toaster with a user friendly message:

Wicket.Event.subscribe('/ajax/call/failure',
function (jqEvent, attributes, jqXHR, errorThrown, textStatus)
{
//TODO Show a fancy toaster with a nice localized user error message
});

ErrorCodeRequestHandler above has also a constructor that takes a message:
ErrorCodeRequestHandler(final int errorCode, final String message)

I guess this can be used to get the nice message to the browser?

So when I write this an do some more thinking my conclusion is that I must
implement my own IExceptionMapper (extending DefaultExceptionMapper?).

I will then create my new ExceptionMapper in MyApplication#init and
override Application#getExceptionMapperProvider() to return it. In my
exception mapper I can check all types of unexpected exeptions my
application might throw and get the corresponding user message to supply
it
to ErrorCodeRequestHandler(final int errorCode, final String message) and
then let failure handler show it in the toaster.

Ok, so now I guess it would be easier to just test this, but the mail is
written so I hope I don´t waste to much of your time by asking if this is
a
good or bad way to handle exceptions during ajax requests.

Cheers
Lasse



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception Handling (ajax)

2016-03-09 Thread Lars Törner
Hi Sven and thanks for your answer!

Ok I see! That's a better solution. I guess it means that I don't have to
set:
getExceptionSettings().setAjaxErrorHandlingStrategy(
AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);

Because we'll never get to the DefaultExceptionMapper (in the case of an
expected unexpected exception).

Cheers
Lars

2016-03-09 10:56 GMT+01:00 Sven Meier :

> Hi Lars,
>
> > if this is a good or bad way to handle exceptions during ajax requests
>
> I'd keep your IRequestCycleListener and just return new
> ErrorCodeRequestHandler(500, message) from there.
> No need to fiddle with IExceptionMapper and/or DefaultExceptionMapper.
>
> Have fun
> Sven
>
>
>
>
> On 09.03.2016 09:33, Lars Törner wrote:
>
>> About exception handling
>>
>> I would like a fallback for unexcpected exceptions that are thrown during
>> ajax-calls.
>>
>> I don't want to redirect to a new page so in my application#init I do:
>>
>>
>> getExceptionSettings().setAjaxErrorHandlingStrategy(AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);
>>
>> For the moment I have a request cycle listener for exceptions (added also
>> in application#init). Which implements #onException but for now does
>> nothing if an ajax-request is running:
>> !((WebRequest) requestCycle.getRequest()).isAjax()) -> return null
>>
>> AjaxErrorStrategy.INVOKE_FAILURE_HANDLER leads to
>> org.apache.wicket.DefaultExceptionMapper.internalMap(Exception) returns
>> ErrorCodeRequestHandler(500)
>>
>> What I would like is to register a global failure handler that via java
>> script shows a nice toaster with a user friendly message:
>>
>> Wicket.Event.subscribe('/ajax/call/failure',
>> function (jqEvent, attributes, jqXHR, errorThrown, textStatus)
>> {
>>//TODO Show a fancy toaster with a nice localized user error message
>> });
>>
>> ErrorCodeRequestHandler above has also a constructor that takes a message:
>> ErrorCodeRequestHandler(final int errorCode, final String message)
>>
>> I guess this can be used to get the nice message to the browser?
>>
>> So when I write this an do some more thinking my conclusion is that I must
>> implement my own IExceptionMapper (extending DefaultExceptionMapper?).
>>
>> I will then create my new ExceptionMapper in MyApplication#init and
>> override Application#getExceptionMapperProvider() to return it. In my
>> exception mapper I can check all types of unexpected exeptions my
>> application might throw and get the corresponding user message to supply
>> it
>> to ErrorCodeRequestHandler(final int errorCode, final String message) and
>> then let failure handler show it in the toaster.
>>
>> Ok, so now I guess it would be easier to just test this, but the mail is
>> written so I hope I don´t waste to much of your time by asking if this is
>> a
>> good or bad way to handle exceptions during ajax requests.
>>
>> Cheers
>> Lasse
>>
>>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Exception Handling (ajax)

2016-03-09 Thread Sven Meier

Hi Lars,

> if this is a good or bad way to handle exceptions during ajax requests

I'd keep your IRequestCycleListener and just return new 
ErrorCodeRequestHandler(500, message) from there.

No need to fiddle with IExceptionMapper and/or DefaultExceptionMapper.

Have fun
Sven



On 09.03.2016 09:33, Lars Törner wrote:

About exception handling

I would like a fallback for unexcpected exceptions that are thrown during
ajax-calls.

I don't want to redirect to a new page so in my application#init I do:

getExceptionSettings().setAjaxErrorHandlingStrategy(AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);

For the moment I have a request cycle listener for exceptions (added also
in application#init). Which implements #onException but for now does
nothing if an ajax-request is running:
!((WebRequest) requestCycle.getRequest()).isAjax()) -> return null

AjaxErrorStrategy.INVOKE_FAILURE_HANDLER leads to
org.apache.wicket.DefaultExceptionMapper.internalMap(Exception) returns
ErrorCodeRequestHandler(500)

What I would like is to register a global failure handler that via java
script shows a nice toaster with a user friendly message:

Wicket.Event.subscribe('/ajax/call/failure',
function (jqEvent, attributes, jqXHR, errorThrown, textStatus)
{
   //TODO Show a fancy toaster with a nice localized user error message
});

ErrorCodeRequestHandler above has also a constructor that takes a message:
ErrorCodeRequestHandler(final int errorCode, final String message)

I guess this can be used to get the nice message to the browser?

So when I write this an do some more thinking my conclusion is that I must
implement my own IExceptionMapper (extending DefaultExceptionMapper?).

I will then create my new ExceptionMapper in MyApplication#init and
override Application#getExceptionMapperProvider() to return it. In my
exception mapper I can check all types of unexpected exeptions my
application might throw and get the corresponding user message to supply it
to ErrorCodeRequestHandler(final int errorCode, final String message) and
then let failure handler show it in the toaster.

Ok, so now I guess it would be easier to just test this, but the mail is
written so I hope I don´t waste to much of your time by asking if this is a
good or bad way to handle exceptions during ajax requests.

Cheers
Lasse




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling in AutoCompleteTextField

2016-01-12 Thread Rakesh A
Hi,

After looking into ajax code a bit, I see that 'Ajax-Location' header is not
considered for autocomplete response.
I created a PR (https://github.com/apache/wicket/pull/156) with a small
change to ajax JavaScript.

Regards,
Rakesh.A

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Exception-handling-in-AutoCompleteTextField-tp4673192p4673272.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling in AutoCompleteTextField

2016-01-08 Thread Martin Grigorov
Hi,

The error handling in Ajax is controlled
via org.apache.wicket.settings.ExceptionSettings#setAjaxErrorHandlingStrategy().
By default it redirects to the error page.
http://examples7x.wicket.apache.org/ajax/links shows both ways.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Wed, Jan 6, 2016 at 10:39 AM, Rakesh A 
wrote:

> Hi,
>
> If we get an exception while preparing suggestions/choices for the entered
> text (in AutoCompleteTextField#getChoices()), I see that, there is no means
> to show it to user.
> JavaScript implementation handles only success responses.
>
> Is there any way to execute standard Ajax response handling, in this case?
>
> Please find attached quick start, try entering 'test' in the autocomplete
> text field on home page.
>
> autocomplete.7z
> 
>
> Regards,
> Rakesh.A
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Exception-handling-in-AutoCompleteTextField-tp4673192.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: Exception handling and testing

2012-09-27 Thread Martin Grigorov
Make the TabbedPanel stateless by using BookmarkablePageLink.

P.S. Please start a new thread when you have new questions.

On Wed, Sep 26, 2012 at 10:56 PM, Alec Swan alecs...@gmail.com wrote:
 Thanks, that worked as advertised. Now I am wondering if it's possible
 to get this to work when the user click on a tab in TabbedPanel?
 RenderPageRequestHandler(new PageProvider(HomePage.class),
 ALWAYS_REDIRECT) seems to lose the knowledge of the tab selected by
 the user and redirects the user to the default tab after he logs in on
 HomePage.

 Thoughts?

 Thanks,

 Alec

 On Wed, Sep 26, 2012 at 12:52 AM, Martin Grigorov mgrigo...@apache.org 
 wrote:
 You have to return a IRequestHandler. See RenderPageRequestHandler

 On Wed, Sep 26, 2012 at 1:45 AM, Alec Swan alecs...@gmail.com wrote:
 I am trying to implement Martin's @SubSite annotation approach to
 redirect the user to the sub-site's home page when
 AuthenticationException is thrown in Wicket 1.5. However, apparently I
 cannot throw a 
 RestartResponseAtInterceptPageException(annotation.homePage())
 from AbstractRequestCycleListener#onException. How else can I redirect
 the user to the sub-site login page?

 The following RCH causes a 500 HTTP error page to be shown in the
 browser when AuthenticationException is thrown.

 public class AuthenticationExceptionRequestCycleHandler extends
 AbstractRequestCycleListener
 {
 @Override
 public IRequestHandler onException(RequestCycle cycle, Exception ex) {
 if (ex instanceof WicketRuntimeException 
 ex.getCause().getCause() instanceof AuthenticationException) {
 IPageRequestHandler lastHandler =
 PageRequestHandlerTracker.getLastHandler(cycle);
 Class? extends IRequestablePage pageClass = lastHandler
 == null ? null : lastHandler.getPageClass();
 if (pageClass != null) {
 SubSite annotation = pageClass.getAnnotation(SubSite.class);
 if (annotation != null  annotation.homePage() != null) {
 throw new
 RestartResponseAtInterceptPageException(annotation.homePage());
 }
 }
 }
 return super.onException(cycle, ex);
 }
 }

 Thanks,

 Alec

 On Fri, Jun 8, 2012 at 2:54 PM, Alec Swan alecs...@gmail.com wrote:
 I also use this approach, but with authentication exceptions thrown by
 Wicket it's hard to tell if the user was redirected to Login page
 because of authentication or some other exceptions.

 On Fri, Jun 8, 2012 at 1:15 PM, Michal Margiel michal.marg...@gmail.com 
 wrote:
 2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


 Hello,
 Why you want to verify that exception was thrown in WicketTester? IMHO it
 is not proper place to check that.
 In my code I am verifying expcetions in services tests using
 catch-exception library [1].

 And then while testing Page I am mocking my service to throw exception and
 I am verifying behaviour on exception (e.g. redirecting to login page,
 showing error message etc...)

 That makes not only clearer code but also simplify testing.
 you can see example of services tests in [2] and page tests in [3]

 [1] http://code.google.com/p/catch-exception/
 [2]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
 [3]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
 --
 Pozdrawiam/Best regards
 Michał Margiel

 http://www.confitura.pl (dawniej Javarsovia)
 http://www.linkedin.com/in/MichalMargiel
 http://www.margiel.eu

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-09-27 Thread Alec Swan
Thanks, works great.

I just needed to convert IRequestParameters to PageParameters in
RequestHandler#onException() in order to remember the tab selection
made by the user throughout login. Is there a convenience method
somewhere in wicket to convert between IRequestParameters and
PageParameters?

Thanks,

Ale

On Thu, Sep 27, 2012 at 1:18 AM, Martin Grigorov mgrigo...@apache.org wrote:
 Make the TabbedPanel stateless by using BookmarkablePageLink.

 P.S. Please start a new thread when you have new questions.

 On Wed, Sep 26, 2012 at 10:56 PM, Alec Swan alecs...@gmail.com wrote:
 Thanks, that worked as advertised. Now I am wondering if it's possible
 to get this to work when the user click on a tab in TabbedPanel?
 RenderPageRequestHandler(new PageProvider(HomePage.class),
 ALWAYS_REDIRECT) seems to lose the knowledge of the tab selected by
 the user and redirects the user to the default tab after he logs in on
 HomePage.

 Thoughts?

 Thanks,

 Alec

 On Wed, Sep 26, 2012 at 12:52 AM, Martin Grigorov mgrigo...@apache.org 
 wrote:
 You have to return a IRequestHandler. See RenderPageRequestHandler

 On Wed, Sep 26, 2012 at 1:45 AM, Alec Swan alecs...@gmail.com wrote:
 I am trying to implement Martin's @SubSite annotation approach to
 redirect the user to the sub-site's home page when
 AuthenticationException is thrown in Wicket 1.5. However, apparently I
 cannot throw a 
 RestartResponseAtInterceptPageException(annotation.homePage())
 from AbstractRequestCycleListener#onException. How else can I redirect
 the user to the sub-site login page?

 The following RCH causes a 500 HTTP error page to be shown in the
 browser when AuthenticationException is thrown.

 public class AuthenticationExceptionRequestCycleHandler extends
 AbstractRequestCycleListener
 {
 @Override
 public IRequestHandler onException(RequestCycle cycle, Exception ex) {
 if (ex instanceof WicketRuntimeException 
 ex.getCause().getCause() instanceof AuthenticationException) {
 IPageRequestHandler lastHandler =
 PageRequestHandlerTracker.getLastHandler(cycle);
 Class? extends IRequestablePage pageClass = lastHandler
 == null ? null : lastHandler.getPageClass();
 if (pageClass != null) {
 SubSite annotation = 
 pageClass.getAnnotation(SubSite.class);
 if (annotation != null  annotation.homePage() != null) {
 throw new
 RestartResponseAtInterceptPageException(annotation.homePage());
 }
 }
 }
 return super.onException(cycle, ex);
 }
 }

 Thanks,

 Alec

 On Fri, Jun 8, 2012 at 2:54 PM, Alec Swan alecs...@gmail.com wrote:
 I also use this approach, but with authentication exceptions thrown by
 Wicket it's hard to tell if the user was redirected to Login page
 because of authentication or some other exceptions.

 On Fri, Jun 8, 2012 at 1:15 PM, Michal Margiel michal.marg...@gmail.com 
 wrote:
 2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


 Hello,
 Why you want to verify that exception was thrown in WicketTester? IMHO it
 is not proper place to check that.
 In my code I am verifying expcetions in services tests using
 catch-exception library [1].

 And then while testing Page I am mocking my service to throw exception 
 and
 I am verifying behaviour on exception (e.g. redirecting to login page,
 showing error message etc...)

 That makes not only clearer code but also simplify testing.
 you can see example of services tests in [2] and page tests in [3]

 [1] http://code.google.com/p/catch-exception/
 [2]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
 [3]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
 --
 Pozdrawiam/Best regards
 Michał Margiel

 http://www.confitura.pl (dawniej Javarsovia)
 http://www.linkedin.com/in/MichalMargiel
 http://www.margiel.eu

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 

Re: Exception handling and testing

2012-09-26 Thread Martin Grigorov
You have to return a IRequestHandler. See RenderPageRequestHandler

On Wed, Sep 26, 2012 at 1:45 AM, Alec Swan alecs...@gmail.com wrote:
 I am trying to implement Martin's @SubSite annotation approach to
 redirect the user to the sub-site's home page when
 AuthenticationException is thrown in Wicket 1.5. However, apparently I
 cannot throw a RestartResponseAtInterceptPageException(annotation.homePage())
 from AbstractRequestCycleListener#onException. How else can I redirect
 the user to the sub-site login page?

 The following RCH causes a 500 HTTP error page to be shown in the
 browser when AuthenticationException is thrown.

 public class AuthenticationExceptionRequestCycleHandler extends
 AbstractRequestCycleListener
 {
 @Override
 public IRequestHandler onException(RequestCycle cycle, Exception ex) {
 if (ex instanceof WicketRuntimeException 
 ex.getCause().getCause() instanceof AuthenticationException) {
 IPageRequestHandler lastHandler =
 PageRequestHandlerTracker.getLastHandler(cycle);
 Class? extends IRequestablePage pageClass = lastHandler
 == null ? null : lastHandler.getPageClass();
 if (pageClass != null) {
 SubSite annotation = pageClass.getAnnotation(SubSite.class);
 if (annotation != null  annotation.homePage() != null) {
 throw new
 RestartResponseAtInterceptPageException(annotation.homePage());
 }
 }
 }
 return super.onException(cycle, ex);
 }
 }

 Thanks,

 Alec

 On Fri, Jun 8, 2012 at 2:54 PM, Alec Swan alecs...@gmail.com wrote:
 I also use this approach, but with authentication exceptions thrown by
 Wicket it's hard to tell if the user was redirected to Login page
 because of authentication or some other exceptions.

 On Fri, Jun 8, 2012 at 1:15 PM, Michal Margiel michal.marg...@gmail.com 
 wrote:
 2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


 Hello,
 Why you want to verify that exception was thrown in WicketTester? IMHO it
 is not proper place to check that.
 In my code I am verifying expcetions in services tests using
 catch-exception library [1].

 And then while testing Page I am mocking my service to throw exception and
 I am verifying behaviour on exception (e.g. redirecting to login page,
 showing error message etc...)

 That makes not only clearer code but also simplify testing.
 you can see example of services tests in [2] and page tests in [3]

 [1] http://code.google.com/p/catch-exception/
 [2]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
 [3]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
 --
 Pozdrawiam/Best regards
 Michał Margiel

 http://www.confitura.pl (dawniej Javarsovia)
 http://www.linkedin.com/in/MichalMargiel
 http://www.margiel.eu

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-09-26 Thread Alec Swan
Thanks, that worked as advertised. Now I am wondering if it's possible
to get this to work when the user click on a tab in TabbedPanel?
RenderPageRequestHandler(new PageProvider(HomePage.class),
ALWAYS_REDIRECT) seems to lose the knowledge of the tab selected by
the user and redirects the user to the default tab after he logs in on
HomePage.

Thoughts?

Thanks,

Alec

On Wed, Sep 26, 2012 at 12:52 AM, Martin Grigorov mgrigo...@apache.org wrote:
 You have to return a IRequestHandler. See RenderPageRequestHandler

 On Wed, Sep 26, 2012 at 1:45 AM, Alec Swan alecs...@gmail.com wrote:
 I am trying to implement Martin's @SubSite annotation approach to
 redirect the user to the sub-site's home page when
 AuthenticationException is thrown in Wicket 1.5. However, apparently I
 cannot throw a RestartResponseAtInterceptPageException(annotation.homePage())
 from AbstractRequestCycleListener#onException. How else can I redirect
 the user to the sub-site login page?

 The following RCH causes a 500 HTTP error page to be shown in the
 browser when AuthenticationException is thrown.

 public class AuthenticationExceptionRequestCycleHandler extends
 AbstractRequestCycleListener
 {
 @Override
 public IRequestHandler onException(RequestCycle cycle, Exception ex) {
 if (ex instanceof WicketRuntimeException 
 ex.getCause().getCause() instanceof AuthenticationException) {
 IPageRequestHandler lastHandler =
 PageRequestHandlerTracker.getLastHandler(cycle);
 Class? extends IRequestablePage pageClass = lastHandler
 == null ? null : lastHandler.getPageClass();
 if (pageClass != null) {
 SubSite annotation = pageClass.getAnnotation(SubSite.class);
 if (annotation != null  annotation.homePage() != null) {
 throw new
 RestartResponseAtInterceptPageException(annotation.homePage());
 }
 }
 }
 return super.onException(cycle, ex);
 }
 }

 Thanks,

 Alec

 On Fri, Jun 8, 2012 at 2:54 PM, Alec Swan alecs...@gmail.com wrote:
 I also use this approach, but with authentication exceptions thrown by
 Wicket it's hard to tell if the user was redirected to Login page
 because of authentication or some other exceptions.

 On Fri, Jun 8, 2012 at 1:15 PM, Michal Margiel michal.marg...@gmail.com 
 wrote:
 2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


 Hello,
 Why you want to verify that exception was thrown in WicketTester? IMHO it
 is not proper place to check that.
 In my code I am verifying expcetions in services tests using
 catch-exception library [1].

 And then while testing Page I am mocking my service to throw exception and
 I am verifying behaviour on exception (e.g. redirecting to login page,
 showing error message etc...)

 That makes not only clearer code but also simplify testing.
 you can see example of services tests in [2] and page tests in [3]

 [1] http://code.google.com/p/catch-exception/
 [2]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
 [3]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
 --
 Pozdrawiam/Best regards
 Michał Margiel

 http://www.confitura.pl (dawniej Javarsovia)
 http://www.linkedin.com/in/MichalMargiel
 http://www.margiel.eu

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-09-25 Thread Alec Swan
I am trying to implement Martin's @SubSite annotation approach to
redirect the user to the sub-site's home page when
AuthenticationException is thrown in Wicket 1.5. However, apparently I
cannot throw a RestartResponseAtInterceptPageException(annotation.homePage())
from AbstractRequestCycleListener#onException. How else can I redirect
the user to the sub-site login page?

The following RCH causes a 500 HTTP error page to be shown in the
browser when AuthenticationException is thrown.

public class AuthenticationExceptionRequestCycleHandler extends
AbstractRequestCycleListener
{
@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
if (ex instanceof WicketRuntimeException 
ex.getCause().getCause() instanceof AuthenticationException) {
IPageRequestHandler lastHandler =
PageRequestHandlerTracker.getLastHandler(cycle);
Class? extends IRequestablePage pageClass = lastHandler
== null ? null : lastHandler.getPageClass();
if (pageClass != null) {
SubSite annotation = pageClass.getAnnotation(SubSite.class);
if (annotation != null  annotation.homePage() != null) {
throw new
RestartResponseAtInterceptPageException(annotation.homePage());
}
}
}
return super.onException(cycle, ex);
}
}

Thanks,

Alec

On Fri, Jun 8, 2012 at 2:54 PM, Alec Swan alecs...@gmail.com wrote:
 I also use this approach, but with authentication exceptions thrown by
 Wicket it's hard to tell if the user was redirected to Login page
 because of authentication or some other exceptions.

 On Fri, Jun 8, 2012 at 1:15 PM, Michal Margiel michal.marg...@gmail.com 
 wrote:
 2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


 Hello,
 Why you want to verify that exception was thrown in WicketTester? IMHO it
 is not proper place to check that.
 In my code I am verifying expcetions in services tests using
 catch-exception library [1].

 And then while testing Page I am mocking my service to throw exception and
 I am verifying behaviour on exception (e.g. redirecting to login page,
 showing error message etc...)

 That makes not only clearer code but also simplify testing.
 you can see example of services tests in [2] and page tests in [3]

 [1] http://code.google.com/p/catch-exception/
 [2]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
 [3]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
 --
 Pozdrawiam/Best regards
 Michał Margiel

 http://www.confitura.pl (dawniej Javarsovia)
 http://www.linkedin.com/in/MichalMargiel
 http://www.margiel.eu

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: exception handling (get cause page)

2012-09-04 Thread Alfonso Quiroga
It works perfectly thanks

On Mon, Sep 3, 2012 at 3:11 PM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 See 
 https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/request/cycle/PageRequestHandlerTracker.java
 Register it, then use it:
 PageRequestHandlerTracker.getLastHandler(cycle).getPage()


 On Mon, Sep 3, 2012 at 8:00 PM, Alfonso Quiroga alfonsose...@gmail.com 
 wrote:
 Hi! I have a custom exception handler, and I have this method:

 onException(RequestCycle cycle, Exception anException) {
   
 }


 Inside this method, how can I get the original page who caused the
 exception? in other Wicket version, I had  onRuntimeException
 method, who already had the original page.

 Thanks in advance!

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: exception handling (get cause page)

2012-09-03 Thread Martin Grigorov
Hi,

See 
https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/request/cycle/PageRequestHandlerTracker.java
Register it, then use it:
PageRequestHandlerTracker.getLastHandler(cycle).getPage()


On Mon, Sep 3, 2012 at 8:00 PM, Alfonso Quiroga alfonsose...@gmail.com wrote:
 Hi! I have a custom exception handler, and I have this method:

 onException(RequestCycle cycle, Exception anException) {
   
 }


 Inside this method, how can I get the original page who caused the
 exception? in other Wicket version, I had  onRuntimeException
 method, who already had the original page.

 Thanks in advance!

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-06-08 Thread Alec Swan
That's clever. I will give it a try.

What is the recommendation on verifying that an exception was thrown
during page rendering using Wicket tester? I am not talking just about
authentication here, but exceptions in general.

Thanks,

Alec

On Thu, Jun 7, 2012 at 6:18 PM, Martin Grigorov mgrigo...@apache.org wrote:
 On Fri, Jun 8, 2012 at 12:37 AM, Alec Swan alecs...@gmail.com wrote:
 I am also asking how to redirect to sub-site's home page when the user
 is not authenticated and tries to access on of those sub-site pages.

 Use a custom IAuthenticationStrategy that knows which pages are part
 of this sub-site (e.g. you can annotate them with a special @SubSite)
 and
 if the user is not logged in then redirect to @SubSite.homePage class.
 This way even every page can it have its own home page.


 On Thu, Jun 7, 2012 at 3:35 PM, Alec Swan alecs...@gmail.com wrote:
 The problem is that I cannot verify this exception in tests. I am
 basically asking for best practices.

 Thanks!

 On Thu, Jun 7, 2012 at 1:30 AM, Martin Grigorov mgrigo...@apache.org 
 wrote:
 Hi,

 You can use IAuthenticationStrategy and throw
 RestartResponseAtInterceptException.

 On Wed, Jun 6, 2012 at 8:09 PM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 I am creating a new set of pages that are a part of an old project but
 have a different home page. It's kind of like a sub-site within a
 site. The user is required to log in on the sub-site's home page to be
 able to access any of those pages. If the user tries to access any of
 these pages directly he should be redirected to the sub-site's home
 page.

 What's the best way to implement/configure the home page for this 
 sub-site?
 What kind of exception should each sub-site page throw to trigger
 redirection to home page?
 How can I verify that an exception was thrown in my test? (Currently I
 have a test which calls startPanel(..) which logs an exception if the
 user is not logged in, but returns with no errors. So, I have to
 verify that the rendered page is what it should be.)

 I am basically looking for best practices here.

 Thanks,

 Alec

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-06-08 Thread Michal Margiel
2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


Hello,
Why you want to verify that exception was thrown in WicketTester? IMHO it
is not proper place to check that.
In my code I am verifying expcetions in services tests using
catch-exception library [1].

And then while testing Page I am mocking my service to throw exception and
I am verifying behaviour on exception (e.g. redirecting to login page,
showing error message etc...)

That makes not only clearer code but also simplify testing.
you can see example of services tests in [2] and page tests in [3]

[1] http://code.google.com/p/catch-exception/
[2]
https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
[3]
https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
-- 
Pozdrawiam/Best regards
Michał Margiel

http://www.confitura.pl (dawniej Javarsovia)
http://www.linkedin.com/in/MichalMargiel
http://www.margiel.eu


Re: Exception handling and testing

2012-06-08 Thread Alec Swan
I also use this approach, but with authentication exceptions thrown by
Wicket it's hard to tell if the user was redirected to Login page
because of authentication or some other exceptions.

On Fri, Jun 8, 2012 at 1:15 PM, Michal Margiel michal.marg...@gmail.com wrote:
 2012/6/8 Alec Swan alecs...@gmail.com

 That's clever. I will give it a try.

 What is the recommendation on verifying that an exception was thrown
 during page rendering using Wicket tester? I am not talking just about
 authentication here, but exceptions in general.


 Hello,
 Why you want to verify that exception was thrown in WicketTester? IMHO it
 is not proper place to check that.
 In my code I am verifying expcetions in services tests using
 catch-exception library [1].

 And then while testing Page I am mocking my service to throw exception and
 I am verifying behaviour on exception (e.g. redirecting to login page,
 showing error message etc...)

 That makes not only clearer code but also simplify testing.
 you can see example of services tests in [2] and page tests in [3]

 [1] http://code.google.com/p/catch-exception/
 [2]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/services/UserServiceImplShould.java
 [3]
 https://bitbucket.org/margielm/confitura/src/8599eae2ba00/src/test/java/jelatyna/pages/admin/login/LoginPageShould.java
 --
 Pozdrawiam/Best regards
 Michał Margiel

 http://www.confitura.pl (dawniej Javarsovia)
 http://www.linkedin.com/in/MichalMargiel
 http://www.margiel.eu

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-06-07 Thread Martin Grigorov
Hi,

You can use IAuthenticationStrategy and throw
RestartResponseAtInterceptException.

On Wed, Jun 6, 2012 at 8:09 PM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 I am creating a new set of pages that are a part of an old project but
 have a different home page. It's kind of like a sub-site within a
 site. The user is required to log in on the sub-site's home page to be
 able to access any of those pages. If the user tries to access any of
 these pages directly he should be redirected to the sub-site's home
 page.

 What's the best way to implement/configure the home page for this sub-site?
 What kind of exception should each sub-site page throw to trigger
 redirection to home page?
 How can I verify that an exception was thrown in my test? (Currently I
 have a test which calls startPanel(..) which logs an exception if the
 user is not logged in, but returns with no errors. So, I have to
 verify that the rendered page is what it should be.)

 I am basically looking for best practices here.

 Thanks,

 Alec

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-06-07 Thread Alec Swan
The problem is that I cannot verify this exception in tests. I am
basically asking for best practices.

Thanks!

On Thu, Jun 7, 2012 at 1:30 AM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 You can use IAuthenticationStrategy and throw
 RestartResponseAtInterceptException.

 On Wed, Jun 6, 2012 at 8:09 PM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 I am creating a new set of pages that are a part of an old project but
 have a different home page. It's kind of like a sub-site within a
 site. The user is required to log in on the sub-site's home page to be
 able to access any of those pages. If the user tries to access any of
 these pages directly he should be redirected to the sub-site's home
 page.

 What's the best way to implement/configure the home page for this sub-site?
 What kind of exception should each sub-site page throw to trigger
 redirection to home page?
 How can I verify that an exception was thrown in my test? (Currently I
 have a test which calls startPanel(..) which logs an exception if the
 user is not logged in, but returns with no errors. So, I have to
 verify that the rendered page is what it should be.)

 I am basically looking for best practices here.

 Thanks,

 Alec

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-06-07 Thread Alec Swan
I am also asking how to redirect to sub-site's home page when the user
is not authenticated and tries to access on of those sub-site pages.

On Thu, Jun 7, 2012 at 3:35 PM, Alec Swan alecs...@gmail.com wrote:
 The problem is that I cannot verify this exception in tests. I am
 basically asking for best practices.

 Thanks!

 On Thu, Jun 7, 2012 at 1:30 AM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 You can use IAuthenticationStrategy and throw
 RestartResponseAtInterceptException.

 On Wed, Jun 6, 2012 at 8:09 PM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 I am creating a new set of pages that are a part of an old project but
 have a different home page. It's kind of like a sub-site within a
 site. The user is required to log in on the sub-site's home page to be
 able to access any of those pages. If the user tries to access any of
 these pages directly he should be redirected to the sub-site's home
 page.

 What's the best way to implement/configure the home page for this sub-site?
 What kind of exception should each sub-site page throw to trigger
 redirection to home page?
 How can I verify that an exception was thrown in my test? (Currently I
 have a test which calls startPanel(..) which logs an exception if the
 user is not logged in, but returns with no errors. So, I have to
 verify that the rendered page is what it should be.)

 I am basically looking for best practices here.

 Thanks,

 Alec

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling and testing

2012-06-07 Thread Martin Grigorov
On Fri, Jun 8, 2012 at 12:37 AM, Alec Swan alecs...@gmail.com wrote:
 I am also asking how to redirect to sub-site's home page when the user
 is not authenticated and tries to access on of those sub-site pages.

Use a custom IAuthenticationStrategy that knows which pages are part
of this sub-site (e.g. you can annotate them with a special @SubSite)
and
if the user is not logged in then redirect to @SubSite.homePage class.
This way even every page can it have its own home page.


 On Thu, Jun 7, 2012 at 3:35 PM, Alec Swan alecs...@gmail.com wrote:
 The problem is that I cannot verify this exception in tests. I am
 basically asking for best practices.

 Thanks!

 On Thu, Jun 7, 2012 at 1:30 AM, Martin Grigorov mgrigo...@apache.org wrote:
 Hi,

 You can use IAuthenticationStrategy and throw
 RestartResponseAtInterceptException.

 On Wed, Jun 6, 2012 at 8:09 PM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 I am creating a new set of pages that are a part of an old project but
 have a different home page. It's kind of like a sub-site within a
 site. The user is required to log in on the sub-site's home page to be
 able to access any of those pages. If the user tries to access any of
 these pages directly he should be redirected to the sub-site's home
 page.

 What's the best way to implement/configure the home page for this sub-site?
 What kind of exception should each sub-site page throw to trigger
 redirection to home page?
 How can I verify that an exception was thrown in my test? (Currently I
 have a test which calls startPanel(..) which logs an exception if the
 user is not logged in, but returns with no errors. So, I have to
 verify that the rendered page is what it should be.)

 I am basically looking for best practices here.

 Thanks,

 Alec

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception Handling in 1.5

2011-11-17 Thread Nelson Segura
Hey, any idea how can I get the page/page class of the page that was
being rendered when the exception happened?
I was depending on that in 1.4 to determine the type of page I needed
to return, for example if I am in the context of a modal window, I was
showing a message in the window, and a close button. If I was in a
normal page, I was showing the full error page with errors et all.
I tried

Class pageClass =
((IPageClassRequestHandler)cycle.getActiveRequestHandler()).getPageClass();

But that throws an NPE

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception Handling in 1.5

2011-11-17 Thread Igor Vaynberg
hrm. you cant yet. but you can check if you are in an ajax request or
not by using webrequest.isajax() so you can implement that particular
usecase without the page.

-igor

On Thu, Nov 17, 2011 at 1:19 PM, Nelson Segura nsegu...@gmail.com wrote:
 Hey, any idea how can I get the page/page class of the page that was
 being rendered when the exception happened?
 I was depending on that in 1.4 to determine the type of page I needed
 to return, for example if I am in the context of a modal window, I was
 showing a message in the window, and a close button. If I was in a
 normal page, I was showing the full error page with errors et all.
 I tried

 Class pageClass =
 ((IPageClassRequestHandler)cycle.getActiveRequestHandler()).getPageClass();

 But that throws an NPE

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception Handling in 1.5

2011-11-16 Thread Nelson Segura
Great. Thanks for your help.

On Mon, Nov 14, 2011 at 7:06 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 application.getrequestcyclelisteners().add(new abstractrequestcyclelistener() 
 {
  irequsthandler onexception(e) {
       Throwable cause = e;
       if (cause instanceof WicketRuntimeException) {
           cause = cause.getCause();
       }

       if (cause instanceof InvocationTargetException) {
           cause = cause.getCause();
       }

       if (cause instanceof WicketResourceGoneException
               || cause instanceof ResourceGoneException) {
           return new renderpagerequesthandler(new
 ResourceGonePage((WicketResourceGoneException)cause));
       }

       if (cause instanceof ResourceNotFoundException) {
           return new renderpagerequesthandler(new
 NotFoundPage((ResourceNotFoundException)cause));
       }
 });

 -igor

 On Mon, Nov 14, 2011 at 3:34 PM, Nelson Segura nsegu...@gmail.com wrote:
 Hello,
 I am starting to migrate from 1.4 to 1.5.
 I am having problems trying to figure out exactly what is the best way
 to do the following.

 I have some custom exception and some custom pages for when the code
 throws those exception. In 1.4 this seemed trivial. For example


 ..

 public class MyRequestLifecycle extends WebRequestCycle {

    public MyRequestLifecycle(org.apache.wicket.protocol.http.WebApplication
 application,
                                         WebRequest request,
                                         Response response) {
        super(application, request, response);
    }

    @Override
    public Page onRuntimeException(Page page, RuntimeException e) {
        Throwable cause = e;
        if (cause instanceof WicketRuntimeException) {
            cause = cause.getCause();
        }

        if (cause instanceof InvocationTargetException) {
            cause = cause.getCause();
        }

        if (cause instanceof WicketResourceGoneException
                || cause instanceof ResourceGoneException) {
            return new ResourceGonePage((WicketResourceGoneException)cause);
        }

        if (cause instanceof ResourceNotFoundException) {
            return new NotFoundPage((ResourceNotFoundException)cause);
        }
        return super.onRuntimeException(page, e);
    }

 }


 But I can't figure out a clean / easy way to do this in 1.5. I seems
 that I need to write a lot of code to accomplish this.

 I am looking at the following links:

 https://cwiki.apache.org/WICKET/migration-to-wicket-15.html
 https://cwiki.apache.org/WICKET/requestcycle-in-wicket-15.html

 Problems are:
 - Which class should I be extend or implementing.
 AbstractRequestCycleListener? IExceptionMapper? IRequestHandler?
 - How do I get access to the current page?
 If I return a IRequestHandler, how do I create one. Do I need to
 create one? Can I use the current one? do I need to worry if this is
 part of an AjaxRequest? I have looked at code in
 AbstractRequestCycleListener, SystemMapper, CompoundRequestMapper,
 DefaultExceptionMapper, etc. It all seems too low level compared to
 other Wicket APIs, that makes me think I am missing something.

 What should I do?

 -Nelson

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception Handling in 1.5

2011-11-14 Thread Igor Vaynberg
application.getrequestcyclelisteners().add(new abstractrequestcyclelistener() {
  irequsthandler onexception(e) {
   Throwable cause = e;
   if (cause instanceof WicketRuntimeException) {
   cause = cause.getCause();
   }

   if (cause instanceof InvocationTargetException) {
   cause = cause.getCause();
   }

   if (cause instanceof WicketResourceGoneException
   || cause instanceof ResourceGoneException) {
   return new renderpagerequesthandler(new
ResourceGonePage((WicketResourceGoneException)cause));
   }

   if (cause instanceof ResourceNotFoundException) {
   return new renderpagerequesthandler(new
NotFoundPage((ResourceNotFoundException)cause));
   }
});

-igor

On Mon, Nov 14, 2011 at 3:34 PM, Nelson Segura nsegu...@gmail.com wrote:
 Hello,
 I am starting to migrate from 1.4 to 1.5.
 I am having problems trying to figure out exactly what is the best way
 to do the following.

 I have some custom exception and some custom pages for when the code
 throws those exception. In 1.4 this seemed trivial. For example


 ..

 public class MyRequestLifecycle extends WebRequestCycle {

    public MyRequestLifecycle(org.apache.wicket.protocol.http.WebApplication
 application,
                                         WebRequest request,
                                         Response response) {
        super(application, request, response);
    }

    @Override
    public Page onRuntimeException(Page page, RuntimeException e) {
        Throwable cause = e;
        if (cause instanceof WicketRuntimeException) {
            cause = cause.getCause();
        }

        if (cause instanceof InvocationTargetException) {
            cause = cause.getCause();
        }

        if (cause instanceof WicketResourceGoneException
                || cause instanceof ResourceGoneException) {
            return new ResourceGonePage((WicketResourceGoneException)cause);
        }

        if (cause instanceof ResourceNotFoundException) {
            return new NotFoundPage((ResourceNotFoundException)cause);
        }
        return super.onRuntimeException(page, e);
    }

 }


 But I can't figure out a clean / easy way to do this in 1.5. I seems
 that I need to write a lot of code to accomplish this.

 I am looking at the following links:

 https://cwiki.apache.org/WICKET/migration-to-wicket-15.html
 https://cwiki.apache.org/WICKET/requestcycle-in-wicket-15.html

 Problems are:
 - Which class should I be extend or implementing.
 AbstractRequestCycleListener? IExceptionMapper? IRequestHandler?
 - How do I get access to the current page?
 If I return a IRequestHandler, how do I create one. Do I need to
 create one? Can I use the current one? do I need to worry if this is
 part of an AjaxRequest? I have looked at code in
 AbstractRequestCycleListener, SystemMapper, CompoundRequestMapper,
 DefaultExceptionMapper, etc. It all seems too low level compared to
 other Wicket APIs, that makes me think I am missing something.

 What should I do?

 -Nelson

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling for components inside a page

2010-10-01 Thread Igor Vaynberg
no, there isnt. exceptions that occur during render time are very hard
to recover from. what you can do is place every panel into an iframe.

-igor

On Fri, Oct 1, 2010 at 7:14 AM, Rui Fernando Hayashi
rui.haya...@tecsinapse.com.br wrote:
 I have a Wicket page which is a dashboard composed of a number of
 panels. The actual panels are only known in runtime and are added to a
 RepeatingView. That's because I have a modular application, and each
 module can contribute panels to the dashboard. The modularity issue is
 well solved and working as expected. My problem is when any of the
 panels throws an Exception. In that case Wicket directs me to my error
 page. I would like to be able to handle the exception on the panel
 level and just replace the panel area with some error notification,
 but the other panels would still be shown. That way I have to find out
 what's going on with that panel, but the users can still use the rest
 of the dashboard.

 Is there any hook point where I could include a handler? I can control
 the instantiation of the panel, but I would still have to handle any
 exception during the render phase, but I can't figure out where I
 could do this.

 Best Regards

 --
 Rui Fernando Hayashi

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: EXception handling in Wicket

2010-08-29 Thread Nitnatsnok


arunarapole wrote:
 
 Thank you for replay i am very glad you have sent me the sample code thank
 you so much
 
 My problem is i have to handle SQLException and only message  to be
 display
 in hidden field  same webpage
 
 do u have any idea regarding this
 
 Aruna
 
 

It depends.
Is your exception thrown in an ajax call or a form submit?

In your WebRequestCycle.onRuntimeException you have two parameters: page on
which exception was thrown and which exception was thrown.

If your runtime exception was SQLException then you can access any element
on your page and set any value to it.

Next you can update an element on page if it's AJAX or show this page again
by returning updated page.

You can get your ajax target this way:
(AjaxRequestTarget)RequestCycle.get().getRequestTarget().

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2399426.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: EXception handling in Wicket

2010-08-29 Thread Nitnatsnok


Antoine van Wel wrote:
 
 I think you should prevent that SQLException from happening in the first
 place by validating the form input.
 Then use a FeedbackPanel to display suitable error messages. Just google
 for
 example code with forms, it's basic stuff.
 
 Otherwise, create a FeedbackPanel on your page, put a try .. catch block
 around your sql methods and in case of an exception, write to the
 FeedbackPanel using error(your message)
 
 

I agree with you, catching Runtime exceptions in WebRequestCycle should not
be a part of normal workflow.
I use this thing only to display critical failures information.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2399427.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: EXception handling in Wicket

2010-08-28 Thread Antoine van Wel
I think you should prevent that SQLException from happening in the first
place by validating the form input.
Then use a FeedbackPanel to display suitable error messages. Just google for
example code with forms, it's basic stuff.

Otherwise, create a FeedbackPanel on your page, put a try .. catch block
around your sql methods and in case of an exception, write to the
FeedbackPanel using error(your message)



Antoine


On Fri, Aug 27, 2010 at 3:02 PM, arunarapole arunakumm...@gmail.com wrote:


 Thank you for replay i am very glad you have sent me the sample code thank
 you so much

 My problem is i have to handle SQLException and only message  to be display
 in hidden field  same webpage

 do u have any idea regarding this

 Aruna

 On Thu, Aug 26, 2010 at 10:14 PM, Nitnatsnok [via Apache Wicket] 
 ml-node+2340562-650873628-136...@n4.nabble.comml-node%2b2340562-650873628-136...@n4.nabble.com
 ml-node%2b2340562-650873628-136...@n4.nabble.comml-node%252b2340562-650873628-136...@n4.nabble.com
 
  wrote:

  Oh, also I set not to show Error Page on exception in WebApplication:
 
 
 getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_NO_EXCEPTION_PAGE);
 
 
  --
   View message @
 
 http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2340562.html
  To unsubscribe from EXception handling in Wicket, click here
 http://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2340439code=YXJ1bmFrdW1tYXJpQGdtYWlsLmNvbXwyMzQwNDM5fC00Njg4NjYxODg=
 .
 
 
 


 --


 Regards
 Aruna.R
 404-988-5562

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2341035.html
 Sent from the Wicket - User mailing list archive at Nabble.com.



Re: EXception handling in Wicket

2010-08-27 Thread arunarapole

Thank you for replay i am very glad you have sent me the sample code thank
you so much

My problem is i have to handle SQLException and only message  to be display
in hidden field  same webpage

do u have any idea regarding this

Aruna

On Thu, Aug 26, 2010 at 10:14 PM, Nitnatsnok [via Apache Wicket] 
ml-node+2340562-650873628-136...@n4.nabble.comml-node%2b2340562-650873628-136...@n4.nabble.com
 wrote:

 Oh, also I set not to show Error Page on exception in WebApplication:

 getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_NO_EXCEPTION_PAGE);


 --
  View message @
 http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2340562.html
 To unsubscribe from EXception handling in Wicket, click 
 herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2340439code=YXJ1bmFrdW1tYXJpQGdtYWlsLmNvbXwyMzQwNDM5fC00Njg4NjYxODg=.





-- 


Regards
Aruna.R
404-988-5562

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2341035.html
Sent from the Wicket - User mailing list archive at Nabble.com.


Re: EXception handling in Wicket

2010-08-26 Thread Nitnatsnok

Hi, I don't know if it is a proper way but this is how I did it.

1. Extended WebRequestCycle

@Override
public Page onRuntimeException(Page page, RuntimeException e) {
// if error was during application running e.g. when Home page was
loaded and if it was an ajax request that caused problem
if (page instanceof Home  RequestCycle.get().getRequestTarget()
instanceof AjaxRequestTarget) {
// On my Home page there is a js ModalWindow into which I place
the error text
ModalWindow errorPage = (ModalWindow)page.get(modalErrorPage);
final ResourceModel message = new
ResourceModel(gorillaUrlError);
errorPage.setContent( ... );
   
errorPage.show((AjaxRequestTarget)RequestCycle.get().getRequestTarget());
}
return null;

2. Extended WebRequestCycleProcessor to comment out placing 500 error code
into Ajax response.

@Override
public void respond(RuntimeException e, RequestCycle requestCycle)
{
// If application doesn't want debug info showing up for users
final Application application = Application.get();
final IExceptionSettings settings =
application.getExceptionSettings();
final Page responsePage = requestCycle.getResponsePage();

Page override = onRuntimeException(responsePage, e);
if (override != null)
{
throw new RestartResponseException(override);
}
else if (e instanceof AuthorizationException)
{
// are authorization exceptions always thrown before the real
// render?
// else we need to make a page (see below) or set it hard to a
// redirect.
Class? extends Page accessDeniedPageClass =
application.getApplicationSettings()
.getAccessDeniedPage();

throw new
RestartResponseAtInterceptPageException(accessDeniedPageClass);
}
else if (e instanceof PageExpiredException)
{
Class? extends Page pageExpiredErrorPageClass =
application.getApplicationSettings()
.getPageExpiredErrorPage();
boolean mounted = isPageMounted(pageExpiredErrorPageClass);
RequestCycle.get().setRedirect(mounted);
throw new RestartResponseException(pageExpiredErrorPageClass);
}
else if (settings.getUnexpectedExceptionDisplay() !=
IExceptionSettings.SHOW_NO_EXCEPTION_PAGE)
{
// we do not want to redirect - we want to inline the error
output
// and preserve the url so when the refresh button is pressed we
// rerun the code that caused the error
// However we don't what to do this in a situation where we are
in portlet mode
if (!RequestContext.get().isPortletRequest())
{
requestCycle.setRedirect(false);
}

// figure out which error page to show
Class? extends Page internalErrorPageClass =
application.getApplicationSettings()
.getInternalErrorPage();
Class? extends Page responseClass = responsePage != null ?
responsePage.getClass()
: null;

if (responseClass != internalErrorPageClass 
settings.getUnexpectedExceptionDisplay() ==
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
{
throw new RestartResponseException(internalErrorPageClass);
}
else if (responseClass != ExceptionErrorPage.class)
{
// Show full details
throw new RestartResponseException(new ExceptionErrorPage(e,
responsePage));
}
else
{
// give up while we're ahead!
throw new WicketRuntimeException(Internal Error: Could not
render error page  +
internalErrorPageClass, e);
}
}
else if (requestCycle.getResponse() instanceof WebResponse)
{
// commented out so that error code is not set to header
// it was set in case of runtime Java exception and
SHOW_NO_EXCEPTION_PAGE option of application
//   
((WebResponse)requestCycle.getResponse()).getHttpServletResponse().setStatus(
//HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}

3. Overridden 2 methods in WebApplication
public RequestCycle newRequestCycle(Request request, Response response) {
protected IRequestCycleProcessor newRequestCycleProcessor() {


That's it.
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2340560.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: EXception handling in Wicket

2010-08-26 Thread Nitnatsnok

Oh, also I set not to show Error Page on exception in WebApplication:

getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_NO_EXCEPTION_PAGE);
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2340562.html
Sent from the Wicket - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Exception handling

2009-11-15 Thread Jeremy Thomerson
In your application:

@Override
public RequestCycle newRequestCycle(Request request, Response response)
{
return new WebRequestCycle(this, (WebRequest) request, response) {
@Override
public Page onRuntimeException(Page page, RuntimeException e) {
return super.onRuntimeException(page, e);
}
};
}


--
Jeremy Thomerson
http://www.wickettraining.com



2009/11/15 Wojtek zabia...@gmail.com

 Hi there,
 I'd like to find out how the development mechanism of exception handling
 works.
 It displays  stacktrace from exception thrown, so it means it has access to
 the Exception object.
 I would like to implement similar feature, to display at least the message
 from the exception to the end user.
 Could you tell me how to do it or point the name of class shown where the
 exception is thrown in development mode?
 BTW. I know how to set internal exception page :)

 Regards,
 Wojtek

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Exception handling

2009-11-15 Thread Wojtek

That's exactly what I need. Thanks a lot.
Regards,
Wojtek


Jeremy Thomerson pisze:

In your application:

@Override
public RequestCycle newRequestCycle(Request request, Response response)
{
return new WebRequestCycle(this, (WebRequest) request, response) {
@Override
public Page onRuntimeException(Page page, RuntimeException e) {
return super.onRuntimeException(page, e);
}
};
}


--
Jeremy Thomerson
http://www.wickettraining.com



2009/11/15 Wojtek zabia...@gmail.com

  

Hi there,
I'd like to find out how the development mechanism of exception handling
works.
It displays  stacktrace from exception thrown, so it means it has access to
the Exception object.
I would like to implement similar feature, to display at least the message
from the exception to the end user.
Could you tell me how to do it or point the name of class shown where the
exception is thrown in development mode?
BTW. I know how to set internal exception page :)

Regards,
Wojtek

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org





  



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: exception handling for session dependent URLs

2009-02-16 Thread Igor Vaynberg
please create a jira issue.

-igor

On Mon, Feb 16, 2009 at 6:00 AM, Michael Sparer michael.spa...@gmx.at wrote:

 I recently came across a link to one of my projects where a user linked to a
 session dependent URL such as /?wicket:interface=:0::IBehaviorListener:2:3

 when clicking on that URL, a PageExpiredException gets thrown and a redirect
 to the SessionExpiredPage takes place. So far so good - that's the way it
 should be.
 However this works only for the first request (as long as the user doesn't
 have a session). If the user has a session and clicks on that link different
 exceptions might get thrown. with the URL mentioned above I've seen either a
 IllegalStateException (when it couldn't find a IBehaviorListener with the
 corresponding ID) or a ClassCastException (when it tried to cast a
 HeaderContributor to an IBehaviorListener in BehaviorRequestTarget).

 I must admit I didn't look into the code that thoroughly as I wanted to ask
 you first how you go about this problem (or it may be already fixed in
 1.3.6/1.4 - I'm using 1.3.5). I thinks accidentally pasting session
 dependent URLs in blogs etc. shouldn't result in server errors ... would it
 be save to throw e.g. a PageExpiredException instead of
 IllegalStateExceptions?

 Michael




 -
 Michael Sparer
 http://techblog.molindo.at
 --
 View this message in context: 
 http://www.nabble.com/exception-handling-for-session-dependent-URLs-tp22037821p22037821.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: exception handling for session dependent URLs

2009-02-16 Thread Michael Sparer

aye aye captain :-)

https://issues.apache.org/jira/browse/WICKET-2107



igor.vaynberg wrote:
 
 please create a jira issue.
 
 -igor
 
 On Mon, Feb 16, 2009 at 6:00 AM, Michael Sparer michael.spa...@gmx.at
 wrote:

 I recently came across a link to one of my projects where a user linked
 to a
 session dependent URL such as
 /?wicket:interface=:0::IBehaviorListener:2:3

 when clicking on that URL, a PageExpiredException gets thrown and a
 redirect
 to the SessionExpiredPage takes place. So far so good - that's the way it
 should be.
 However this works only for the first request (as long as the user
 doesn't
 have a session). If the user has a session and clicks on that link
 different
 exceptions might get thrown. with the URL mentioned above I've seen
 either a
 IllegalStateException (when it couldn't find a IBehaviorListener with the
 corresponding ID) or a ClassCastException (when it tried to cast a
 HeaderContributor to an IBehaviorListener in BehaviorRequestTarget).

 I must admit I didn't look into the code that thoroughly as I wanted to
 ask
 you first how you go about this problem (or it may be already fixed in
 1.3.6/1.4 - I'm using 1.3.5). I thinks accidentally pasting session
 dependent URLs in blogs etc. shouldn't result in server errors ... would
 it
 be save to throw e.g. a PageExpiredException instead of
 IllegalStateExceptions?

 Michael




 -
 Michael Sparer
 http://techblog.molindo.at
 --
 View this message in context:
 http://www.nabble.com/exception-handling-for-session-dependent-URLs-tp22037821p22037821.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 


-
Michael Sparer
http://techblog.molindo.at
-- 
View this message in context: 
http://www.nabble.com/exception-handling-for-session-dependent-URLs-tp22037821p22042612.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: exception handling for session dependent URLs

2009-02-16 Thread Igor Vaynberg
i think this might have to wait until 1.5.

we definetely cannot change this for 1.3.6 because it will change
existing behavior too much. and since 1.4 is already in the RC i would
rather not change it there either.

since we will be rewriting all url handling in 1.5 anyways it will be
a good time to implement this.

-igor

On Mon, Feb 16, 2009 at 10:09 AM, Michael Sparer michael.spa...@gmx.at wrote:

 aye aye captain :-)

 https://issues.apache.org/jira/browse/WICKET-2107



 igor.vaynberg wrote:

 please create a jira issue.

 -igor

 On Mon, Feb 16, 2009 at 6:00 AM, Michael Sparer michael.spa...@gmx.at
 wrote:

 I recently came across a link to one of my projects where a user linked
 to a
 session dependent URL such as
 /?wicket:interface=:0::IBehaviorListener:2:3

 when clicking on that URL, a PageExpiredException gets thrown and a
 redirect
 to the SessionExpiredPage takes place. So far so good - that's the way it
 should be.
 However this works only for the first request (as long as the user
 doesn't
 have a session). If the user has a session and clicks on that link
 different
 exceptions might get thrown. with the URL mentioned above I've seen
 either a
 IllegalStateException (when it couldn't find a IBehaviorListener with the
 corresponding ID) or a ClassCastException (when it tried to cast a
 HeaderContributor to an IBehaviorListener in BehaviorRequestTarget).

 I must admit I didn't look into the code that thoroughly as I wanted to
 ask
 you first how you go about this problem (or it may be already fixed in
 1.3.6/1.4 - I'm using 1.3.5). I thinks accidentally pasting session
 dependent URLs in blogs etc. shouldn't result in server errors ... would
 it
 be save to throw e.g. a PageExpiredException instead of
 IllegalStateExceptions?

 Michael




 -
 Michael Sparer
 http://techblog.molindo.at
 --
 View this message in context:
 http://www.nabble.com/exception-handling-for-session-dependent-URLs-tp22037821p22037821.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org





 -
 Michael Sparer
 http://techblog.molindo.at
 --
 View this message in context: 
 http://www.nabble.com/exception-handling-for-session-dependent-URLs-tp22037821p22042612.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org