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.


EXception handling in Wicket

2010-08-26 Thread arunarapole

Hi

How to display exception message in hidden field or  on pop up window or
feedback panel or in any wicket component  in the same page where i am
entering data.

If any one does this please send me sample code or idea 
please do this i am very new to the wicket frame work.
please help out me any one


Thank you
Aruna

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/EXception-handling-in-Wicket-tp2340439p2340439.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

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