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
Felipe OliveiraFelipe Oliveira 

help with actionFunction and object validation

Hi,

I'm having a problem using the actionFunction

My page have a buttom [Add New Car] that creates a empty Custom Object and show a form to allow the user to define the object properties

 

PAGE

<apex:form >
  <apex:actionFunction name="Add_Car" action="{!showAdd_Car}" rerender="Container_Car" status="myStatus" />

  <apex:actionFunction name="CancelAction" action="{!cancelActionr}" rerender="Container_Car" status="myStatus" />

.....

<a class="btn" onclick="Add_Car();" href="#">Add a new Car</a>

......

<apex:outputPanel id="Container_Car" rendered="{!IF(showForm=='showAdd_Car', 'true', 'false')}">
   <h3>New Car</h3>

   <apex:inputField value="{!currentCar.Name}" />

......

<a class="btn" href="#" onclick="SaveObject();">Save Changes</a>
<a class="btn" href="#" onclick="CancelAction();">Cancel</a>


</apex:outputPanel>

 

</apex:form>

 

CONTROLLER

 

public PageReference showAdd_ShipToAddress() {
  currentCar = new Car__c(); 
  showForm = 'showAdd_Car';
  return null;
}

 

public PageReference cancelAction () {
    currentCar = new Car__c();
   return null;
}

 

______________________________________________________________________


The first part, show the form, works great. 

My problem is the cancel action.

When I click on the cancel button, the server side is called, but before my action cancelAction be called, the currentCar object is validated and return some message errors because the inputFields for the validade properties are empty.

 

Is it possible to disable the object validation before I submit? 

Or how do I intercept the call before the object is validade in the controller?

 

thanks a lot

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

Try 

 

<apex:actionFunction name="CancelAction" action="{!cancelActionr}" immediate="true" rerender="Container_Car" status="myStatus" />

 Regards

All Answers

SeAlVaSeAlVa

Try 

 

<apex:actionFunction name="CancelAction" action="{!cancelActionr}" immediate="true" rerender="Container_Car" status="myStatus" />

 Regards

This was selected as the best answer
Felipe OliveiraFelipe Oliveira

thanks a lot!