1

I'm getting <f:param> i.e., menuItemIndex value as null during my ajax call. Is it because it is with in <h:graphicImage> ??? Can any one suggest please? Note: Parameter is getting passed if I use <h:commandLink> instead of <h:graphicImage>.

 <c:forEach items="#{cc.attrs.value}" var="menuItem" varStatus="loopItem">
 ....
    <ui:fragment rendered="#{menuItem.hasChildren}">
        <h:graphicImage library="images" name="#{menuItem.symbol}">
           <f:ajax render=":fatcaForm:myMenu:menuID" event="click" listener="#{menuBean.refreshMenu}" />
           <f:param name="menuItemIndex" value="{loopItem.count}" />
        </h:graphicImage>
    </ui:fragment>
  ....
 </c:forEach>
MyFist
  • 413
  • 7
  • 19

1 Answers1

1

The <h:graphicImage> is not a command component and it does therefore not support <f:param> children at all. The <f:param> works only when nested in an UICommand component, such as <h:commandLink> as you found out yourself.

So, this should do:

<h:commandLink action="#{menuBean.refreshMenu}">
    <h:graphicImage library="images" name="#{menuItem.symbol}" />
    <f:ajax render=":fatcaForm:myMenu:menuID" />
    <f:param name="menuItemIndex" value="#{loopItem.count}" />
</h:commandLink>

(note that I fixed the EL syntax error in the <f:param value> as well)


Unrelated to the concrete problem, how you used the <h:graphicImage library> is not entirely right. Please carefully read What is the JSF resource library for and how should it be used?

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thx a lot but my image is getting placed inside a square BORDER when using your code (i.e., `` inside ``). how to get rid of it? functionality is working though. – MyFist Dec 19 '12 at 00:40
  • That's just a styling matter. Just add `a img { border: 0; }` to CSS. – BalusC Dec 19 '12 at 00:57