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
G!R!G!R! 

urgent: passing <apex:param with command button and command link

Hi All,

 

I have small problem...I am trying to show the related list of contacts i.e cases when i click on apecific contact name.

it is coming good with command link but having problem with command button....here is the code.....can any one rectify it pls...

 

<apex:page controller="Ccontactstocases"  showChat="true" tabStyle="contract">
  <apex:form >
  <apex:pageBlock >
      <apex:pageBlockTable value="{!con}" var="Allcontacts">
      
          <apex:column value="{!Allcontacts.id}" />
          
          <apex:column >
           <apex:commandLink action="{!callcases}" styleClass="btn">
                              <apex:outputField value="{!Allcontacts.Name}"/>
                              <apex:param name="hi" value="{!Allcontacts.id}"/>
                     </apex:commandLink>
                     
          <apex:commandbutton action="{!callcases}" value="{!Allcontacts.Name}">
                        <apex:param name="hi" value="{!Allcontacts.id}" />      
                    </apex:commandButton>            
              </apex:column>
              
          <apex:column value="{!Allcontacts.title}"/>
 
      </apex:pageBlockTable>
 
    </apex:pageBlock>
    
    <apex:pageBlock >
    <apex:pageBlockTable value="{!cases}" var="Allcases">
               
        <apex:column value="{!Allcases.subject}"/>
        <apex:column value="{!Allcases.priority}"/>
        <apex:column value="{!Allcases.status}"/>
    
    </apex:pageBlockTable>
    
    </apex:pageBlock>
  </apex:form>
</apex:page>

 

 

public class Ccontactstocases {

    
   Public list<Contact> con{get;set;}
   Public list<Case> cases{get;set;}
 
   public Ccontactstocases ()
   {
       con = [select id,name, title from Contact limit 10];
       
   }
public void callcases()
{
    ID contactid = apexpages.currentpage().getparameters().get('hi');
    cases =[select id,subject,priority,status from case where contactid = :contactid ];
       
}
}

bob_buzzardbob_buzzard
Is the parameter not present on the URL when you retrieve it? I've had similar problems (although I was assigning the parameter to a controller property) in the past. The solution for me was to add a rerender to the command button - if I didn't have anything to sensibly rerender then I just put a big output panel around the body of the page.