问题描述
我正在使用primefaces-7.0.jar,所以我假设我正在使用版本7。
我有一个p:autocomplete,其中填充了用户过去使用的“代码”。允许用户输入不在列表中的其他代码,当p:autocomplete失去焦点时,将验证该代码以查看是否允许该用户使用该代码。
在当前版本中,如果用户在输入框中键入内容,则用制表符将输入中的“最佳”匹配项填充到列表中。 在以前的版本中,如果没有匹配项,则输入框将存储并提交用户键入的内容。
我认为在以前的版本中,这是一个错误,已得到修复,但这是我想要的行为。
我尝试更改一些属性,但没有运气。
我认为我可能需要重写或自定义此行为,但我不知道从哪里开始。
它必须使用javascript(jquery?),在哪里可以找到它在做什么?我可以覆盖它吗?怎么样?
我觉得关键必须在这里https://primefaces.github.io/primefaces/jsdocs/modules/jquery.html#autocomplete,但老实说,我不确定从哪里开始。该文档似乎假定了我只是没有的组件知识。
我认为我可能必须重写invokeItemSelectBehavior,但我并不真正知道,我也不知道是否可能。
CombineLatest
这也是xhtml中的invokeConditionally方法:
<p:autoComplete
disabled="#{empty currentBean.formA.serviceDate}"
id="userCode" dropdown="true" scrollHeight="200"
value="#{currentBean.formA.userCode}"
completeMethod="#{currentBean.completeUserCode}"
forceSelection="false"
var="userCode" itemLabel="#{userCode.code}" itemValue="#{userCode}"
converter="userCodeConverter"
styleClass="userCodeInput"
inputStyle="width: 150px"
cache="true"
onchange="invokeConditionally();"
widgetvar="userCodeWidgetvar"
>
<p:column>
<h:outputText value="#{userCode.code}"/>
</p:column>
<p:column>
<h:outputText value="#{userCode.description}" />
</p:column>
<p:ajax event="query" process="@this" update="userCodeSectionMsg"/>
<p:ajax event="itemSelect"
onstart="clearChangeEvent();"
update="<several things are updated here>"
process="@this"
listener="#{currentStepBean.calculateUserAmount}" />
</p:autoComplete>
感谢您的帮助。
谢谢
解决方法
哈哈!我的文档有误! 在我的文档版本中没有描述autoHighlight。