1

Very straight forward listview table of account records - see apex:pageblocktable below

Within this account listview table, we have a checkbox field at the account object as shown in our listview. The user can check this box in the account listview

apex:inputField value="{!a.Worked__c}" .

I need to save these checked Account Records when the user clicks on the apex:commandbutton to move as shown in the action="{!first}" or "{!previous}" call button selected.

I need to save the selected apex:inputField value="{!a.Worked__c}" / using the "ONCOMPLETE" attribute in the apex:commandbutton

EXAMPLE:

<apex:commandbutton  action="{!first}" 
                     value="First Group" 
                     ONCOMPLETE="{!xxSaveSelectedRecordsxx}">
</apex:commandbutton>

Example ListView Table of Account Records:

<apex:pageBlockTable id="AccountList" value="{!Accounts}" var="a">

<apex:column value="{!a.Id}"/>

<apex:column value="{!a.Name}"/>

<apex:column headerValue="Worked?">
<apex:inputField value="{!a.Worked__c}"   />
</apex:column>

<apex:column value="{!a.Phone}"/>
</apex:pageBlockTable>

ListView Table w/Selected Records to be saved with CommandButton - But on the "action" command because it has already been taken...

Example Nav Buttons:

<apex:commandbutton  action="{!first}" value="First Group" </apex:commandbutton>
<apex:commandbutton action="{!previous}" value=" Previous Group" rendered="{!hasPrevious}"></apex:commandbutton>
<apex:commandbutton action="{!next}"  value="Next Group >"  rendered="{!hasNext}"></apex:commandbutton>
<apex:commandbutton   action="{!last}" value="Last Group"></apex:commandbutton>

oncomplete String - The JavaScript invoked when the result of an AJAX update request completes on the client.

Thanks for your help....

  • It seems that you haven't written the whole information (missing images). Can you please complete it ? – S.Sharma Jul 23 '13 at 7:00
  • Yes, It is not entirely clear what you are asking for to me either. I believe the oncomplete attribute is meant to trigger some javascript after the specified action is performed and can not not perform additional controller logic. – Samuel De Rycke Jul 23 '13 at 7:42
1

You have the logic backwards: you need to save and then navigate. Of course, you could have combined them together in the controller, but lets say, for sake of argument, you wanted to keep them separated:

<apex:actionFunction name="firstPage" action="{!first}" reRender="form" />

You can then call those functions in response to oncomplete:

<apex:commandButton action="{!saveData}" oncomplete="firstPage()" reRender="form" />

Note that "completed" fires even if there was an error, so you probably wouldn't want to use this technique in normal usage, although a cleverly designed page wouldn't have a problem with this type of logic.

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.