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
jojoforcejojoforce 

AJAX Multiple actionStatus calling two different apex:actionStatus

Is it possible for 1 action call two seperate action status? 

 

for example,

 

<apex:commandButton id="btnID" status="status1,status2" action="{!someAction}" value="Click Me"/>
 
<apex:actionStatus id="status1">
.....
</apex:actionStatus>

 
<apex:actionStatus id="status2">
.......
</apex:actionStatus>

 
 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I see.  I tend to use one of two mechanisms (or a combinaton of both) when I need this:

 

(1) Grey out the rest of the page and popup a 'working' dialog or similar

(2) Use Jquery to locate and disable all input fields on the page 

All Answers

bob_buzzardbob_buzzard

Doesn't look like it - when I try it, although there are no errors on the markup or reported by the browser, neither of the actionstatus components changes to reflect the request.  When I change it to a single status, it works fine.

 

The docs say that the status attribute takes an ID rather than one or more IDs.

jojoforcejojoforce

Thanks bob buzzard... 

 

The only way I could tihnk of making it work is to potentially have an actionSupport to call that status as well... but the problem might be a timing issue since status1 and status2 might potentially not finish the same time.

 

<apex:page controller="testController">


<apex:actionStatus id="status1" startText="Status1 Started....." stopText="Status1 Stopped.....">
</apex:actionStatus>

<apex:actionStatus id="status2" startText="Status2 Started....." stopText="Status2 Stopped.....">
</apex:actionStatus>


<apex:form >


    <apex:commandButton action="{!DoNothing}" status="status1" value="Hello World" rerender="outputID">
        <apex:actionSupport event="onclick" status="status2" rerender="outputID"/>
    </apex:commandButton>    
    
    <apex:outputText id="outputID" value="{!StringValue}"></apex:outputText>
    

</apex:form>


</apex:page>

 

bob_buzzardbob_buzzard

I think you'll get a race condition with your postbacks as well.  I've seen odd behaviour with this sort of thing in the past, where the second request seems to take out the first one.

 

Is there a particular reason you are looking to do this?  You could change your actionstatus and provide javascript methods for onstart/onstop that redraw the dom elements you want to update.

jojoforcejojoforce

Yeah that is a really good point. 

 

The reason why I wanted to do this is because I have a VisualForce page in which I have a button wrapped in a actionStatus "stop" and the column headers of a PageBlock Data Table are facet outputLink (because when users click the column header it toggles a sort).

 

The skeleton is something like this: 

 

<apex:actionStatus name="toolbar">
    <apex:facet name="start" >
       <apex:commandButton disabled="true" />
    </apex:facet>
    <apex:facet name="stop" >
       <apex:commandButton disabled="false" />
    </apex:facet>
</apex:actionStatus>

<apex:datatable>
   <apex:column>
      <apex:facet name="header">
         <apex:actionStatus name="column1Sort">
            <apex:facet name="start" >
                 <apex:outputLink action="{!toggleSort}" disabled="true"/>
            </apex:facet>
            <apex:facet name="stop" >
                 <apex:outputLink action="{!toggleSort}" disabled="false"/>
            </apex:facet>
      </apex:facet> 


      <apex:inputText value="{!value1} >
         <apex:actionSupport onchange="{!saveChanges}" status="toolbar,column1Sort" rerender="somePanelBlahblahblah"/>

      </apex:inputText>
   </apex:column>

</apex:datatable>

 

 

By doing so, as users make changes to the inputText value, they cannot perform any button action or column header outputlink action until the {!saveChanges} completed.

 

 

 

 

bob_buzzardbob_buzzard

I see.  I tend to use one of two mechanisms (or a combinaton of both) when I need this:

 

(1) Grey out the rest of the page and popup a 'working' dialog or similar

(2) Use Jquery to locate and disable all input fields on the page 

This was selected as the best answer
jojoforcejojoforce

I tried the 1st approach graying out the whole screen, unfortunately it didnt work well for a user since the data table may have multiple records/editable columns and waiting every time they make updates was a little too much. 

 

I ended up with somewhat of the 2nd approach, although not using JQuery tho. I put the toolbar and each of the links into two <apex:outputPanel > one for enabled and the other for disabled. I  gave them an ID "disableSpanOnChangeXXXX" and the disabled having style of "display:none". 

 

<apex:outputPanel id="disableSpanOnChangeENABLED1" >
<apex:commandButton ... disabled="false" />
</apex:outputPanel >
<apex:outputPanel id="disableSpanOnChangeDISABLED1" style="display:none;">
<apex:commandButton ... disabled="true" />
</apex:outputPanel >

 




And then I call a javascript on each of the <apex:inputText onchange="disableToolbar" /> by switching the output panels display style property. 

 

 

 function disableToolbar() 
        {        
            var divs=document.getElementsByTagName('span');
            for(var i=0;i<divs.length;i++) {
                if(divs[i].id.indexOf('disableSpanOnChangeENABLED') != -1) {
                    var l1 = document.getElementById(divs[i].id);
                    l1.style.display = 'none';
                    
                }
                if(divs[i].id.indexOf('disableSpanOnChangeDISABLED') != -1) {
                    var l1 = document.getElementById(divs[i].id);
                    l1.style.display = '';
                    
                }

            }

 

Is there any anvantages of using JQuery as opposed to the JavaScript approached that I took?

bob_buzzardbob_buzzard

The reason I use jquery is that its very fast at identifying all of the input fields - much faster than javascript that I've written in the past  - and saves me worrying about browser incompatibilities.  

Arijit.MajeeArijit.Majee

I am having similar problem!

 

I wanted to accomodate two button or combination of link and button.

 

One is "request for access" and other one is link to records.

the business requirement is if the user already have access permission, then he can see the link to page instead of request option.

 

            

           

<apex:pageBlockTable value="{!Refvar_page}" var="account">
            
            
             <apex:column style="width:112px;background-color:#FBF2F4;color:#0D033E">
                
               <input type="button" style="width:110px" value="Request Access" onclick="displaymessage('{!account.acc.Id}');" align="center"/>
                
            </apex:column>
            
            
            <apex:column headerValue="Business Unit" style="background-color:#FBF2F4;color:#0D033E">
                
                 {!account.acc.Source_BU__c} 
                
            </apex:column>
            
            
            <apex:column headerValue="Name" style="background-color:#FBF2F4;color:#0D033E">
                
               <!-- <apex:outputLink value="/{!account.acc.Id}" > {!account.acc.name} </apex:outputLink> -->
                {!account.acc.name} 
                
            </apex:column>

 

jojoforcejojoforce

Im not sure I understand what you are asking...

 

If its the same problem as the one I described in the original note then the Accepted Solution as laid out by awesome Bob Buzzard should help you out. Best of luck! :D