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}?

<snip/>

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

<dialogs>
 <dialog name="addVendor" scxmlconfig="dialogs/addVendor.xml"
   dataclassname="com.foo.Vendor" />
</dialogs>

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:

<h:outputText value="No configuration: #{dialog.data.cfgErrMsg}"/>

-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

<snap/>

Reply via email to