You need to sign in to do that
Don't have an account?
StephenJacobGoldberg
can't get param from vforce page to apex method
I have a command button, and when I try and use it in the visualforce page I am not able to reterive the paramter from the page, it returns null
Here is the visualforce code
<apex:page standardController="Account" extensions="Controller_DupeChecker"> <apex:form > <apex:dataTable value="{!DupeAccounts}" var="das" width="100%" border="1px" style="text-align:center"> <apex:column headerValue="Account Names" value="{!das.Name}"/> <apex:column headerValue="Phone" value="{!das.Phone}"/> <apex:column headerValue="Shipping Street" value="{!das.ShippingStreet}"/> <apex:column headerValue="Billing Street" value="{!das.BillingStreet}"/> <apex:column > <apex:commandButton action="{!MergeAccounts}" value="Merge" id="theButton"> <apex:param name="acid" value="{!das.id}"/> </apex:commandButton> </apex:column> <apex:column >{!das.id}</apex:column> </apex:dataTable> </apex:form> </apex:page>
And here is the apex class
public PageReference MergeAccounts(){ // aid is not passing a value Id aid = System.currentPageReference().getParameters().get('acid'); List<Account> mergeAccounts = new List<Account>(); system.debug('aid: ' + aid); Account mergeAccount = ([select Id FROM Account WHERE Id =:aid]); //merge function doesn't bring over fields merge acc mergeAccount; return null; }
Please help!
When you call {!DupeAccount}, is the Data showing correctly in the Data Table itself, or is it returning null values? If they're all returning null values, try Skodisana's response
Additionally: There have been reports of a bug with the CommandButton and the getter, setter methods for a while now. Just for testing, try switching to a command Link and give it a shot.
Off the top of my head, the code is something like this:
A better explanation of the bug (and ways to work around it) can be found here:
http://blog.jeffdouglas.com/2010/03/04/passing-parameters-with-a-commandbutton/
Best of luck.
All Answers
Hi,
Delete the 3rd line in the visualforcepage code and replace with below code:
Please use the below controller code
Skodisana,
Thanks for the quick reply, but I don't see how that will solve the problem...
When you call {!DupeAccount}, is the Data showing correctly in the Data Table itself, or is it returning null values? If they're all returning null values, try Skodisana's response
Additionally: There have been reports of a bug with the CommandButton and the getter, setter methods for a while now. Just for testing, try switching to a command Link and give it a shot.
Off the top of my head, the code is something like this:
A better explanation of the bug (and ways to work around it) can be found here:
http://blog.jeffdouglas.com/2010/03/04/passing-parameters-with-a-commandbutton/
Best of luck.
Thanks Gobbledigook, that worked perfectly. My data in the table was fine, thats why I was confused by the other comment.
Stephen
sravu,
Thanks for trying ...but that doesn't work either the other solution provided actually works.