actionSupport InputText Onchange Not Firing

问题描述 投票:0回答:1

我正在绞尽脑汁。它是一个简单的改变功能,它应该触发,但是当我在我的组织中测试时,我从来没有得到调试“这里”,尽管在我的课堂上休息。我查看了几十个不同的谷歌搜索结果,代码完全相同。有人知道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个回答
1
投票

对于正在寻找答案的人来说,此代码段的修复程序是微妙的。确保该函数返回页面引用。使字段全局化可能有助于使其对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>
© www.soinside.com 2019 - 2024. All rights reserved.