Page:
<apex:page controller="componentController">
<script>
window.addEventListener("DOMContentLoaded",
function() {
setSite("jingweidu");
});
</script>
<body>
<apex:form id="form">
<apex:actionFunction action="{!setSite}" name="setSite" reRender="form">
<apex:param name="param1" assignTo="{!site}" value="GC"/>
</apex:actionFunction>
<h3>
I am text
</h3>
</apex:form>
</body>
</apex:page>
********************************************Controller*********************************
public class componentController {
public string site {get;set;}
public void setSite(){
system.debug('set site');
system.debug(site);
}
}
执行结果:
画面上显示: I am text
Log里打出了:set site
jingweidu
本文探讨了Apex页面中使用Page Controller进行组件状态管理的方法。通过实例展示了如何利用Apex:ActionFunction触发控制器方法setSite,实现参数传递与页面刷新。代码中详细解释了如何设置监听器在DOM加载完成后调用自定义函数,以及如何在控制器中接收并处理这些参数。
8988

被折叠的 条评论
为什么被折叠?



