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

Blank param value and no java script function defined
Hi Guys,
Following going through the salesforce docs,I came across the below code snipet. On change event calls java script function rerenderStates ,which is nonewhere defined on the page ,is that created by default? Also Param has blank value ,how's country passed to param?The code is working fine.Throgh param country value selected is passed to country variable in controller and accordingly the dependent picklist show the values.
<apex:page controller="CountryStatePicker">
<apex:form >
<apex:actionFunction name="rerenderStates" rerender="statesSelectList" >
<apex:param name="firstParam" assignTo="{!country}" value="" />
</apex:actionFunction>
<table>
<tr>
<th>Country</th>
<td>
<apex:selectList id="country" styleclass="std" size="1"
value="{!country}" onChange="rerenderStates(this.value)">
<apex:selectOptions value="{!countriesSelectList}"/>
</apex:selectList>
</td>
</tr>
<tr id="state_input">
<th>State/Province</th>
<td>
<apex:selectList id="statesSelectList" styleclass="std" size="1"
value="{!state}">
<apex:selectOptions value="{!statesSelectList}"/>
</apex:selectList>
</td>
</tr>
</table>
</apex:form>
</apex:page>
Thanks in advance!
Following going through the salesforce docs,I came across the below code snipet. On change event calls java script function rerenderStates ,which is nonewhere defined on the page ,is that created by default? Also Param has blank value ,how's country passed to param?The code is working fine.Throgh param country value selected is passed to country variable in controller and accordingly the dependent picklist show the values.
<apex:page controller="CountryStatePicker">
<apex:form >
<apex:actionFunction name="rerenderStates" rerender="statesSelectList" >
<apex:param name="firstParam" assignTo="{!country}" value="" />
</apex:actionFunction>
<table>
<tr>
<th>Country</th>
<td>
<apex:selectList id="country" styleclass="std" size="1"
value="{!country}" onChange="rerenderStates(this.value)">
<apex:selectOptions value="{!countriesSelectList}"/>
</apex:selectList>
</td>
</tr>
<tr id="state_input">
<th>State/Province</th>
<td>
<apex:selectList id="statesSelectList" styleclass="std" size="1"
value="{!state}">
<apex:selectOptions value="{!statesSelectList}"/>
</apex:selectList>
</td>
</tr>
</table>
</apex:form>
</apex:page>
Thanks in advance!
Insetead of calling javascript function we can directly call the actionfucntion...this is what is happending here in this code...onchange we are directly calling the actiuonfunction by passing the value and so its working fine...
Its not required to call javascript first and then actionfunction..irectly we can call..
Let me kniow if this is your question or you have other doubt
Thanks,
Sandeep
Action function attribute 'name' points to a javascript function always,isn' it? It is not the name of actionfunction (through which we can refer it ).Please correct my understanding if wrong.
Thanks Again1
Hi,
No, we can directly call actionfunction from event ..same thing is happening in your case...okay!!
Via javascript it is not required..
Value will be what we are passing simply by alling the actionfunction..
Thanks,
Sandeep
Following are the answers for your questions:
1. Via javascript its not required, you can directly call teh actionfunction with name..
2. Value denoates the default value , if you are passing anything in method then that will take that value else by default whatever you are providing in value, will be considered as value..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer