+ Start a Discussion
kmorf_entransformkmorf_entransform 

commandButtons within a pageBlockTable

i have a pageblocktable and i have a list of custom objects Offers. I want to make a button where if u click on it. the current offer will be accepted, but the button doesnt work. Ive also tried commandLink and also it doesnt work. i have also used assignTo an that to doesnt work. can anybody help me on this.

<apex:PageBlockTable var="offer" value="{!Offers}">
  <apex:column >
       <apex:facet name="header">Accept</apex:facet>
         <apex:commandButton value ="Accept" action="{!AcceptOffer}">
<apex:param name="q" value="{!offer.Id}"/>
             </apex:commandButton>                               
    </apex:column>
/////controller

public class code{

public List<Offers__c> Offers {set;get}

public class AcceptOffer(){

String aOffer = ApexPages.currentPage().getParameters().get('Id')

}
}

 

Rajesh_SFGRajesh_SFG

you need change

   String aOffer = Apexpages.Currentpage().getparameters().get('q');

because u were used the param name as 'q'.

Chamil MadusankaChamil Madusanka

Hi,

 

change as follows,

 

<apex:PageBlockTable var="offer" value="{!Offers}">
  <apex:column >
       <apex:facet name="header">Accept</apex:facet>
         <apex:commandButton value ="Accept" action="{!AcceptOffer}">
<apex:param name="q" value="{!offer.Id}" assignTo="{!offerID}"/>
             </apex:commandButton>                               
    </apex:column>
	
	
/////controller

public class code{

public String offerID{get;set;}
public List<Offers__c> Offers {set;get}

public class AcceptOffer(){

//String aOffer = ApexPages.currentPage().getParameters().get('Id')
System.Debug('offerID ::: '+offerID);
}
}

 You can get the parameter from "offerID".

 

Additional link for parameter passing:

http://salesforceworld.blogspot.com/2011/06/parameter-passing-using.html

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 

Chamil's Blog

osamanosaman

This is a known issue that you cant pass in parameter with commandButton. You need to rereneder a hidden page block to pass the paramter with commandButton.

 

Try this

 

<apex:page standardController="Contact" extensions="CommandButtonParamController">
    <apex:form >
 
        <apex:commandButton value="Process Nickname" action="{!processButtonClick}" rerender="hiddenBlock">
            <apex:param name="nickName"
                value="{!contact.firstname}"
                assignTo="{!nickName}"/>
        </apex:commandButton>
 
        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
 
    </apex:form>
</apex:page>