function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chirag MehtaChirag Mehta 

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>

Message Edited by Chirag Mehta on 03-10-2010 10:36 AM
Best Answer chosen by Admin (Salesforce Developers) 
Chirag MehtaChirag Mehta

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>  

Message Edited by Chirag Mehta on 03-11-2010 11:30 AM

All Answers

bob_buzzardbob_buzzard

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. 

Chirag MehtaChirag Mehta

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_buzzardbob_buzzard
The only difference to mine is that I have an outputpanel around the initial repeat, which is what gets rerendered.  Shouldn't make any odds, but worth a try.
Chirag MehtaChirag Mehta

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.

bob_buzzardbob_buzzard

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.

Chirag MehtaChirag Mehta

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> 

 

 

 

 

Chirag MehtaChirag Mehta

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>  

Message Edited by Chirag Mehta on 03-11-2010 11:30 AM
This was selected as the best answer
bob_buzzardbob_buzzard
Good to know.
Sandeep Mishra 7Sandeep Mishra 7
@Chirag Mehta,

Thanks for sharing this. I can't believe that it's been 6 years but still not fixed. Thansk !