You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Antoni Reus (JIRA)" <de...@myfaces.apache.org> on 2008/08/14 08:21:44 UTC

[jira] Created: (MYFACES-1904) Exception encoding selectOneMenu when value has an intermediate node null

Exception encoding selectOneMenu when value has an intermediate node null
-------------------------------------------------------------------------

                 Key: MYFACES-1904
                 URL: https://issues.apache.org/jira/browse/MYFACES-1904
             Project: MyFaces Core
          Issue Type: Bug
    Affects Versions: 1.2.3
         Environment: geronimo 2.1.2
            Reporter: Antoni Reus


I have a managed bean called "treeManager", with a "selectedNode" property that is null the first time.
I have three input components: 2 inputText, and a selectOneMenu, the JSP code is this:

...
<h:outputLabel for="nodeName" value="Nom"/>
<h:inputText id="nodeName" value="#{treeManager.selectedNode.name}" />

<h:outputLabel for="nodeDescription" value="Descripció"/>
<h:inputText id="nodeDescription" value="#{treeManager.selectedNode.description}"  />

<h:outputLabel for="ambitType" value="Àmbit"/>
<h:selectOneMenu id="ambitType" value="#{treeManager.selectedNode.ambit}">
  <f:selectItem itemLabel="Global" itemValue="global"/>
  <f:selectItem itemLabel="Organisme" itemValue="organisme"/>
  <f:selectItem itemLabel="Procediment" itemValue="procediment"/>
</h:selectOneMenu>
.... 


When I try the JSF I get this error.

|javax.faces.FacesException: Exception while calling encodeEnd on component : {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /dissenyador/estructures.jsp][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id_jsp_305935947_1]}|
| at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:610)|

Caused by: ...

|Caused by: org.apache.jasper.el.JspPropertyNotFoundException: /dissenyador/estructures.jsp(60,8) '#{treeManager.selectedNode.ambit}' Target Unreachable, 'selectedNode' returned null|
| at org.apache.jasper.el.JspValueExpression.getType(JspValueExpression.java:61)|
| at org.apache.myfaces.shared_impl.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:58)|
| at org.apache.myfaces.shared_impl.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:391)|
| at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.findUIOutputConverterFailSafe(HtmlRendererUtils.java:393)|
| at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.internalRenderSelect(HtmlRendererUtils.java:316)|
| at org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils.renderMenu(HtmlRendererUtils.java:288)|
| at org.apache.myfaces.shared_impl.renderkit.html.HtmlMenuRendererBase.encodeEnd(HtmlMenuRendererBase.java:57)|
| at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:607)|



Comments from Simon Kitching on the mailing list:

Interesting. From the stacktrace it look like the problem is when trying 
to determine the *type* that this expression returns.

When actually asking for the value, null is simply returned if the 
intermediate object is not there.

But when asking what static type of object would be returned from the 
bound property, of course there is a real problem if the intermediate 
node is not there.

Here's the code from SharedRendererUtils.findUIOutputConverter; the 
getType call is the problem:
        Class valueType = vb.getType(facesContext);  // boom when an 
intermediate node in the EL is null
        if (valueType == null) return null;

        if (String.class.equals(valueType)) return null;    //No 
converter needed for String type
        if (Object.class.equals(valueType)) return null;    //There is 
no converter for Object class

The HtmlRendererUtils.internalRenderSelect uses
  converter = findUIOutputConverterFailSafe
 -- which obviously is not quite so "fail safe" :-)

I'm not quite sure what the converter is being used for during rendering 
of the select component, but I do know that the rules about converters 
and select-components are quite complex. The HTML select component must 
always render strings for its options, but JSF requires typed objects to 
be passed between the select *component* and the backing beans. So 
conversions are required to be invoked at various times.

I think a JIRA issues should definitely be filed for this. If a 
converter is optional here, then the code should catch this exception 
and not use a converter. Even if a converter is mandatory (ie an error 
should be reported if the value-type cannot be determined) then at least 
the error reporting needs to be improved. And it is definitely a myfaces 
issue, not a Geronimo one.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.