You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eyal Golan <eg...@gmail.com> on 2008/11/27 14:18:34 UTC
Hand on session code
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
egolan74@gmail.com
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
Posted by Eyal Golan <eg...@gmail.com>.
I actually did find it afterward :)
the ctrl+o in my eclipse confused me. :/
And I understood that it's the same
Thanks anyway...
I
Eyal Golan
egolan74@gmail.com
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 6:16 PM, Michael Sparer <mi...@gmx.at>wrote:
>
> Nicer? Well it's quite the same with the difference that I overrode the
> cycle
> processor and Dipu just the cycle ... I suspect you didn't find the right
> method to override ;-)
>
> regards,
> Michael
>
>
> egolan74 wrote:
> >
> > Thanks Dipu and Michael,
> >
> > Michael, you understood correctly.
> > I used Dipu's solution as it looks nicer (no offend Michael :) )
> > However, I added a check for development / deployment.
> > And this is my (almost) final method.
> > /**
> > * @see
> > org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
> > * org.apache.wicket.Response)
> > */
> > @Override
> > 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 (DEPLOYMENT.equalsIgnoreCase(getConfigurationType()))
> {
> > if
> > (PageExpiredException.class.isAssignableFrom(e.getClass())) {
> > return null;
> > }
> > return new InternalErrorPage();
> > } else {
> > // In development we want to see the exception
> > return null;
> > }
> >
> > }
> > };
> > }
> >
> > All I need now is to work on the InternalErrorPage to get parameters and
> > add
> > the information.
> >
> > I have noticed one thing.
> > Overriding this method caused the
> > getExceptionSettings().setUnexpectedExceptionDisplay to be overridden.
> >
> > Thanks again, that was very much helpful.
> >
> >
> > Eyal Golan
> > egolan74@gmail.com
> >
> > 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 4:27 PM, Michael Sparer
> > <mi...@gmx.at>wrote:
> >
> >>
> >> 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
> >> > egolan74@gmail.com
> >> >
> >> > 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
> >> > <mi...@gmx.at>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
> >> >> > egolan74@gmail.com
> >> >> >
> >> >> > 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
> >> >> > egolan74@gmail.com
> >> >> >
> >> >> > 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: users-unsubscribe@wicket.apache.org
> >> >> For additional commands, e-mail: users-help@wicket.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >> > -----
> >> > Eyal Golan
> >> > egolan74@gmail.com
> >> >
> >> > 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > -----
> > Eyal Golan
> > egolan74@gmail.com
> >
> > 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Hand on session code
Posted by Michael Sparer <mi...@gmx.at>.
Nicer? Well it's quite the same with the difference that I overrode the cycle
processor and Dipu just the cycle ... I suspect you didn't find the right
method to override ;-)
regards,
Michael
egolan74 wrote:
>
> Thanks Dipu and Michael,
>
> Michael, you understood correctly.
> I used Dipu's solution as it looks nicer (no offend Michael :) )
> However, I added a check for development / deployment.
> And this is my (almost) final method.
> /**
> * @see
> org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
> * org.apache.wicket.Response)
> */
> @Override
> 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 (DEPLOYMENT.equalsIgnoreCase(getConfigurationType())) {
> if
> (PageExpiredException.class.isAssignableFrom(e.getClass())) {
> return null;
> }
> return new InternalErrorPage();
> } else {
> // In development we want to see the exception
> return null;
> }
>
> }
> };
> }
>
> All I need now is to work on the InternalErrorPage to get parameters and
> add
> the information.
>
> I have noticed one thing.
> Overriding this method caused the
> getExceptionSettings().setUnexpectedExceptionDisplay to be overridden.
>
> Thanks again, that was very much helpful.
>
>
> Eyal Golan
> egolan74@gmail.com
>
> 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 4:27 PM, Michael Sparer
> <mi...@gmx.at>wrote:
>
>>
>> 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
>> > egolan74@gmail.com
>> >
>> > 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
>> > <mi...@gmx.at>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
>> >> > egolan74@gmail.com
>> >> >
>> >> > 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
>> >> > egolan74@gmail.com
>> >> >
>> >> > 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: users-unsubscribe@wicket.apache.org
>> >> For additional commands, e-mail: users-help@wicket.apache.org
>> >>
>> >>
>> >
>> >
>> > -----
>> > Eyal Golan
>> > egolan74@gmail.com
>> >
>> > 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> -----
> Eyal Golan
> egolan74@gmail.com
>
> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Hand on session code
Posted by Eyal Golan <eg...@gmail.com>.
Thanks Dipu and Michael,
Michael, you understood correctly.
I used Dipu's solution as it looks nicer (no offend Michael :) )
However, I added a check for development / deployment.
And this is my (almost) final method.
/**
* @see
org.apache.wicket.Application#newRequestCycle(org.apache.wicket.Request,
* org.apache.wicket.Response)
*/
@Override
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 (DEPLOYMENT.equalsIgnoreCase(getConfigurationType())) {
if
(PageExpiredException.class.isAssignableFrom(e.getClass())) {
return null;
}
return new InternalErrorPage();
} else {
// In development we want to see the exception
return null;
}
}
};
}
All I need now is to work on the InternalErrorPage to get parameters and add
the information.
I have noticed one thing.
Overriding this method caused the
getExceptionSettings().setUnexpectedExceptionDisplay to be overridden.
Thanks again, that was very much helpful.
Eyal Golan
egolan74@gmail.com
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 4:27 PM, Michael Sparer <mi...@gmx.at>wrote:
>
> 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
> > egolan74@gmail.com
> >
> > 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
> > <mi...@gmx.at>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
> >> > egolan74@gmail.com
> >> >
> >> > 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
> >> > egolan74@gmail.com
> >> >
> >> > 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: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
> > -----
> > Eyal Golan
> > egolan74@gmail.com
> >
> > 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Hand on session code
Posted by Michael Sparer <mi...@gmx.at>.
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
> egolan74@gmail.com
>
> 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
> <mi...@gmx.at>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
>> > egolan74@gmail.com
>> >
>> > 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
>> > egolan74@gmail.com
>> >
>> > 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: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> -----
> Eyal Golan
> egolan74@gmail.com
>
> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Hand on session code
Posted by Dipu <di...@googlemail.com>.
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 <eg...@gmail.com> 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
> egolan74@gmail.com
>
> 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 <michael.sparer@gmx.at
> >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
> > > egolan74@gmail.com
> > >
> > > 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
> > > egolan74@gmail.com
> > >
> > > 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: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
Re: Hand on session code
Posted by Eyal Golan <eg...@gmail.com>.
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
egolan74@gmail.com
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 <mi...@gmx.at>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
> > egolan74@gmail.com
> >
> > 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
> > egolan74@gmail.com
> >
> > 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: Hand on session code
Posted by Michael Sparer <mi...@gmx.at>.
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
> egolan74@gmail.com
>
> 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
> egolan74@gmail.com
>
> 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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org