方案:我使用了自动完成的组件和infront我使用了一个命令链接与搜索图像。Primefaces自动完成:如何在点击命令链接后将焦点设置为自动完成
我的目的是在点击commandlink后在自动完成中显示光标。
我的代码如下:
自动完成:
<p:autoComplete id="senderAutocomplete" widgetVar="senderInfo"
value="#{customerReviewLazyDataModel.customerReviewVO.senderVO}"
completeMethod="#{customerReviewLazyDataModel.searchOrganizations}"
var="senderVO"
itemValue="#{senderVO}" converter="organizationConverterForCustomerReview"
size="60">
commandlink
<p:commandLink oncomplete="setFocus()" ajax="true">
<p:graphicImage value="/app-resources/themes/yob/images/search.png" style="margin-bottom: -4px;"></p:graphicImage>
</p:commandLink>
js函数
function setFocus(){
document.getElementById("senderAutocomplete").focus();
}
有没有解决这个问题的方法?
谢谢。你的答案解决了我的问题。我用'document.getElementById(“senderAutocomplete_input”)。focus();'这和它工作得很好。 – Shruti