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:
   <state id="setup">
     <onentry>
       <var expr="#{vendorDialog.setup}" name="outcome" />
     </onentry>
     <transition target="vendor/add" cond="${outcome eq 'success'}" />
   </state>

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?

<snip/>

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:

<state id="setup">

 <onentry>
   <var expr="#{vendorDialog.setup}" name="outcome" />
 </onentry>

 <transition target="vendor/add"
             cond="${outcome eq 'success'}" />

 <transition target="vendor/noconfig"
             cond="${outcome eq 'notconfigured'}" />

</state>

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


Reply via email to