[SalesForce] Using ActionStatus with a CommandButton and Apex:Param

This is my initial (and working) setup for a Select button against an OpportunityLineItem on a custom product selection Visualforce page. Note the OpportunityLineItems are displayed in a table, hence the <apex:column> tag:

            <!-- Notify user search we are adding product-->
            <apex:actionStatus id="addCart" startText="Adding Product..." stopText=" " startStyleClass="statusStyle"/>

                <apex:column >
                    <apex:commandButton value="Select" action="{!addToShoppingCart}" reRender="selected,searchResults,msgs" immediate="true" status="addCart">
                        <apex:param value="{!a.Id}" assignTo="{!toSelect}" name="toSelect"/>
                    </apex:commandButton>
                </apex:column>

Now I would rather the button itself shows the actionstatus, saving the user having to scroll up/down to see it. I have this working in several other places in the page, but this is the only one which also uses apex:param. Using the below the button doesn't even appear:

               <apex:column >
                    <apex:actionStatus id="addCart1">
                        <apex:facet name="stop">
                            <apex:commandButton value="SelectWIP" action="{!addToShoppingCart}" reRender="selected,searchResults,msgs" immediate="true" status="addCart1"/>
                                <apex:param value="{!a.Id}" assignTo="{!toSelect}" name="toSelect"/>
                        </apex:facet>

                        <apex:facet name="start">
                            <apex:outputPanel>
                                <apex:image value="/img/loading32.gif" style="height: 15px"/>
                                <apex:commandButton value="Adding Product..." status="addCart1" disabled="true"/>
                            </apex:outputPanel>
                        </apex:facet>                       
                    </apex:actionStatus>                             
                </apex:column>

However if I comment out the line below, the actionstatus displays but the param does not get sent back to the controller:

<apex:param value="{!a.Id}" assignTo="{!toSelect}" name="toSelect"/>

The first example works so I'm pretty sure there is no issue with the controller and I thought as long as the commandbutton is rerendering something then the param would be sent. Is there an issue with using the combination I am using?

Best Answer

In your second example, the <apex:param /> is outside of the <apex:commandButton> element, yet on the first example which you provided the param tag is within the command button's markup.

Was this change deliberate? If not, restructuring the button markup to contain the param element may solve your issue.

<apex:commandButton value="SelectWIP" action="{!addToShoppingCart}" reRender="selected,searchResults,msgs" immediate="true" status="addCart1">
    <apex:param value="{!a.Id}" assignTo="{!toSelect}" name="toSelect"/>
</apex:commandButton>
Related Topic