5

I have this basic page below

<apex:page controller="basic">
<apex:pageMessages ></apex:pageMessages>
  <apex:form >
  <apex:outputPanel id="C">

  <apex:outputPanel id="B">
  <apex:inputtext value="{!input1}"  required="true"  />
  </apex:outputPanel>


  <apex:actionregion>
   <apex:outputPanel id="a">
  <apex:inputtext value="{!input2}"     />
   </apex:outputPanel>  
  <apex:commandButton value="save" reRender="C" />
<!--if i remove rerender attribute altogether it 
  </apex:actionregion>

 </apex:outputPanel>
  </apex:form>
</apex:page>

and controller is very basic with just getters and setters

Scenario:I never enter the required input1 so that validation error is forced

My main trouble is if i remove rerender from commandbutton enclosed in actionregion--it throws error if i change rerender so as to rerender everything/some part --it doesn't throw error

whats the reason behind you need a rerender for action region to work.As far as i know actionregion submits data enclosed in action region tag so lifecycle as i understand is

  • decode view state(applicable only for things inside action region)

  • evaluate setters for action:region components

  • validation check for actionregion related components

  • If everything fine,update view state

    say there is no rerender attribute for commandbutton

  • getters are invoked for all components

now where in this stage can possibly cause error if rerender is taken away?

can somebody explain where am i going wrong in the concept?

1 Answer 1

9

Action Regions require a reRender attribute to be effective. The point of an Action Region is to refresh only part of the page, using only the data that is contained in the Action Region. This is commonly used to isolate apex:inputFile fields, which can't be used with reRender at all, and also to avoid validation errors that may occur while trying to update the page while some standard validations exist in the page.

If you have identified a use for an Action Region, you must also be prepared to use reRender, because the two work hand-in-hand. When you do not use a reRender attribute, the entire page state is submitted and validated before attempting to run any controller logic. Using the Action Region will restrict validation to just that section of the page, but also usually prevents updates from occurring outside the action region area.

Traditionally, I've used this to do things like loading a contact's address fields into the page when the contact is changed in a lookup field. Validation rules could prevent this code from running successfully, and so the Action Region serves as a way to isolate part of the page and allow the controller to run normally when it otherwise would produce Visualforce errors.

You must log in to answer this question.

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