5

I have a simple table for displaying users...

<apex:page standardController="User" recordSetVar="Users" tabStyle="User">
  <apex:pageBlock >
  <apex:pageBlockSection title="Today’s usersRecords"> 
  <apex:form >
  <apex:pageBlockTable value="{!Users}" var="user" styleClass="list">
  <apex:column >
  <apex:facet name="header">Name</apex:facet>
  <apex:outputText value="{!user.Name}" />
  </apex:column>
   <apex:column >
  <apex:facet name="header">Push Email</apex:facet>
  <apex:inputCheckbox value="{!user.DM_APP_EMAIL__My_custom_field__c }" />
  </apex:column>
  </apex:pageBlockTable>
  <apex:pageBlock >
  <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!save}"/>
  </apex:pageBlockButtons>  
  </apex:pageBlock>
  </apex:form>
  </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

It only displays 25 users. How do I display more users?

Note: I want to keep things simple. No controller if possible.

2 Answers 2

6

I'm afraid we don't have a good news for you ;)

http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_sosc_pagination.htm

By default, a list controller returns 20 records on the page. To control the number of records displayed on each page, use a controller extension to set the pageSize.

So you either display the previous / next controls or there's a setPageSize() method on StandardSetController...

3

I'm taking a look at what you're trying to do, and I think you might want to reconsider.

You have a list of records, you display a custom checkbox field, and then you want to save the changes.

This will work, but there something is going to happen that you may not be aware of. When you click the save button, you will be saving every record in the list. So if you have a list of 50 users, and you check just one of the boxes, all 50 users will have their last modified fields updated. In a way, it spoils your audit of what has actually changed in your user records. For some companies, this can create a compliance problem. You're also forcing the platform to do a lot more work than it needs to (updating 50 instead of 1).

I know you state you don't want a controller, but for this reason, I would suggest you at least consider using one. For mass edits like this, there is a tried-and-true pattern called a Wrapper Class. It allows you to select only the records you want to change for update. Your code then sifts through the selected records, and if only 3 need to change, then only three will change.

It does increase the complexity of your page, but I would suggest that in most instances it is worth it, and it is definitely a best practice.

2
  • I am just setting up test data and want it done quickly. Thanks for you concerns.
    – dublintech
    Commented Jan 31, 2013 at 11:53
  • In that case, quick and dirty gets the job done. :-)
    – pchittum
    Commented Jan 31, 2013 at 12:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .