You need to sign in to do that
Don't have an account?
Command links not working inside repeat inside repeat
Command links with param are not working inside "repeat inside repeat" code. The action method attached to the command link is not getting invoked.
Any suggestions?
<apex:repeat value="{!listData}" var="l" rendered="{!NOT(ISNULL(listData))}">
<apex:repeat value="{!l.Items}" var="c"><tr>
<td>{!l.Title}</td>
<td>{!c.Description}</td>
<td>{!c.Name}</td>
<td>
<apex:commandLink value="View" action="{!viewId}">
<apex:param assignTo="{!selectedId}" name="selectedId" value="{!c.Id}" />
</apex:commandLink>
</td>
</tr>
</apex:repeat>
Hey Bob n All,
I got quite interesting solution, instead of using a commandLink or commandButton with param use JS function with an ActionFunction
<apex:outputPanel id="mainRepeatContainer">
<apex:repeat value="{!listData}" var="l" rendered="{!NOT(ISNULL(listData))}" id="repeatmain">
<apex:repeat value="{!l.Items}" var="c"><tr>
<td>{!l.Title}</td>
<td>{!c.Description}</td>
<td>{!c.Name}</td>
<td>
<a href="javascript:viewItem('{!c.Id}');">View</a>
</td>
</tr>
</apex:repeat>
</apex:outputPanel>
<apex:actionFunction action="{!viewItem}" name="viewItem" reRender="form" >
<apex:param name="selectedIdentifier" value="" assignTo="{!selectedIdentifier}"/>
</apex:actionFunction>
All Answers
I hit this problem a short while ago, but with command buttons rather than links.
I found that if my buttons caused a refresh of the entire page, then the parameters didn't get set. However, if I rerendered just the nested repeats then it worked.
Give re-rendering a shot and see if that helps.
Bob,
Changed commandLink to commandButton; Added rerender to commandButton, yet same output. Am I missing anything?
<apex:repeat value="{!listData}" var="l" rendered="{!NOT(ISNULL(listData))}" id="repeatmain">
<apex:repeat value="{!l.Items}" var="c"><tr>
<td>{!l.Title}</td>
<td>{!c.Description}</td>
<td>{!c.Name}</td>
<td>
<apex:commandButton value="View" action="{!viewId}" rerender="repeatmain">
<apex:param assignTo="{!selectedId}" name="selectedId" value="{!c.Id}" />
</apex:commandButton >
</td>
</tr>
</apex:repeat>
Bob, gotcha .. I tried the same and it didn't worked (I was trying the same solution and in the mean time received your comment, Thanks!)
Tried enclosing not only the main repeat, but also the container form with a outputPanel to be rendered by command button, but neither worked. The controller function is still not getting invoked.
The only other area I've had problems with around this is using 'id' in the parameter name, as they get posted back using that name on the URL and sometimes that causes confusion - I usually change the id at the end of the name to ident.
Last roll of the dice from me - try changing your action method to viewIdent and the parameter to selectedIdent.
Bob, apologies but this time too it didn't worked
<apex:outputPanel id="mainRepeatContainer">
<apex:repeat value="{!listData}" var="l" rendered="{!NOT(ISNULL(listData))}" id="repeatmain">
<apex:repeat value="{!l.Items}" var="c"><tr>
<td>{!l.Title}</td>
<td>{!c.Description}</td>
<td>{!c.Name}</td>
<td>
<apex:commandButton value="View" action="{!viewItem}" rerender="mainRepeatContainer">
<apex:param assignTo="{!selectedIdentifer}" name="selectedIdentifer" value="{!c.Id}" />
</apex:commandButton >
</td>
</tr>
</apex:repeat>
</apex:outputPanel>
Hey Bob n All,
I got quite interesting solution, instead of using a commandLink or commandButton with param use JS function with an ActionFunction
<apex:outputPanel id="mainRepeatContainer">
<apex:repeat value="{!listData}" var="l" rendered="{!NOT(ISNULL(listData))}" id="repeatmain">
<apex:repeat value="{!l.Items}" var="c"><tr>
<td>{!l.Title}</td>
<td>{!c.Description}</td>
<td>{!c.Name}</td>
<td>
<a href="javascript:viewItem('{!c.Id}');">View</a>
</td>
</tr>
</apex:repeat>
</apex:outputPanel>
<apex:actionFunction action="{!viewItem}" name="viewItem" reRender="form" >
<apex:param name="selectedIdentifier" value="" assignTo="{!selectedIdentifier}"/>
</apex:actionFunction>
Thanks for sharing this. I can't believe that it's been 6 years but still not fixed. Thansk !