1

Trying to get the values to my Controller that I can change the limit on the displayed List on my Page. I'm Using a dynamic query and everything is working fine but what's below. What am I'm missing?

If instead of selectOption, I use CommandLink that calls the same Action it works, but don't want that. I want selectOption to work!

<apex:selectList value="{! PageSize }" size="1" id="resultLimit">
   <apex:selectOption itemValue="5" itemLabel="5">
      <apex:param value="5" name="5" assignTo="{!rowLimit}"/>
   </apex:selectOption>
   <apex:selectOption itemValue="5" itemLabel="5">
      <apex:param value="5" name="5" assignTo="{!rowLimit}"/>
   </apex:selectOption>
   <apex:selectOption itemValue="10" itemLabel="10">
      <apex:param value="10" name="10" assignTo="{!rowLimit}" />
   </apex:selectOption>
   <apex:selectOption itemValue="20" itemLabel="20">
      <apex:param value="20" name="20" assignTo="{!rowLimit}" />
   </apex:selectOption>
<apex:actionSupport event="onchange" reRender="results" action="{!resetList}"  status="myStatus"/>
</apex:selectList> 

On Controller :

public String rowLimit = '5';
public String getRowLimit()   {
     if (rowLimit == null || rowLimit == '') {
          return '5'; 
     }
    else {
     return rowLimit;
    }
 }
public void setRowLimit(String limitExp)
   {  
     rowLimit = limitExp;
   }

public void resetList () {
 /* This Method Run the Dynamic Query and reset the List Table on Page */
}
  • the problem seems like for some reason I cannot set the rowLimit Value? – sfdx bomb Jun 14 '15 at 15:22
2

Since PageSize will already hold the selected value, I don't think there is a need to use apex:param. You can directly use PageSize to build a Dynamic Query.

<apex:selectList value="{!PageSize}" size="1" id="resultLimit">
<apex:selectOption itemValue="5" itemLabel="5"/>
<apex:selectOption itemValue="10" itemLabel="10"/>
<apex:selectOption itemValue="20" itemLabel="20"/>
<apex:selectOption itemValue="30" itemLabel="30"/>
<apex:selectOption itemValue="40" itemLabel="40"/>
</apex:selectList>

Whatever value you select, will be stored in PageSize variable.

  • yep thanks.. Changed PageSize to rowLimit and removed all the apex:param..Now it works Fine :) – sfdx bomb Jun 14 '15 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.