Trying to find out how to work with actionFuntion in case of usage html instead of VF. My simple piece of code is listed below.
Controller:
public class Test {
public String variable1 {get; set;}
public String variable2 {get; set;}
public void mTest(){
System.debug(variable1 + ' ' + variable2);
}
}
Apex page:
<apex:page controller="Test">
<apex:form>
<apex:actionFunction name="JS" action="{!mTest}">
<apex:param assignTo="{!variable1}" name="var1" value=""/>
<apex:param assignTo="{!variable2}" name="var2" value=""/>
</apex:actionFunction>
</apex:form>
<form>
<input type="text" id="input1"/><br/>
<input type="text" id="input2"/><br/>
<button type="button" onclick="doJS()">
Click
</button>
</form>
<script>
function doJS(){
let x = document.getElementById('input1').value;
let y = document.getElementById('input2').value;
JS(x, y);
}
</script>
First to say, it doesn't work: mTest is invoked but with no parameters passed. Also, I have some questions.
- Usage of apex:param. It declares an order of passed arguments or what?
How to send variable's from apex to the Vf?
Thank you!