Re: Exception redirecting to source page

2008-02-19 Thread Cristiano Kliemann

Thanks for the reply.

I think I will not use onRuntimeException to control my 'business
exceptions' even if it works now. If Wicket doesn't count on such thing, I
have no guarantee that it won't break in the future. 

I'm not sure it will not break in the future.

What I'm afraid 
of changes in the Wicket code in future versions that could break my 


igor.vaynberg wrote:
 
 good. there are some internals that do not count on a runtime
 exception being thrown because of user code...for example throwing it
 out of something like validator will abort entire form processing, and
 might leave that particular form component in an inconsistent state.
 but throwing it out of onclick/onsubmit handlers shouldnt pose much
 problem as most wicket processing has already happened.
 
 -igor
 
 On Feb 18, 2008 8:40 AM, Cristiano Kliemann [EMAIL PROTECTED] wrote:

 Igor,

 It seems to work with Link.onClick also.



 Cristiano Kliemann wrote:
 
  Yes, it works, at least when the exception is thrown in
 Button.onSubmit. I
  haven't tried with Link.onClick.
 
 
  igor.vaynberg wrote:
 
  have you tried it and does it work?
 
  -igor
 
 
  On Feb 15, 2008 1:17 PM, Cristiano Kliemann [EMAIL PROTECTED]
 wrote:
 
  Hi!
 
  I have some business runtime exceptions that I want to be
 automatically
  catched and its message rendered in the same page that threw it
 instead
  of
  redirecting to an error page.
 
  Is there a safe way to do that?
 
  These 'business exceptions' are usually thrown in some specific
 methods
  like
  onSubmit and onClick. Extending the specific components is not an
 option
  for
  me.
 
  I did something I think it dangerous. Something like:
 
  public Page onRuntimeException(Page page, RuntimeException e) {
 
  Throwable current = e;
  while (current != null  !(current instanceof
 MyBusinessException))
  {
  current = current.getCause();
  }
  if (current != null) {
  // MyBusinessException detected
  page.error(Error:  + current.getMessage());
  return page;
  } else {
  return super.onRuntimeException(page, e);
  }
  }
 
  When as exception is thrown, all the execution flow breaks, making
 some
  things not happen. The question is: is the above code safe assuming
 that
  MyException could be thrown only by methods like onSubmit and
 onClick?
  --
  View this message in context:
 
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.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]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15547028.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]


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

-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15560807.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: Exception redirecting to source page

2008-02-19 Thread Cristiano Kliemann

I spent some time editing the previous e-mail and forgot to delete the
'garbage' before posting... sorry :)


igor.vaynberg wrote:
 
 good. there are some internals that do not count on a runtime
 exception being thrown because of user code...for example throwing it
 out of something like validator will abort entire form processing, and
 might leave that particular form component in an inconsistent state.
 but throwing it out of onclick/onsubmit handlers shouldnt pose much
 problem as most wicket processing has already happened.
 
 -igor
 
 On Feb 18, 2008 8:40 AM, Cristiano Kliemann [EMAIL PROTECTED] wrote:

 Igor,

 It seems to work with Link.onClick also.



 Cristiano Kliemann wrote:
 
  Yes, it works, at least when the exception is thrown in
 Button.onSubmit. I
  haven't tried with Link.onClick.
 
 
  igor.vaynberg wrote:
 
  have you tried it and does it work?
 
  -igor
 
 
  On Feb 15, 2008 1:17 PM, Cristiano Kliemann [EMAIL PROTECTED]
 wrote:
 
  Hi!
 
  I have some business runtime exceptions that I want to be
 automatically
  catched and its message rendered in the same page that threw it
 instead
  of
  redirecting to an error page.
 
  Is there a safe way to do that?
 
  These 'business exceptions' are usually thrown in some specific
 methods
  like
  onSubmit and onClick. Extending the specific components is not an
 option
  for
  me.
 
  I did something I think it dangerous. Something like:
 
  public Page onRuntimeException(Page page, RuntimeException e) {
 
  Throwable current = e;
  while (current != null  !(current instanceof
 MyBusinessException))
  {
  current = current.getCause();
  }
  if (current != null) {
  // MyBusinessException detected
  page.error(Error:  + current.getMessage());
  return page;
  } else {
  return super.onRuntimeException(page, e);
  }
  }
 
  When as exception is thrown, all the execution flow breaks, making
 some
  things not happen. The question is: is the above code safe assuming
 that
  MyException could be thrown only by methods like onSubmit and
 onClick?
  --
  View this message in context:
 
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.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]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 

 --
 View this message in context:
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15547028.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]


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

-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15561407.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: Exception redirecting to source page

2008-02-19 Thread Cristiano Kliemann

I missed the generic exception 'goalkeeper' that JSF, Struts and other web
frameworks have (I think).


Alex Jacoby-2 wrote:
 
 Just wondering if this sort of thing is documented anywhere...
 
 Thanks,
 Alex
 
 On Feb 18, 2008, at 1:02 PM, Igor Vaynberg wrote:
 
 good. there are some internals that do not count on a runtime
 exception being thrown because of user code...for example throwing it
 out of something like validator will abort entire form processing, and
 might leave that particular form component in an inconsistent state.
 but throwing it out of onclick/onsubmit handlers shouldnt pose much
 problem as most wicket processing has already happened.

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

-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15581199.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: Exception redirecting to source page

2008-02-18 Thread Cristiano Kliemann

Igor,

It seems to work with Link.onClick also.


Cristiano Kliemann wrote:
 
 Yes, it works, at least when the exception is thrown in Button.onSubmit. I
 haven't tried with Link.onClick.
 
 
 igor.vaynberg wrote:
 
 have you tried it and does it work?
 
 -igor
 
 
 On Feb 15, 2008 1:17 PM, Cristiano Kliemann [EMAIL PROTECTED] wrote:

 Hi!

 I have some business runtime exceptions that I want to be automatically
 catched and its message rendered in the same page that threw it instead
 of
 redirecting to an error page.

 Is there a safe way to do that?

 These 'business exceptions' are usually thrown in some specific methods
 like
 onSubmit and onClick. Extending the specific components is not an option
 for
 me.

 I did something I think it dangerous. Something like:

 public Page onRuntimeException(Page page, RuntimeException e) {

 Throwable current = e;
 while (current != null  !(current instanceof MyBusinessException))
 {
 current = current.getCause();
 }
 if (current != null) {
 // MyBusinessException detected
 page.error(Error:  + current.getMessage());
 return page;
 } else {
 return super.onRuntimeException(page, e);
 }
 }

 When as exception is thrown, all the execution flow breaks, making some
 things not happen. The question is: is the above code safe assuming that
 MyException could be thrown only by methods like onSubmit and onClick?
 --
 View this message in context:
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.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]


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

-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15547028.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: Exception redirecting to source page

2008-02-18 Thread Igor Vaynberg
good. there are some internals that do not count on a runtime
exception being thrown because of user code...for example throwing it
out of something like validator will abort entire form processing, and
might leave that particular form component in an inconsistent state.
but throwing it out of onclick/onsubmit handlers shouldnt pose much
problem as most wicket processing has already happened.

-igor

On Feb 18, 2008 8:40 AM, Cristiano Kliemann [EMAIL PROTECTED] wrote:

 Igor,

 It seems to work with Link.onClick also.



 Cristiano Kliemann wrote:
 
  Yes, it works, at least when the exception is thrown in Button.onSubmit. I
  haven't tried with Link.onClick.
 
 
  igor.vaynberg wrote:
 
  have you tried it and does it work?
 
  -igor
 
 
  On Feb 15, 2008 1:17 PM, Cristiano Kliemann [EMAIL PROTECTED] wrote:
 
  Hi!
 
  I have some business runtime exceptions that I want to be automatically
  catched and its message rendered in the same page that threw it instead
  of
  redirecting to an error page.
 
  Is there a safe way to do that?
 
  These 'business exceptions' are usually thrown in some specific methods
  like
  onSubmit and onClick. Extending the specific components is not an option
  for
  me.
 
  I did something I think it dangerous. Something like:
 
  public Page onRuntimeException(Page page, RuntimeException e) {
 
  Throwable current = e;
  while (current != null  !(current instanceof MyBusinessException))
  {
  current = current.getCause();
  }
  if (current != null) {
  // MyBusinessException detected
  page.error(Error:  + current.getMessage());
  return page;
  } else {
  return super.onRuntimeException(page, e);
  }
  }
 
  When as exception is thrown, all the execution flow breaks, making some
  things not happen. The question is: is the above code safe assuming that
  MyException could be thrown only by methods like onSubmit and onClick?
  --
  View this message in context:
  http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.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]
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 

 --
 View this message in context: 
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15547028.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]



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



Re: Exception redirecting to source page

2008-02-17 Thread Cristiano Kliemann

Yes, it works, at least when the exception is thrown in Button.onSubmit. I
haven't tried with Link.onClick.


igor.vaynberg wrote:
 
 have you tried it and does it work?
 
 -igor
 
 
 On Feb 15, 2008 1:17 PM, Cristiano Kliemann [EMAIL PROTECTED] wrote:

 Hi!

 I have some business runtime exceptions that I want to be automatically
 catched and its message rendered in the same page that threw it instead
 of
 redirecting to an error page.

 Is there a safe way to do that?

 These 'business exceptions' are usually thrown in some specific methods
 like
 onSubmit and onClick. Extending the specific components is not an option
 for
 me.

 I did something I think it dangerous. Something like:

 public Page onRuntimeException(Page page, RuntimeException e) {

 Throwable current = e;
 while (current != null  !(current instanceof MyBusinessException))
 {
 current = current.getCause();
 }
 if (current != null) {
 // MyBusinessException detected
 page.error(Error:  + current.getMessage());
 return page;
 } else {
 return super.onRuntimeException(page, e);
 }
 }

 When as exception is thrown, all the execution flow breaks, making some
 things not happen. The question is: is the above code safe assuming that
 MyException could be thrown only by methods like onSubmit and onClick?
 --
 View this message in context:
 http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.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]


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

-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15528633.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]



Exception redirecting to source page

2008-02-15 Thread Cristiano Kliemann

Hi!

I have some business runtime exceptions that I want to be automatically
catched and its message rendered in the same page that threw it instead of
redirecting to an error page.

Is there a safe way to do that?

These 'business exceptions' are usually thrown in some specific methods like
onSubmit and onClick. Extending the specific components is not an option for
me.

I did something I think it dangerous. Something like:

public Page onRuntimeException(Page page, RuntimeException e) {

Throwable current = e;
while (current != null  !(current instanceof MyBusinessException)) {
current = current.getCause();
}
if (current != null) {
// MyBusinessException detected
page.error(Error:  + current.getMessage());
return page;
} else {
return super.onRuntimeException(page, e);
}
}

When as exception is thrown, all the execution flow breaks, making some
things not happen. The question is: is the above code safe assuming that
MyException could be thrown only by methods like onSubmit and onClick?
-- 
View this message in context: 
http://www.nabble.com/Exception-redirecting-to-source-page-tp15510198p15510198.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]