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
unidhaunidha 

How can I ensure all the actionSupport completed before Apex:commandlink get executed?

Hi,

 

I am not sure this is a right place or not, but let me explain about this.

 

I have Apex page and apex component . Click here to see my  page structure.

 

At page level I have tab that constructed dynamically  and component like simplified code below.

 

Tab code at page level

  <apex:repeat value="{!segmentSelected}" var="seg">
            <li class="{!IF(ISNULL($CurrentPage.parameters.segmentTab) && rowNum == 1,'ui-tabs-active',IF($CurrentPage.parameters.segmentTab == seg,'ui-tabs-active',''))}"  style="padding: 0px !important;">
                      <span style="float:left;font-size:14px;align:center;margin-top:5px;margin-left:0px">
                    <apex:commandLink  value="{!seg}" rerender="segment,report">
                        <apex:param name="segmentTab1" value="{!seg}" />
                        <apex:param name="segmentTab2" value="{!seg}" />
                    </apex:commandLink>
                </span>
            </li>
			<apex:variable var="rowNum" value="{!rowNum + 1}"/>
 </apex:repeat>

 

Component code

 <apex:component controller="MyReport" access="global" allowDML="true"> 
  <apex:repeat value="{!mylist}" var="c">
    <td class="comments">
<apex:inputTextArea style="border: none;width:420px;resize:none;" styleclass="txtaresexpone" value="{!c.Comments__c}"> <apex:actionSupport action="{!saveMyList}" status="inProgress" event="onchange" rerender="dummy"> </apex:actionsupport> </apex:inputTextarea></td> </apex:repeat> </apex:component>

 

Each tab represent different data with the same Object type.Component will display the detail of the Object based on the tab.Example the user click Tab 1 contain value Emp Name, the component will render the Emp Detail that belong to Tab 1.

 

The issue is when user update multiple field of  Emp Detail in component and directly click on different tab.The system is using actionSupport to save the detail, and if the user directly click on different tab after updating field from different tab, the system will save some of the detail with the recent clicked  tab while the data should belong to previous tab.

 

How I can control this? Is there any function that will ensure all the actionSupport completed before the apex:commandlink get executed?

 

Note: I already put actionStatus for every actionSupport but still is not helping.

 

Thanks,

unidha

Best Answer chosen by Admin (Salesforce Developers) 
unidhaunidha

Hi firechimp,

 

That is very nice idea.I also find out using two action support with different event helps me.But I am not sure if it best practise.

 

 <apex:component controller="MyReport" access="global" allowDML="true"> 
  <apex:repeat value="{!mylist}" var="c">
      <td class="comments">
<apex:inputTextArea value="{!c.Comments__c}"> <apex:actionSupport action="{!saveMyList}" status="inProgress" event="onchange" rerender="dummy"> </apex:actionsupport> <apex:actionSupport action="{!saveMyList}" status="inProgress" event="onblur" rerender="dummy"> </apex:actionsupport> </apex:inputTextarea> </td> </apex:repeat> </apex:component>

 

All Answers

firechimpfirechimp

Hi Unidha,

You could try disabling the click of the tab from the onSubmit event on your actionSupport, then re-enable the click of the tab from the onComplete event on your action support.

 

For info on action support click Here.

 

Hope this helps!

 

unidhaunidha

Hi firechimp,

 

That is very nice idea.I also find out using two action support with different event helps me.But I am not sure if it best practise.

 

 <apex:component controller="MyReport" access="global" allowDML="true"> 
  <apex:repeat value="{!mylist}" var="c">
      <td class="comments">
<apex:inputTextArea value="{!c.Comments__c}"> <apex:actionSupport action="{!saveMyList}" status="inProgress" event="onchange" rerender="dummy"> </apex:actionsupport> <apex:actionSupport action="{!saveMyList}" status="inProgress" event="onblur" rerender="dummy"> </apex:actionsupport> </apex:inputTextarea> </td> </apex:repeat> </apex:component>

 

This was selected as the best answer