Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf p:焦点不起作用_Jsf_Primefaces - Fatal编程技术网

Jsf p:焦点不起作用

Jsf p:焦点不起作用,jsf,primefaces,Jsf,Primefaces,我需要焦点指定Id(即commandbutton、selectonemenu和text)不起作用。我尝试以下代码: <h:form id="mainForm"> <p:inputText id="name"/> <p:inputText id="Age"/> <p:selectOneRadio id="Gender" value="#{employee.gender}" layout="custom"> <f:s

我需要焦点指定Id(即commandbutton、selectonemenu和text)不起作用。我尝试以下代码:

<h:form id="mainForm">
<p:inputText id="name"/>
<p:inputText id="Age"/>
   <p:selectOneRadio id="Gender" value="#{employee.gender}" layout="custom">
            <f:selectItem itemLabel="Male" itemValue="Male" />
            <f:selectItem itemLabel="Female" itemValue="Female" />

        </p:selectOneRadio>
<p:commandButton  id="clear" value="Press" action="{employee.saveAction}">
<p:focus for="Gender"/>
</p:commandButton>

<p:commandButton id="clear" value="clear"/>
</h:form>

我尝试焦点单选按钮或id=“clear”命令按钮或文本按钮不是焦点


注意:我尝试了
context=“specifyid”
替换,因为它也不起作用。

我不知道你为什么把
放在
里面。也许这是造成问题的原因。根据,您可以将标签直接放入
并将焦点设置在您的
上:



它适用于“年龄”吗?我想我读到过当按commandbutton focus specify id时focus不适用于selects(虽然不确定,但搜索internet可能会产生一些结果),因为我使用了多个命令按钮和多个focus。所以我点击commandbutton来集中注意力,为什么不改用JavaScript呢
onclick=“document.getElementById(“Gender”).focus();”
It focus但它使用页面来引用
<h:form id="mainForm">
  <p:focus for="Gender" />
  <p:inputText id="name" />
  <p:inputText id="Age" />
  <p:selectOneRadio id="Gender" value="#{employee.gender}" layout="custom">
    <f:selectItem itemLabel="Male" itemValue="Male" />
    <f:selectItem itemLabel="Female" itemValue="Female" />
  </p:selectOneRadio>
  <p:commandButton id="clear" value="Press" action="{employee.saveAction}" />
  <p:commandButton id="clear" value="clear" />
</h:form>