+ Start a Discussion
Joseph BaroneJoseph Barone 

Need help passing Param value to Controller

Hi all,

I've been reading forum after forum, post after post and still am getting no where.  Hopefully, one of you smart people can help me out.  

I have a command button on my VF page that when pressed, I want to send a value to the controller and have it dynamically delete that line.  This issue I am running into is I cannot get the value of my Param into the controller.  

Here is the code - 
 
<apex:page Controller="AddmultipleTimes">
    <apex:form >

        <apex:pageblock title="New Time Entries">
        
            <apex:pageblocktable value="{!listNewtime}" var="lnt" id="thetable"> <apex:variable value="{!0}" var="cnt"/>
     <apex:pageMessages />
        <apex:column width="100px">
        <apex:commandButton action="{!removeLine}" value=" X " reRender="thetable"/>
            <apex:param name="TimeCount" assignTo="{!removeLine}" value="{!cnt}"/>
                <apex:variable var="cnt" value="{!cnt+1}"/>
Controller -
 
public class AddmultipleTimes {
Time_Entry__c newtime = new Time_Entry__c();
    
    public list<Time_Entry__c>listNewtime{ get;set;}
    public Integer TimeCount {get;set;}
    
    public AddmultipleTimes()
    {
 //       TimeCount = 0;
        listNewtime=new list<Time_Entry__c>();
        listNewtime.add(newtime);
    }
    
    public void addTime()
    {
       
        Time_Entry__c newEntry = new Time_Entry__c();
//    	TimeCount = TimeCount + 1;
        listNewtime.add(newEntry);
        
               
    }
    
  
    public PageReference removeLine()
    { 
 		
        
        String indexVal = ApexPages.currentPage().getParameters().get('TimeCount');    
		
  
        integer TimeCount1 = integer.valueof(indexVal); 
       
        listNewTime.remove(TimeCount1);
 
            return null;
    }

Any help would be much appreciated.

Thank you
 
NagaNaga (Salesforce Developers) 
Hi Joseph,

Try to use apex:actionFunction

Controllerpublic String mySubject {get;set;} public PageReference myMethod(){
System.debug('mySubject: ' + mySubject);
}

Please see the link below

http://salesforce.stackexchange.com/questions/69887/unable-to-pass-parameter-to-controller

Best Regards
Naga Kiran