【发布时间】:2017-10-26 13:57:14
【问题描述】:
Primefaces v6.1 在使用 p:selectOneMenu 时似乎存在一个错误,它在显示模态对话框时保持焦点。您可以使用向上/向下箭头键更改 selectOneMenu 选择。当我用 h:selectOneMenu 替换 p:selectOneMenu 时,它按预期工作。知道如何将焦点移到 input1 字段吗?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form id="form">
<!-- PF('statusWidget').blur();document.activeElement.blur(); -->
<p:selectOneMenu id="status" widgetVar="statusWidget"
onchange="PF('dlg').show();" value="test1">
<f:selectItem itemValue="test1" itemLabel="TEST_1"/>
<f:selectItem itemValue="test2" itemLabel="TEST_2"/>
<f:selectItem itemValue="test3" itemLabel="TEST_3"/>
</p:selectOneMenu>
<!-- onShow="document.activeElement.blur();" -->
<p:dialog widgetVar="dlg" modal="true" focus="input1">
<p:inputText id="input1" widgetVar="test"/>
</p:dialog>
</h:form>
</h:body>
</html>
【问题讨论】:
-
你的意思是即使
focus="input1"也无济于事? -
@Kukeltje 对,即使使用 focus="input1" 也不起作用。
标签: jsf primefaces