Simple illustration of the problem:
// managed bean that has null property:
public class TestBean {
private String name;
public String getName() {
return name;
}
// Not-initialized bean property
private TestBean nullTestBean;
public TestBean getNullTestBean() {
return nullTestBean;
}
}
Test jsp:
<h:inputText id="riInputText" value="#{testBean.nullTestBean.name}" />
<t:inputText id="tomahawkInputText"
value="#{testBean.nullTestBean.name}" />
<tr:inputText id="trinidadInputText"
value="#{testBean.nullTestBean.name}" />
h: and t: produce input box with no problem, but tr: throws exception:
javax.faces.el.PropertyNotFoundException: Base is null: .nullTestBean
org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:474)
org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:172)
org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.ValueRenderer.getDefaultConverter(ValueRenderer.java:73)
org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.EditableValueRenderer.addOnSubmitConverterValidators(EditableValueRenderer.java:188)
org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleInputTextRenderer.encodeAllAsElement(SimpleInputTextRenderer.java:101)
org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormElementRenderer.encodeAll(FormElementRenderer.java:66)
org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderer.delegateRenderer(CoreRenderer.java:295)
Reason is the same as at ADFFACES-151 - getting default converter. I've
fixed it with changing getDefaultConverter to return null if value is
null:
ValueBinding binding = getValueBinding(bean);
if (binding == null || binding.getValue(context) == null)
return null;
But I don't know if such patch is correct and if it doesnt have side
effects.
Btw. how are such methods tested? I know only ValueRenderer ->
ValueRendererTest way but there is no such test. Yes there is
http://wiki.apache.org/myfaces/Trinidad_RenderKit_test_framework but as
I do understand that it tests outputs to desired markup, not util
methods.
Regards,
Martin
Martin Koci píše v Pá 29. 09. 2006 v 13:50 +0200:
> Yes, I can fill JIRA issue because ValueBindingImpl.isReadOnly catch
> Exception and return true, but should throw EvaluationException or
> PropertyNotFoundException. Or not?
> http://java.sun.com/javaee/javaserverfaces/1.1_01/docs/api/javax/faces/el/ValueBinding.html#isReadOnly(javax.faces.context.FacesContext)
>
> How it is solved in RI?
>
> Btw. that method in myfaces contains comment:
> // Cannot determine read-only, return true
> // (todo: is this what the spec requires,
> // MYFACES-686 suggests using true due to problems with alias bean?)
> return true;
>
>
>
> I've fixed it localy but there is still a issue with trinidad I think. I
> will investigate it and post results.
>
> Martin
>
> Matthias Wessendorf píše v Čt 28. 09. 2006 v 19:29 +0200:
> > Martin,
> > can you do that?
> >
> > On 9/28/06, Adam Winer <[EMAIL PROTECTED]> wrote:
> > > On 9/28/06, Martin Koci <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Hello,
> > > >
> > > > as http://issues.apache.org/jira/browse/ADFFACES-151 is fixed I found
> > > > that problem in SimpleInputTextRenderer. Is there a one right place
> > > > where solve that?
> > > >
> > > >
> > > > Other very strange bug is in EditableValueRenderer.getReadOnly:
> > > >
> > > > ValueBinding vb = getValueBinding(bean);
> > > >
> > > > if ((vb != null) && vb.isReadOnly(context))
> > > > {
> > > > return true;
> > > > }
> > > >
> > > > It returns true even if valueBinding cannot be resolved! It's probably a
> > > > bug in myfaces 1.1.4 - vb.isReadOnly returns true for all properties
> > > > that cannot be resolved.
> > > >
> > > > I solved that problem with changing 'if' to:
> > > >
> > > > if ((vb != null) && vb.getValue(context) != null &&
> > > > vb.isReadOnly(context))
> > >
> > >
> > >
> > > -1 to that; if there's a 1.1.4 bug, it should get filed...
> > >
> > > -- Adam
> > >
> > >
> >
> >
>
>