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
ledap13ledap13 

return value by clicking on button

Hi friends,
how can I return a value in a controller from my page?

Thanks
Best Answer chosen by ledap13
Sonam_SFDCSonam_SFDC
Sure,  see the following sample code:

this is from a pagetableblock which has this button on every row of the table

<apex:commandButton value="Accept"  action="{!CreateAcceptDealAction}" >
<apex:param name="ADealID" assignto="{!AdealID}" value="{!DealMapWrapper[d].deal.id}"></apex:param> </apex:commandButton>

When we click on the commandbutton"Accept" - the record ID of the record on this particular row is assigned to the property "ADealID" of the controller

in the controller: public String Adeal {get;set;}

All Answers

Sonam_SFDCSonam_SFDC
You can use the apex:param tag with commandbutton such that you can assign any value to a property in the controller using the attributes of this tag:
https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_param.htm
ledap13ledap13
Thanks,
but can you tell me a little more detail?
Sonam_SFDCSonam_SFDC
Sure,  see the following sample code:

this is from a pagetableblock which has this button on every row of the table

<apex:commandButton value="Accept"  action="{!CreateAcceptDealAction}" >
<apex:param name="ADealID" assignto="{!AdealID}" value="{!DealMapWrapper[d].deal.id}"></apex:param> </apex:commandButton>

When we click on the commandbutton"Accept" - the record ID of the record on this particular row is assigned to the property "ADealID" of the controller

in the controller: public String Adeal {get;set;}

This was selected as the best answer