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
Arun BalaArun Bala 

CommandButton & oncomplete ..

Folks,
Have anyone ever tried to use the oncomplete attribute on a command button ? I am facing one weird issue.

<apex:commandButton styleClass="btn" value="Save" action="{!saveAction}" id="save" oncomplete="checkError();"/>

Now on click of the button when the save action fails as a result of some required fields not filled in, the fields are not getting highlighted as they would typically. When I remove the oncomplete definition, they get highlighted. My
gut feeling is that our own definition of oncomplete overrides something that salesforce has defined for commandButton on completion of an ajax request. Any takers ??


Thanks.


Message Edited by Arun Bala on 12-30-2008 08:14 PM
Best Answer chosen by Admin (Salesforce Developers) 
dchasmandchasman
Not exactly - the issue is that as soon as you use oncomplete /or rerender you put the VF engine into partial page update mode and you have not indicated any target components to rerender (via the rerender attribute on apex:commandButton in this case). The result is that no visual updates are going to be performed. Just id a container component or components for the areas of the page you want to have updated and reference those id(s) via <apex:commandButton rerender>.

All Answers

dchasmandchasman
Not exactly - the issue is that as soon as you use oncomplete /or rerender you put the VF engine into partial page update mode and you have not indicated any target components to rerender (via the rerender attribute on apex:commandButton in this case). The result is that no visual updates are going to be performed. Just id a container component or components for the areas of the page you want to have updated and reference those id(s) via <apex:commandButton rerender>.
This was selected as the best answer
Arun BalaArun Bala
ah .. its my silly mistake Doug.. thanks for pointing it out .. the rerender fix solved a couple of my other issues as well. Thanks.
Abhik DeyAbhik Dey
Hi All,

I am putting the question in this thread only since its almost related to the above.

I am using <apex:commandButton value="Next" action="{!method1}" rerender="test" oncomplete="complete1();"/>

Once the method1 executes, it updates a boolean variable to 'true' and in the constructor this variable value is set as false

public void method1(){
                fieldstatus='true';
                //system.debug('fieldstatus:'+fieldstatus);
    }
Now on VF page , i want to access this variable value so used oncomplete, but in the oncomplete function i always got the value as false.

function complete1() {
        var check1= '{!fieldstatus}';
        alert(check1);
        }

Any idea why this wierd behaviour?
Abhik DeyAbhik Dey
got the answer
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000BCRW