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 <ar...@git.es> on 2008/08/13 14:30:44 UTC

Problem rendering selectOneMenu

||Hi,

Recently I came around a problem testing my app with geronimo 2.1.2 
(myfaces 1.2.3).

The app is working well in jboss 4.2 (JSF RI 1.2_04), and I'm trying it 
with geronimo 2.1.2 (myfaces 1.2.3).


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)|


Don't know if this is correct, because its true that selectedNode 
evaluates to null, but no exception is thrown when rendering the two 
previus inputText that also reference selectedNode.

Is this correct? Should I file a bug report?




-- 
-------------------------
Antoni Reus Darder
GIT Consultors S.L.
c/ Francesc Rover 2-B
07003 Palma de Mallorca
Illes Balears
mail: areus@git.es
Tel: + 34 971 49 83 10
Fax: + 34 971 49 61 89 


Re: Problem rendering selectOneMenu

Posted by Antoni Reus <ar...@git.es>.
En/na simon.kitching@chello.at ha escrit:
> Antoni Reus schrieb:
>> ||Hi,
>>
>> Recently I came around a problem testing my app with geronimo 2.1.2 
>> (myfaces 1.2.3).
>>
>> The app is working well in jboss 4.2 (JSF RI 1.2_04), and I'm trying 
>> it with geronimo 2.1.2 (myfaces 1.2.3).
>>
>>
>> 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)| 
>>
>>
>>
>> Don't know if this is correct, because its true that selectedNode 
>> evaluates to null, but no exception is thrown when rendering the two 
>> previus inputText that also reference selectedNode.
>>
>> Is this correct? Should I file a bug report?
>
> 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.
>
> Just as a side-note, please report issues like this to the user list 
> in future. The myfaces developers are also subscribed to that...
>
> Regards, Simon
>
>
Thanks for your response,
I created a JIRA issue for this, MYFACES-1904, and included your comments.

And ... sorry for posting on the wrong list.

-- 
-------------------------
Antoni Reus Darder
GIT Consultors S.L.
c/ Francesc Rover 2-B
07003 Palma de Mallorca
Illes Balears
mail: areus@git.es
Tel: + 34 971 49 83 10
Fax: + 34 971 49 61 89 


Re: Problem rendering selectOneMenu

Posted by "simon.kitching@chello.at" <si...@chello.at>.
Antoni Reus schrieb:
> ||Hi,
>
> Recently I came around a problem testing my app with geronimo 2.1.2 
> (myfaces 1.2.3).
>
> The app is working well in jboss 4.2 (JSF RI 1.2_04), and I'm trying 
> it with geronimo 2.1.2 (myfaces 1.2.3).
>
>
> 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)| 
>
>
>
> Don't know if this is correct, because its true that selectedNode 
> evaluates to null, but no exception is thrown when rendering the two 
> previus inputText that also reference selectedNode.
>
> Is this correct? Should I file a bug report?

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.

Just as a side-note, please report issues like this to the user list in 
future. The myfaces developers are also subscribed to that...

Regards, Simon