简体   繁体   English

jsf.ajax.request无法完全正常运行

[英]jsf.ajax.request not working completely

I am attempt to make a custom autocomplete box but I am having some trouble. 我试图制作一个自定义自动填充框,但遇到了一些麻烦。 Right now I have an input that calls this function on keydown 现在我有一个输入,可以在按下键盘时调用此函数

 function pingAutoComplete(event)
 {
    console.log("pingAutoComlete Called");
    window.clearTimeout(window.keyTimeout);


     //Wait 2 seconds before we attempt to pingAutoComplete incase user has not finished typing
      window.keyTimeout = setTimeout(function() {
       jsf.ajax.request(event, "keydown", {execute:'searchTerm',render:'autoCompletePanel'})
       autoCompleteLayoutPanel.show();
       return false;
    }, 2000);
    return false;

 }

The auto complete panel contains a bunch of selects that look like this 自动完成面板包含一系列如下所示的选择

<h:selectOneListbox id="vehicleResult" title="Vehicles"
    value="#{searchBean.searchTerm}"
    converter="entityConverter"
    required="false"
    rendered="#{!searchBean.filterAutoComplete().isEmpty()}">

    <f:selectItems value="#{searchBean.filterAutoComplete()}"
        var="searchItem" itemValue="#{searchItem}"
        itemLabel="#{searchItem.displayString}"
        itemLabelEscaped="true" />
</h:selectOneListbox>

Now when the javascript is called it seems to be hitting searchBean.filterAutoComplete() on the back end, but it is not actually updating the select list in the gui. 现在,当调用javascript时,似乎在后端点击了searchBean.filterAutoComplete(),但实际上并没有更新gui中的选择列表。 Anyone know why? 有人知道为什么吗?

You have to specify the exact client ID. 您必须指定确切的客户端ID。 That is the value of the id attribute of the generated HTML element, not of the JSF component itself. 那是生成的HTML元素的id属性的值,而不是JSF组件本身的id属性的值。 If the JSF components are placed in a <h:form> , then the client ID will by default be prepended with its ID. 如果JSF组件放置在<h:form> ,则默认情况下,客户端ID之前将带有其ID。

Thus the following panelgroup 因此,以下小组

<h:form id="form">
    <h:panelGroup id="autoCompletePanel">

will have a client ID of form:autoCompletePanel . 客户端ID的form:autoCompletePanel You need to specify exactly that ID in the render attribute. 您需要在render属性中确切指定该ID。 The same rules also applies to execute by the way. 相同的规则也适用于顺便execute

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

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