Rich Tooltip for SelectItem, error when including EL in "for" attribute

Posted by pakore on Stack Overflow See other posts from Stack Overflow or by pakore
Published on 2010-04-22T10:37:48Z Indexed on 2010/04/22 10:43 UTC
Read the original article Hit count: 493

Filed under:
|

How to attach a rich:tooltip to the list generated by f:selectItems when using a variable for the attribute for inside the rich:tooltip.

This code works fine (the value of #{prefix} is theprefixvalue

<ui:composition>
<a4j:form id="#{prefix}_form">
<h:selectOneRadio style="text-align:left" id="#{prefix}_rating">
<f:selectItems value="#{test.options}"></f:selectItems>
</h:selectOneRadio>&nbsp; 
<rich:toolTip for="theprefixvalue_form\:theprefixvalue_rating\:0">a</rich:toolTip>      
</a4j:form>
</ui:composition>

But this code does not:

<ui:composition>
<h:outputText value="#{prefix}" />
<a4j:form id="#{prefix}_form">
<h:selectOneRadio style="text-align:left" id="#{prefix}_rating">
<f:selectItems value="#{test.options}"></f:selectItems>
</h:selectOneRadio>&nbsp; 
<rich:toolTip for="#{prefix}_form\:#{prefix}_rating\:0">a</rich:toolTip>        
</a4j:form>
</ui:composition>

Throws the following exception:

Caused by: java.lang.IllegalArgumentException: theprefixvalue_rating
    at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:612)
    at org.ajax4jsf.renderkit.RendererUtils.findComponentFor(RendererUtils.java:1037)
    at org.richfaces.renderkit.html.ToolTipRenderer.getTargetId(ToolTipRenderer.java:234)
    at org.richfaces.renderkit.html.ToolTipRenderer.constructJSVariable(ToolTipRenderer.java:251)
...

TestBean is session scoped and this is the code for getOptions();

public List<SelectItem> getOptions(){
    List<SelectItem> options = new ArrayList<SelectItem>();
    options.add(new SelectItem("a","a"));
    options.add(new SelectItem("b","b"));
    options.add(new SelectItem("c","c"));
    return options;

}

Any ideas? The goal is to have a tooltip when the mouse is over the different options. Thanks in advance.

© Stack Overflow or respective owner

Related posts about jsf

Related posts about richfaces