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
PrattyPratty 

Using apex:param inside repeat component

Hello all,

 

I have to used param tag inside commandLink under repeat tag but fail to get param value.

 

Here's code,

 

   <apex:repeat value="{!lstNumbers}" var="num">
                <apex:commandLink value="{!num}"     action="{!nextPage}"  >
                <apex:param      name="selectedPage"       value="{!num}"      assignTo="{!selectedPage}"/>
                 <apex:actionSupport        event="onclick"        action="{!nextPage}"      reRender="frm,projtable" />
                </apex:commandlink>
  </apex:repeat>

 

 

// Controller Code

 

public string selectedPage {get; set;}

public void nextPage()
    {
        Error.LogError('In nextPage' + selectedPage); // this only prints In nextPage.
        lstContactForRegisteredVol.Clear();
        lstContactForRegisteredVol = mapContactsForPagination.get(selectedPage);
    }

 

can anybody help me to get through this.

 

Regards,

 

Pratty

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You have the param tag nested inside the command link, but I think the onclick handler will hijack the event and that doesn't have any params.

 

You shouldn't need the actionsupport - just add a rerender attribute to the commandlink:

 

<apex:repeat value="{!lstNumbers}" var="num">
    <apex:commandLink value="{!num}"     action="{!nextPage}"  rerender='frm,projtable">
       <apex:param      name="selectedPage"       value="{!num}"      assignTo="{!selectedPage}"/>
    </apex:commandlink>
  </apex:repeat>

 

All Answers

bob_buzzardbob_buzzard

You have the param tag nested inside the command link, but I think the onclick handler will hijack the event and that doesn't have any params.

 

You shouldn't need the actionsupport - just add a rerender attribute to the commandlink:

 

<apex:repeat value="{!lstNumbers}" var="num">
    <apex:commandLink value="{!num}"     action="{!nextPage}"  rerender='frm,projtable">
       <apex:param      name="selectedPage"       value="{!num}"      assignTo="{!selectedPage}"/>
    </apex:commandlink>
  </apex:repeat>

 

This was selected as the best answer
PrattyPratty

Hey it works fine thank you very much.