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
jygjyg 

Getting apex:param to work within apex:support

I've read through at least 20 posts about this issue, and one or two actually have working examples that seem to match what I'm attemping, but it doesnt work for me.  Please take a look and tell me what I'm not getting right, thanks.  For what its worth, I'm getting no luck with action Function either.

 

I expect that when I click on "I WANT ITX",  the varible "poid" in the controller is set to "123" and then the function "addToCard() gets fired off with access to the new value of "poid".  However, "poid" is always null.

 

Page snippet

<apex:outputPanel styleClass="want">
  I WANT ITX
  <apex:actionSupport event="onclick" action="{!addToCart}">
    <apex:param name="poid" assignTo="{!poid}" value="123"/>
  </apex:actionSupport>
</apex:outputPanel>

 

Controller snippet

// apex:param for apex:actionSupport
public String poid { get; set; } 

// function called from apex:actionSupport
public PageReference addToCart() {
  System.debug('===== POID: ['+((poid==null)?'null':poid)+']');
  .
  .
  .
}

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

i dont know y this is happening like that but u should use rerender in that some thing like this

 

<apex:outputPanel styleClass="want" id="op">
  I WANT ITX
  <apex:actionSupport event="onclick" action="{!addToCart}" rerender="op">
    <apex:param name="poid" assignTo="{!poid}" value="123"/>
  </apex:actionSupport>
</apex:outputPanel>

All Answers

kiranmutturukiranmutturu

i dont know y this is happening like that but u should use rerender in that some thing like this

 

<apex:outputPanel styleClass="want" id="op">
  I WANT ITX
  <apex:actionSupport event="onclick" action="{!addToCart}" rerender="op">
    <apex:param name="poid" assignTo="{!poid}" value="123"/>
  </apex:actionSupport>
</apex:outputPanel>
This was selected as the best answer
jygjyg

The prize goes to Kiran.  It seems that to get the param to set anything in the controller, the encompassing actionSupport must perform a rerender.  I suppose this makes some sense... some.  The function named in the actionSupport does run ether way, but the param only with the rerender.  OK, well,  the only sense it makes to me is that we have a pattern to follow.  Kiran, do you have any idea why it makes a difference?  As far as I have read, this is not documented.

 

jyg

kiranmutturukiranmutturu

i just observed this based on my practice only...

stunaitestunaite

It is a known bug also applied to other components such actionfunction.

 

It is not documented (as any other salesforce bug) :smileywink: