Apex:actionRegion not working with Apex:actionFunction

One of my friend was using apex:inputFile on a Visual force page, and he also needs to reRender some information on the same page. If we need to use both together, we have to use apex:actionRegion in order to isolate apex:inputFile (because inputFile doesn’t support reRender and throws error).

He was also doing the same thing but the state of information was not maintained, See the below psuedo code to get an idea of code

You will think that the above code will work fine, But It won’t!

Issue In the Above Code

Let’s say you are using a list of contact in editable mode where user can add or remove rows and update the information of contact.
User has added one row and filled the information, Now he clicked on some button to add one more row. To add row, function “myFun” (placed in actionRegion 1) is invoked. Here the information for first row of contact will go away on reRender of myInfo panel.

Solution/ Workaround

As of now, after doing some research and hit and trial approach  I have found one workaround or you can say solution. Instead of putting apex:actionFuntion and your part which needs to reRendered put them in a single actionRegion. So the updated code (working) will be as follows.

Reason/Explanation

For now there is no 100% correct explanation behind this behavior. May be actionFunction sends only information of apex:actionRegion in which it is placed to the server. For example if actionFunction is in actionRegion A, then it will send information from actionRegion A to the server. May Be my assumption is wrong. So for now no solid reason, but we have solution. So for now just solve this issue and move faster to meet your deadlines.

Leave a Reply

Your email address will not be published. Required fields are marked *