Activity › Forums › Salesforce® Discussions › What is the use of apex param?
-
What is the use of apex param?
Posted by shariq on August 7, 2017 at 1:13 PMWhat is the working of apex param?
Parul replied 7 years, 9 months ago 3 Members · 3 Replies -
3 Replies
-
<apex:param> tag is mainly used to pass values from JavaScript to an Apex controller, it can only be used with the following parent tags/The <apex:param> component can only be a child of the following components:.
• <apex:actionFunction>
• <apex:actionSupport>
• <apex:commandLink>
• <apex:outputLink>
• <apex:outputText>
• <flow:interview>- One example can be seen as:
#VisualForce Page:
<apex:page controller=”paramtest” docType=”html-5.0″>
<apex:form><apex:commandbutton action=”{!testdirect}” reRender=”test” value=”Static value”>
<apex:param assignTo=”{!value}” value=”The static value that was set from vf page”/>
</apex:commandbutton><br/>
<input type=”text” id=”testinput”/>
<input type=”button” onclick=”testinputJS()” value=”Dynamic Value” class=”btn”/>
<apex:outputPanel id=”test”>
<apex:outputText value=”{!value}”/>
</apex:outputPanel>
<apex:actionFunction action=”{!testinput}” name=”passToController” rerender=”test”>
<apex:param value=”” name=”inpval”/>
</apex:actionFunction>
</apex:form>
<script>
function testinputJS(){
var str = document.getElementById(‘testinput’).value;
if(str.length >4){
str= str.substring(0,4);
}
passToController(str);
}
</script>
</apex:page>#Apex Class/Controller:
public class paramtest {
public string value { get; set;}public void testdirect(){
system.debug(value);
}
public void testinput(){
value = apexpages.currentPage().getParameters().get(‘inpval’);
system.debug(value);
}
} - [adinserter block='9']
-
<apex:param> tag is mainly used to pass values from JavaScript to an Apex controller.
Thanks
Log In to reply.