【问题标题】:actionSupport InputText Onchange Not FiringactionSupport InputText Onchange 未触发
【发布时间】:2018-02-28 21:55:44
【问题描述】:

我正在为此绞尽脑汁。它是一个简单的更改功能,应该触发,但是当我在我的组织中进行测试时,尽管在我的课堂上得到了其余的东西,但我从来没有在“这里”得到调试。我查看了几十个不同的谷歌结果,代码是相同的。有谁知道 SF 是不是刚刚坏掉了?

public class testController {

    public static String testNewString {get;set;}

    public testController(){}

    public static Boolean isAccountAvailable()
    {
        System.debug('here');

        List<Account> tempList = ([SELECT Id 
                                            FROM Account 
                                            WHERE Name = :testNewString]);

        if(tempList.size() != 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

}

<apex:page controller="testController" docType="html-5.0">
     <apex:form id="form1">
        <apex:inputText value="{!testNewString }" html-placeholder="New Sales Order #">
                <apex:actionSupport event="onChange" action="{!isAccountAvailable}" rerender="form1"  />
              </apex:inputText>
    </apex:form>
</apex:page>

【问题讨论】:

    标签: salesforce apex-code visualforce


    【解决方案1】:

    对于正在寻找答案的人来说,此代码 sn-p 的修复是微妙的。确保函数返回页面引用。将字段设为全局可能有助于使其对 VF 可见。

    public class TestController {
    
    public String testNewString {get;set;}
    
    public testController(){}
    
    public PageReference isAccountAvailable()
    {
        System.debug('here');
    
        List<Account> tempList = ([SELECT Id 
                                            FROM Account 
                                            WHERE Name = :testNewString]);
    
        if(tempList.size() != 0)
        {
            System.debug('true');
        }
        else
        {
            System.debug('false');
        }
    
        return null;
    }
    
    }
    
    
    <apex:page controller="TestController" docType="html-5.0">
         <apex:form id="form1">
            <apex:inputText value="{!testNewString}"  html-placeholder="New Sales Order #">
                    <apex:actionSupport event="onchange" action="{!isAccountAvailable}" rerender="form1"  />
                  </apex:inputText>
        </apex:form>
    </apex:page>
    

    【讨论】:

      猜你喜欢
      • 2013-08-07
      • 1970-01-01
      • 2016-05-12
      • 1970-01-01
      • 2021-12-16
      • 2017-11-01
      • 2021-12-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多