You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ri...@mail.thomson.com on 2005/11/27 23:13:40 UTC
Should isRendered return 'false' on error?
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)?
Of course, I could have gotten this completely wrong,
Thanks,
Richard.
Re: Should isRendered return 'false' on error?
Posted by Simon Kitching <sk...@obsidium.com>.
Richard.Kennard@mail.thomson.com 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