How to make a4j:commandLink execute action and show modalpanel?

user1415683 picture user1415683 · Aug 16, 2012 · Viewed 20.3k times · Source

Jsf 1.2, Richfaces 3.3.3,

I got the following code working to show a richfaces:modalpanel:

<ui:repeat id="albums" var="listvalue" 
    value="#{MyBean.getImagelist()}">
    <a4j:commandLink id="link" reRender="panel">
        <h:graphicImage id="image" url="My_image.jpg"/>
        <rich:componentControl for="panel" attachTo="link" operation="show"
            event="onclick"/>
    </a4j:commandLink>
</ui:repeat>

It works and the modalpanel is shown, but what I couldn't manage to do is call a method that is on MyBean, how do I do that?

UPDATE 1

I forgot to mention that i need to pass a <f:param> on that action

UPDATE 2

As requested, here's the exact code i have:

<ui:repeat id="al11" var="albumslistvalue1" 
value="#{AlbumDetailBean.getAlbumImagesList()}">
  <a4j:commandLink id="link" action="#{AlbumDetailBean.mudaIdatual()}" 
    reRender="panel"
    oncomplete="javascript:Richfaces.showModalPanel('panel');" >
    <a4j:actionparam name="idfotoatual" value="#{albumslistvalue1.id}" />
    <h:graphicImage id="image" 
    url="#{albumslistvalue1.albumimagename}"/>
   </a4j:commandLink>
</ui:repeat>

Answer

dcernahoschi picture dcernahoschi · Aug 16, 2012

I suppose you want the action called onclicking the link. I so, try the following:

<a4j:commandLink id="link" action="#{myBean.myAction}" reRender="panel"
    oncomplete="Richfaces.showModalPanel('panel');">
      <a4j:actionparam assignTo="#{yourParam}" value="#{yourParamValue}"/>
    <h:graphicImage id="image" url="My_image.jpg"/>
</a4j:commandLink>

UPDATE: added param as requested.