Re: Hand on session code

2008-11-27 Thread Michael Sparer

the first possibility that comes to my mind is overriding the following
method in your application:

@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return new WebRequestCycleProcessor() {

@Override
protected Page onRuntimeException(final Page page, 
final RuntimeException
e) {
// do the default handling on 
pageexpiredexceptions
if (e instanceof PageExpiredException || e 
instanceof
AuthorizationException) {
return null;
}
return new InternalServerError(page, e); //  
e.getCause for your NPE
}

};
}

egolan74 wrote:
 
 Hi,
 In deployment, we set our own internal error page:
 getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
 and
 getExceptionSettings().setUnexpectedExceptionDisplay(
 IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
 
 Is there a quick way to get the type of the exception and show a different
 message in our internal error page accordingly?
 For example: if we get NullPointerException, show a message: You
 developer
 coded null !!! .
 And ArrayIndexOutOfBoundException will show: oops.. the array is too
 small
 .
 
 Thanks
 
 Eyal Golan
 [EMAIL PROTECTED]
 
 Visit: http://jvdrums.sourceforge.net/
 LinkedIn: http://www.linkedin.com/in/egolan74
 
 P  Save a tree. Please don't print this e-mail unless it's really
 necessary
 
 
 -
 Eyal Golan
 [EMAIL PROTECTED]
 
 Visit: JVDrums 
 LinkedIn: LinkedIn 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Hand on session code

2008-11-27 Thread Eyal Golan
Hi,
In deployment, we set our own internal error page:
getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
and
getExceptionSettings().setUnexpectedExceptionDisplay(
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);

Is there a quick way to get the type of the exception and show a different
message in our internal error page accordingly?
For example: if we get NullPointerException, show a message: You developer
coded null !!! .
And ArrayIndexOutOfBoundException will show: oops.. the array is too small
.

Thanks

Eyal Golan
[EMAIL PROTECTED]

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary


Re: Hand on session code

2008-11-27 Thread Eyal Golan
Thanks,

but looking at WebRequestCycleProcessor I didn't see onRuntimeException
method.
We use 1.3.4 version

Looking at AbstractRequestCycleProcessor:respond, I see the call:
if (responseClass != internalErrorPageClass 
settings.getUnexpectedExceptionDisplay() ==
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
{
throw new RestartResponseException(internalErrorPageClass);
}

And I also see that RestartResponseException has a constructor with
PageParameters.

Is there a nice way to call the constructor with the parameters in respond ?
Without overriding all this method?

Thanks

Eyal Golan
[EMAIL PROTECTED]

Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74

P  Save a tree. Please don't print this e-mail unless it's really necessary


On Thu, Nov 27, 2008 at 3:31 PM, Michael Sparer [EMAIL PROTECTED]wrote:


 the first possibility that comes to my mind is overriding the following
 method in your application:

@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return new WebRequestCycleProcessor() {

@Override
protected Page onRuntimeException(final Page page,
 final RuntimeException
 e) {
// do the default handling on
 pageexpiredexceptions
if (e instanceof PageExpiredException || e
 instanceof
 AuthorizationException) {
return null;
}
return new InternalServerError(page, e); //
  e.getCause for your NPE
}

};
 }

 egolan74 wrote:
 
  Hi,
  In deployment, we set our own internal error page:
  getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
  and
  getExceptionSettings().setUnexpectedExceptionDisplay(
  IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
 
  Is there a quick way to get the type of the exception and show a
 different
  message in our internal error page accordingly?
  For example: if we get NullPointerException, show a message: You
  developer
  coded null !!! .
  And ArrayIndexOutOfBoundException will show: oops.. the array is too
  small
  .
 
  Thanks
 
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: http://jvdrums.sourceforge.net/
  LinkedIn: http://www.linkedin.com/in/egolan74
 
  P  Save a tree. Please don't print this e-mail unless it's really
  necessary
 
 
  -
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: JVDrums
  LinkedIn: LinkedIn
 


 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context:
 http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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




Re: Hand on session code

2008-11-27 Thread Dipu
this is what I do
/**
 * @see
org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
 *  org.apache.wicket.Response)
 */
public RequestCycle newRequestCycle(final Request request, final Response
response)
{
return new WebRequestCycle(this, (WebRequest)request, (WebResponse)response)
{

@Override
public Page onRuntimeException(Page page, RuntimeException e)
{
if(PageExpiredException.class.isAssignableFrom(e.getClass()))
{
return null;
}
return new ErrorPage(e,page);
}
 };
 }

Cheers
Dipu

On Thu, Nov 27, 2008 at 2:18 PM, Eyal Golan [EMAIL PROTECTED] wrote:

 Thanks,

 but looking at WebRequestCycleProcessor I didn't see onRuntimeException
 method.
 We use 1.3.4 version

 Looking at AbstractRequestCycleProcessor:respond, I see the call:
if (responseClass != internalErrorPageClass 
settings.getUnexpectedExceptionDisplay() ==
 IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
 {
throw new RestartResponseException(internalErrorPageClass);
}

 And I also see that RestartResponseException has a constructor with
 PageParameters.

 Is there a nice way to call the constructor with the parameters in respond
 ?
 Without overriding all this method?

 Thanks

 Eyal Golan
 [EMAIL PROTECTED]

 Visit: http://jvdrums.sourceforge.net/
 LinkedIn: http://www.linkedin.com/in/egolan74

 P  Save a tree. Please don't print this e-mail unless it's really necessary


 On Thu, Nov 27, 2008 at 3:31 PM, Michael Sparer [EMAIL PROTECTED]
 wrote:

 
  the first possibility that comes to my mind is overriding the following
  method in your application:
 
 @Override
 protected IRequestCycleProcessor newRequestCycleProcessor() {
 return new WebRequestCycleProcessor() {
 
 @Override
 protected Page onRuntimeException(final Page page,
  final RuntimeException
  e) {
 // do the default handling on
  pageexpiredexceptions
 if (e instanceof PageExpiredException || e
  instanceof
  AuthorizationException) {
 return null;
 }
 return new InternalServerError(page, e);
 //
   e.getCause for your NPE
 }
 
 };
  }
 
  egolan74 wrote:
  
   Hi,
   In deployment, we set our own internal error page:
   getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
   and
   getExceptionSettings().setUnexpectedExceptionDisplay(
   IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
  
   Is there a quick way to get the type of the exception and show a
  different
   message in our internal error page accordingly?
   For example: if we get NullPointerException, show a message: You
   developer
   coded null !!! .
   And ArrayIndexOutOfBoundException will show: oops.. the array is too
   small
   .
  
   Thanks
  
   Eyal Golan
   [EMAIL PROTECTED]
  
   Visit: http://jvdrums.sourceforge.net/
   LinkedIn: http://www.linkedin.com/in/egolan74
  
   P  Save a tree. Please don't print this e-mail unless it's really
   necessary
  
  
   -
   Eyal Golan
   [EMAIL PROTECTED]
  
   Visit: JVDrums
   LinkedIn: LinkedIn
  
 
 
  -
  Michael Sparer
  http://talk-on-tech.blogspot.com
  --
  View this message in context:
  http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



Re: Hand on session code

2008-11-27 Thread Michael Sparer

What do you mean by saying you didn't see onRuntimeException in
WebRequestCycleProcessor? If you didn't find it there it's because it's a
method of its base class ;-)

What I didn't mention when providing the code was that it's actually
returning a Page (our internal server error page) and gets the Exception
that caused the pain in the constructor. I might be misunderstanding you,
but wasn't that the thing you wanted? Displaying different stuff in your
error page based on what Exception was thrown?

regards,
Michael


egolan74 wrote:
 
 Thanks,
 
 but looking at WebRequestCycleProcessor I didn't see onRuntimeException
 method.
 We use 1.3.4 version
 
 Looking at AbstractRequestCycleProcessor:respond, I see the call:
 if (responseClass != internalErrorPageClass 
 settings.getUnexpectedExceptionDisplay() ==
 IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE)
 {
 throw new
 RestartResponseException(internalErrorPageClass);
 }
 
 And I also see that RestartResponseException has a constructor with
 PageParameters.
 
 Is there a nice way to call the constructor with the parameters in respond
 ?
 Without overriding all this method?
 
 Thanks
 
 Eyal Golan
 [EMAIL PROTECTED]
 
 Visit: http://jvdrums.sourceforge.net/
 LinkedIn: http://www.linkedin.com/in/egolan74
 
 P  Save a tree. Please don't print this e-mail unless it's really
 necessary
 
 
 On Thu, Nov 27, 2008 at 3:31 PM, Michael Sparer
 [EMAIL PROTECTED]wrote:
 

 the first possibility that comes to my mind is overriding the following
 method in your application:

@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
return new WebRequestCycleProcessor() {

@Override
protected Page onRuntimeException(final Page page,
 final RuntimeException
 e) {
// do the default handling on
 pageexpiredexceptions
if (e instanceof PageExpiredException || e
 instanceof
 AuthorizationException) {
return null;
}
return new InternalServerError(page, e);
 //
  e.getCause for your NPE
}

};
 }

 egolan74 wrote:
 
  Hi,
  In deployment, we set our own internal error page:
  getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
  and
  getExceptionSettings().setUnexpectedExceptionDisplay(
  IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
 
  Is there a quick way to get the type of the exception and show a
 different
  message in our internal error page accordingly?
  For example: if we get NullPointerException, show a message: You
  developer
  coded null !!! .
  And ArrayIndexOutOfBoundException will show: oops.. the array is too
  small
  .
 
  Thanks
 
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: http://jvdrums.sourceforge.net/
  LinkedIn: http://www.linkedin.com/in/egolan74
 
  P  Save a tree. Please don't print this e-mail unless it's really
  necessary
 
 
  -
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: JVDrums
  LinkedIn: LinkedIn
 


 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context:
 http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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


 
 
 -
 Eyal Golan
 [EMAIL PROTECTED]
 
 Visit: JVDrums 
 LinkedIn: LinkedIn 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Hand-on-session-code-tp20719154p20720178.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Hand on session code

2008-11-27 Thread Eyal Golan
: LinkedIn
  
 
 
  -
  Michael Sparer
  http://talk-on-tech.blogspot.com
  --
  View this message in context:
  http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
  -
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: JVDrums
  LinkedIn: LinkedIn
 


 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context:
 http://www.nabble.com/Hand-on-session-code-tp20719154p20720178.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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




Re: Hand on session code

2008-11-27 Thread Michael Sparer
 PROTECTED]
  
   Visit: http://jvdrums.sourceforge.net/
   LinkedIn: http://www.linkedin.com/in/egolan74
  
   P  Save a tree. Please don't print this e-mail unless it's really
   necessary
  
  
   -
   Eyal Golan
   [EMAIL PROTECTED]
  
   Visit: JVDrums
   LinkedIn: LinkedIn
  
 
 
  -
  Michael Sparer
  http://talk-on-tech.blogspot.com
  --
  View this message in context:
  http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
  -
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: JVDrums
  LinkedIn: LinkedIn
 


 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context:
 http://www.nabble.com/Hand-on-session-code-tp20719154p20720178.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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


 
 
 -
 Eyal Golan
 [EMAIL PROTECTED]
 
 Visit: JVDrums 
 LinkedIn: LinkedIn 
 


-
Michael Sparer
http://talk-on-tech.blogspot.com
-- 
View this message in context: 
http://www.nabble.com/Hand-on-session-code-tp20719154p20721787.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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



Re: Hand on session code

2008-11-27 Thread Eyal Golan
:
   
  getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
and
getExceptionSettings().setUnexpectedExceptionDisplay(
IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
   
Is there a quick way to get the type of the exception and show a
   different
message in our internal error page accordingly?
For example: if we get NullPointerException, show a message: You
developer
coded null !!! .
And ArrayIndexOutOfBoundException will show: oops.. the array is
  too
small
.
   
Thanks
   
Eyal Golan
[EMAIL PROTECTED]
   
Visit: http://jvdrums.sourceforge.net/
LinkedIn: http://www.linkedin.com/in/egolan74
   
P  Save a tree. Please don't print this e-mail unless it's really
necessary
   
   
-
Eyal Golan
[EMAIL PROTECTED]
   
Visit: JVDrums
LinkedIn: LinkedIn
   
  
  
   -
   Michael Sparer
   http://talk-on-tech.blogspot.com
   --
   View this message in context:
   http://www.nabble.com/Hand-on-session-code-tp20719154p20719327.html
   Sent from the Wicket - User mailing list archive at Nabble.com.
  
  
   -
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  
  
  
   -
   Eyal Golan
   [EMAIL PROTECTED]
  
   Visit: JVDrums
   LinkedIn: LinkedIn
  
 
 
  -
  Michael Sparer
  http://talk-on-tech.blogspot.com
  --
  View this message in context:
  http://www.nabble.com/Hand-on-session-code-tp20719154p20720178.html
  Sent from the Wicket - User mailing list archive at Nabble.com.
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
  -
  Eyal Golan
  [EMAIL PROTECTED]
 
  Visit: JVDrums
  LinkedIn: LinkedIn
 


 -
 Michael Sparer
 http://talk-on-tech.blogspot.com
 --
 View this message in context:
 http://www.nabble.com/Hand-on-session-code-tp20719154p20721787.html
 Sent from the Wicket - User mailing list archive at Nabble.com.


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