Re: How to display exception thrown by beans during a dialog?

2007-01-26 Thread Rahul Akolkar

On 1/26/07, Paul Spencer <[EMAIL PROTECTED]> wrote:

Rahul,
So, if I want to display information from the exception to the user:
1) I need to maintain the exception in the bean, #{venderDialog}.
2) The view displaying the exception would reference a property in the
bean, #{venderDialog.caughtException}?




I meant "com.foo.Vendor" in your earlier example below:


 


This is because:

* The dialog data is maintained for us, so we don't need to worry
about scoping, the information will exist for as long as the dialog is
active, and no more than that

* IMO, if the exception message (or some other bits) are meaningful
to the user interaction, then the message (or other bits) belong to
the location where we store all data associated with the user
interaction (such as form field values etc.)

Probably the easiest way to populate the dialog data in v1.0.4 is by
setting the value on the appropriate ValueBinding expression, i.e.
updated snippet:

} catch (NotConfiguredException nce) {
FacesContext ctx = FacesContext.getCurrentInstance();
 ValueBinding vb = ctx.getApplication().
 createValueBinding("#{dialog.data.cfgErrMsg}"); // or a
better prop name
 vb.setValue(ctx, nce.getMessage());
 return "notconfigured";
}

Again, the DialogHelper will help eliminate the grunt work [1] of the
catch block in future releases.

Whereby in the subsequent view (for "vendor/noconfig" state ID), we can have:



-Rahul

[1] https://issues.apache.org/struts/browse/SHALE-401




public class VendorDialog
{
   private Exception caughtException;
   // ..

  public String setup() { // no throws clause

   // ...

   try {
 // line(s) that can throw NotConfiguredException
   } catch (NotConfiguredException nce) {
 caughtException = nce;
 return "notconfigured";
   }

   // ...

   return "success";

  }
  Exception getCaughtException()
  {
return caughtException;
  }
}


Thank you,

Paul Spencer





Re: How to display exception thrown by beans during a dialog?

2007-01-26 Thread Paul Spencer

Rahul,
So, if I want to display information from the exception to the user:
1) I need to maintain the exception in the bean, #{venderDialog}.
2) The view displaying the exception would reference a property in the
   bean, #{venderDialog.caughtException}?


public class VendorDialog
{
  private Exception caughtException;
  // ..

 public String setup() { // no throws clause

  // ...

  try {
// line(s) that can throw NotConfiguredException
  } catch (NotConfiguredException nce) {
caughtException = nce;
return "notconfigured";
  }

  // ...

  return "success";

 }
 Exception getCaughtException()
 {
   return caughtException;
 }
}


Thank you,

Paul Spencer


Rahul Akolkar wrote:

On 1/26/07, Paul Spencer <[EMAIL PROTECTED]> wrote:

I would like to display exception thrown by a managed bean during a
dialog to the user. How do I configure this?

As example:
   
 
   
 
 
   

vendorDialog.setup() can throw a NotConfiguredException.

1) I want to show this to the user.
2) I would also like to define the view that will display the exception.
3) In the above view, what is the bean/variable containing the thrown
exception?




An exception out of a MBE execution is merely yet another logical
outcome for the dialog state machine and should be treated as such.
IMO, introducing Java exception specific constructs into the dialog
description is a bit of a leaky abstraction since it muddys up the
modeling layer and state machine code generation etc. (for those who
care about that). So, for the simplest case, I would author the setup
method like so:

public String setup() { // no throws clause

 // ...

 try {
   // line(s) that can throw NotConfiguredException
 } catch (NotConfiguredException nce) {
   return "notconfigured";
 }

 // ...

 return "success";

}

whereby the flow markup is:



 
   
 

 

 



Note that by returning the NotConfiguredException as a logical outcome
we did lose actual Throwable instance (which might hold needed
information), but:
(a) Its arguable whether we need to display things like the trace to the 
user

(b) We can always use dialog data to hold on to that bit, if its
needed by the subsequent view etc.

-Rahul




Paul Spencer








Re: How to display exception thrown by beans during a dialog?

2007-01-26 Thread Rahul Akolkar

On 1/26/07, Paul Spencer <[EMAIL PROTECTED]> wrote:

I would like to display exception thrown by a managed bean during a
dialog to the user. How do I configure this?

As example:
   
 
   
 
 
   

vendorDialog.setup() can throw a NotConfiguredException.

1) I want to show this to the user.
2) I would also like to define the view that will display the exception.
3) In the above view, what is the bean/variable containing the thrown
exception?




An exception out of a MBE execution is merely yet another logical
outcome for the dialog state machine and should be treated as such.
IMO, introducing Java exception specific constructs into the dialog
description is a bit of a leaky abstraction since it muddys up the
modeling layer and state machine code generation etc. (for those who
care about that). So, for the simplest case, I would author the setup
method like so:

public String setup() { // no throws clause

 // ...

 try {
   // line(s) that can throw NotConfiguredException
 } catch (NotConfiguredException nce) {
   return "notconfigured";
 }

 // ...

 return "success";

}

whereby the flow markup is:



 
   
 

 

 



Note that by returning the NotConfiguredException as a logical outcome
we did lose actual Throwable instance (which might hold needed
information), but:
(a) Its arguable whether we need to display things like the trace to the user
(b) We can always use dialog data to hold on to that bit, if its
needed by the subsequent view etc.

-Rahul




Paul Spencer




How to display exception thrown by beans during a dialog?

2007-01-26 Thread Paul Spencer
I would like to display exception thrown by a managed bean during a 
dialog to the user. How do I configure this?


As example:
  

  


  

vendorDialog.setup() can throw a NotConfiguredException.

1) I want to show this to the user.
2) I would also like to define the view that will display the exception.
3) In the above view, what is the bean/variable containing the thrown 
exception?



Paul Spencer