简体   繁体   English

Apex组件控制器无法从apex:inputText / inputField获取值

[英]Apex Component Controller can not get value from apex:inputText/inputField

I have a simple custom component that I want to use to send an email. 我有一个简单的自定义组件,我想用来发送电子邮件。 The structure is like this: 结构是这样的:

<apex:form>
    <apex:actionFunction action="{!sendEmail}" name="sendEmail" />
    <apex:inputField value="{!To}"/>
    <button type="button" onClick="sendEmail();"/>
</apex:form>

and a controller that is like this: 和一个像这样的控制器:

public with sharing class emailComponent{
    public string To { get; set; } 

    public void sendEmail(){
        system.debug(logginglevel.info,To);
    }
}

Now when I fire the actionFunction the correct method is called but the value of "To" will always be null. 现在,当我触发actionFunction时,将调用正确的方法,但“ To”的值将始终为null。 Even if I set the value in the contructor when I call the method the value will be null. 即使我在调用该方法时在构造函数中设置该值,该值也将为null。 I don't know if this has to do with it being a custom component controller or if there's something else im missing.. 我不知道这是否与作为自定义组件控制器有关,或者我是否还缺少其他东西。

将“ rerender”属性添加到apex:actionFunction,它应该开始工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM