在输入文本中输入时如何使用p:hotkey提交表单

Ana*_* MS 0 jsf hotkeys form-submit primefaces

我有以下片段:

<h:form>
    <p:inputText id="inputId" ... />
    <p:commandButton id="commandId" ... />
    <p:hotkey bind="return ..."  />
</h:form>
Run Code Online (Sandbox Code Playgroud)

当我按下Enter<p:inputText>,我怎么能调用<p:commandButton>使用<p:hotkey>

Bal*_*usC 5

<p:hotkey>不是用来捕捉Enter形式的输入键.它被设计用来捕捉像箭头键和特殊键组合Ctrl,AltShift在整个页面的组合.

你需要<p:defaultCommand>改为.

<h:form>
    <p:inputText ... />
    <p:commandButton id="commandId" ... />
    <p:defaultCommand target="commandId" />
</h:form>
Run Code Online (Sandbox Code Playgroud)