1

Here I want to insert one record on clicking "Post" button, at the same time I don't want to execute code in "First" pageblocksection (avoid all required fields).

 <apex:pageBlockSection id="First">
            //// HERE I HAVE SOME REQUIRED FIELDS 
  <apex:pageBlockSection>

// I Want to Execute following section without any Interference of above PageBlockSection- First
    <apex:pageBlockSection > 
           <apex:actionRegion immediate="true"> 
               <apex:selectList value="{!selectedID}" size="1" label="Select ">
                      <apex:selectOptions value="{!selected}"></apex:selectOptions>
               </apex:selectList>
               <apex:inputTextarea value="{!obj.Body}" label="Enter body : "/>
               <apex:commandButton value="Post" action="{!postMethod}"/>            
           </apex:actionRegion>
        </apex:pageBlockSection>
  • 1
    I'm pretty certain actionRegion only applies when you are using the partial page refresh feature. What you have will post the entire page. – pchittum Nov 20 '14 at 10:33
1

It's been a while, and I'm flying free here without testing, but I'm pretty certain you need to also specify to rerender just the part of the page you want to post back. Otherwise the action will post the entire page anyway. So it should look something like this:

<apex:pageBlockSection id="First">
        //// HERE I HAVE SOME REQUIRED FIELDS 
<apex:pageBlockSection>

// I Want to Execute following section without any Interference of above PageBlockSection- First
<apex:pageBlockSection id="postBack" >  <----added an element Id
       <apex:actionRegion> 
           <apex:selectList value="{!selectedID}" size="1" label="Select ">
                  <apex:selectOptions value="{!selected}"></apex:selectOptions>
           </apex:selectList>
           <apex:inputTextarea value="{!obj.Body}" label="Enter body : "/>
           <apex:commandButton reRender="postBack" value="Post" action="{!postMethod}"/>            
       </apex:actionRegion>             ^----added the rerender to refresh the 
    </apex:pageBlockSection>                 containing section

There are a couple of other things:

  1. Your method you execute from the command button needs to be declared as void.
  2. You might look into the apex:actionStatus tag so you can tell users that the page is working
  3. You can point reRender to multiple element ID's. Just separate ID's by commas. rerender="this,that,theOther". The one part of the UI you will want to refresh in addition to this section is your apex:pageMessages tag, so that any errors that occur can be surfaced to the user.

Also, setting immediate="true" actually will result in data not being posted to the server. So you don't want that in this instance. The use case for this feature is a cancel button...allowing you to cancel out of a page without validating data, or other post backs where there is no need for data to go from client to server in order to complete the request (paging to the next set of results in a list, for instance).

0

You should put commandbutton inside actionregion

CommandButton or you can directly use immediate attribute in commandbutton.

  • I have commandbutton inside Action Region only. – Salesforce Steps Nov 20 '14 at 10:40
  • Please add immediate attribute to commandbutton and if it still doesnt work. Please post full code. – Piyush Kalra Nov 20 '14 at 10:51
0

Ok, I got the trick,

I put that pageblock sections in different <apex:Form> </apex:form>

But I was hoping that ActionRegion will work for me.

  • Nilesh, this should really be a comment to your original post. This is not an answer. – pchittum Nov 20 '14 at 10:54

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.