You need to sign in to do that
Don't have an account?

Passing Parameters to Apex Method from Visualforce Page
Hi
I am trying to Pass parameter to Apex method from VF page. But i am not able to get the parameter value.
My code
<td ><apex:outputText value="{!slot.tstart1}"/></td> <td width="15%" hight="5%"><apex:commandButton value="Book Appointment" action="{!callAppointment}" id="buttonid"> <apex:param name="tstart" value="{!slot.tstart1}" /> </apex:commandButton> </td>
public PageReference callAppointment() { PageReference redirect = new PageReference ('/apex/appointment'); // redirect.getParameters().put('time', liTimeSlots); // string myParam = apexpages.currentpage().getparameters().get('tstart'); system.debug('++++++++++++++++++++++++++++++ apexpages.currentpage() '+ apexpages.currentpage().getparameters().get('tstart1') ); redirect.getRedirect(); return redirect; }
debug log
04:42:39.064 (64864000)|SYSTEM_METHOD_EXIT|[682]|System.PageReference.getParameters() 04:42:39.064 (64887000)|SYSTEM_METHOD_ENTRY|[682]|MAP.get(ANY) 04:42:39.064 (64902000)|SYSTEM_METHOD_EXIT|[682]|MAP.get(ANY) 04:42:39.064 (64927000)|SYSTEM_METHOD_ENTRY|[682]|System.debug(ANY) 04:42:39.064 (64936000)|USER_DEBUG|[682]|DEBUG|++++++++++++++++++++++++++++++ apexpages.currentpage() null 04:42:39.064 (64943000)|SYSTEM_METHOD_EXIT|[682]|System.debug(ANY) 04:42:39.064 (64956000)|SYSTEM_METHOD_ENTRY|[683]|System.PageReference.getRedirect() 04:42:39.065 (65014000)|SYSTEM_METHOD_EXIT|[683]|System.PageReference.getRedirect() 04:42:39.065 (65045000)|CODE_UNIT_FINISHED|AppointmentController invoke(callAppointment) 04:42:39.065 (65090000)|VF_APEX_CALL|buttonid|{!callAppointment}|PageReference:/apex/appointment
Please help me to find the solution for this
Thanks
Anuraj
Hi,
Use the reRender=”pageid” attribute in <apex:commandButton > and also use 'tstart' instead of 'tstart1' in
system.debug('++++++++++++++++++++++++++++++ apexpages.currentpage() '+ apexpages.currentpage().getparameters().get('tstart') );
All Answers
Hi,
You need to assign the value in <apex:param name="tstart" value="{!slot.tstart1}" /> to your apex controller property. There is a attribute assignTo of the <apex:param > apex component.
Use the below code snippet as reference
<apex:param name="tstart" value="{!slot.tstart1}" assignTo=”{!sloatstart1value}”/>
Create the protperty in your apex contollrer with
Public string sloatstart1value{get;set;}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Thanks Navatar for your reply.
The solution you gave me, I have tried it before but the result is same NULL.
Do you have any other idea.
Hi,
Use the reRender=”pageid” attribute in <apex:commandButton > and also use 'tstart' instead of 'tstart1' in
system.debug('++++++++++++++++++++++++++++++ apexpages.currentpage() '+ apexpages.currentpage().getparameters().get('tstart') );
Thanks for your reply it is working.
But When I used reRender in the button the button is not working. I have set button action to pass to appointment page but button is not get redirected.
Can you help me to solve this problem why I am not able to get the appointment page.
Add this after your commandButton <apex:pageBlock id="pageid" rendered="false"></apex:pageBlock> where pagBlock id is the reRender="pageid" value of your command button.