[SalesForce] Passing parameter through commandbutton is null value

I'm trying to pass a parameter of an Object to a controller with this code block:

<apex:commandButton  value="Accept" action="{!Accept}" >                        
  <apex:param name="deal" value="{!deal.id}" assignTo="{!dealId}"/>
</apex:commandButton>

But Visualforce always gives following error:

List has no rows for assignment to SObject Error is in expression
'{!Accept}' in component in page dealviewer:
Class.DealViewerController.Accept: line 34, column 1

When I debug the controller in Developer Console it tells me I'm passing a null value:

// click action button Accept
    public void Accept() {
        String dealId = apexpages.currentpage().getparameters().get('dealId');
        System.debug(dealId);
        Deal_Action__c dealac = [SELECT Action__c, Contact__c FROM Deal_Action__c WHERE Deal_Action__c.Deal__c = :dealId];
        dealac.Action__c = 'Accepted';
        update dealac;
    }

Anyone knows the solution to this problem?

Best Answer

Thanks for your answer SF_User, but unfortunately this doesn't solved my problem.

Finally I found the problem. Apex is not supporting param and commandbutton so you have to work around with reRender attribute and reRender not the whole page.

<apex:column headerValue="Action" id="all">                 
 <apex:commandButton  value="Accept" action="{!Accept}" reRender="all" >                        
  <apex:param name="deal" value="{!deal.Id}" assignTo="{!dealId}" />
 </apex:commandButton>                      
 <button type="button">Reject</button>                                              
</apex:column>