[
https://issues.apache.org/jira/browse/MYFACES-2961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12934888#action_12934888
]
Leonardo Uribe commented on MYFACES-2961:
-----------------------------------------
This problem is questionable. On myfaces 1.2.x, the property getter was filled
like this:
public String getEnctype()
{
if (_enctype != null)
{
return _enctype;
}
ValueExpression vb = getValueExpression("enctype");
if (vb != null)
{
return (String) vb.getValue(getFacesContext().getELContext());
}
return "application/x-www-form-urlencoded";
}
In the RI, this is how the same property is handled:
public java.lang.String getEnctype() {
if (null != this.enctype) {
return this.enctype;
}
ValueExpression _ve = getValueExpression("enctype");
if (_ve != null) {
return (java.lang.String)
_ve.getValue(getFacesContext().getELContext());
} else {
return "application/x-www-form-urlencoded";
}
}
The use case that could fail is what happen if the ValueExpression just return
null? that null should be replaced by the default? or the null is a valid value
for the property?.
The javadoc of StateHelper.eval(Serializable key, Object defaultValue) says
this:
Performs the same logic as eval(java.io.Serializable) } but if no value is
found, this will return the specified defaultValue.
In that sense I think myfaces behavior is correct. It there is a VE bound to
the property, evaluate and return. If an specific property requires ignore the
null value and use the default one, it is more easier to write the necessary
code than force all users the previous behavior.
If no objections, I'll close this issue as invalid.
> StateHelper.eval(Serializable, Object) completely ignores default value in
> case of ValueExpression evaluation to null
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: MYFACES-2961
> URL: https://issues.apache.org/jira/browse/MYFACES-2961
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-314
> Affects Versions: 2.0.3-SNAPSHOT
> Reporter: Nick Belaevski
>
> When StateHelper(Serializable, Object) is called in Mojarra & component has
> no local value but ValueExpression for this attribute that returns null,
> default value is returned.
> Looking over MyFaces code, defaultValue passed in is not used at all if
> there's no local value and ValueExpression is defined.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.