Fair enough :)
-----Original Message-----
From: Simon Kitching [mailto:[EMAIL PROTECTED]
Sent: Monday, 28 November 2005 9:27 AM
To: MyFaces Discussion
Subject: Re: Should isRendered return 'false' on error?
[EMAIL PROTECTED] wrote:
> Dear All,
>
> Could I please confirm the logic of the following code from
> javax.faces.component.UIComponentBase...
>
> public boolean isRendered()
> {
> if (_rendered != null) return _rendered.booleanValue();
> ValueBinding vb = getValueBinding("rendered");
> Boolean v = vb != null ? (Boolean)vb.getValue(getFacesContext()) :
> null;
> return v != null ? v.booleanValue() : DEFAULT_RENDERED;
> }
>
> ...this code throws a very ugly Exception and halts page rendering if the
> value binding cannot be evaluated. However, shouldn't it instead catch the
> Exception and return false? Because I thought the logic of the EL was to
> degrade gracefully with 'reasonable defaults' (and 'false' is the default for
> a boolean)?
I'd be inclined to say no. When there is a bug in my program such that
the binding I've provided can't be evaluated I don't want MyFaces to
silently fail to render the component; I want an exception message so I
can fix the problem. Of course applications should be configured so end
users are routed to a nice error page rather than seeing the exception
directly.
Under what situation could the binding fail, but the program continue to
work correctly? Not too many I would have thought. For example, in an
online tax form failing to render a component because of an application
error could have *very* expensive consequences.
The spec might require certain behaviour here anyway, though I'm not sure.
Regards,
Simon