我有一个用于更新公司股票的应用程序。我想要一个包含两个inputTexts的页面。第一个我输入项目ID和印刷机的地方。然后,Focus转到第二个inputText,即项目的库存量。这很好。然后,当我修改数量并按下时,项目将被保存,焦点应该返回到第一个inputText。确实如此,但它会再次直接跳转到第二个inputText。有什么想法吗?
<div id="page-content">
<h:form id="frmItem" prependId="false">
<p:focus id="focus" context="frmItem:itemNo" />
<p:messages id="vmsgs" severity="error,warn" autoUpdate="true" />
<p:panelGrid id="inventoryHeader" columns="3" columnClasses="form-label,form-input" styleClass="form-grid">
<p:outputLabel for="itemNo" value="item no." />
<p:inputText id="itemNo" autocomplete="off" value="#{wmsItemInventoryActionBean.itemNo}"
onkeypress="if(event.keyCode==13){onchange();return false;}">
<p:ajax process="@form" update="@form:focus,@form:stockAmount,@this"
listener="#{wmsItemInventoryActionBean.itemNo}" oncomplete="stockAmount.select()" />
</p:inputText>
<p:message for="itemNo" />
<p:outputLabel for="stockAmount" value="stock" />
<p:inputText id="stockAmount" autocomplete="off" value="#{wmsItemInventoryActionBean.stockAmount}" onkeypress="if(event.keyCode==13){onchange();return false;}">
<p:ajax process="@form" listener="#{wmsItemInventoryActionBean.save()}" oncomplete="itemNo.focus()"/>
</p:inputText>
<p:message for="stockAmount" />
</p:panelGrid>
</h:form>
</div>
答案 0 :(得分:0)
这是解决方案:
update="@form:focus"
<p:inputText id="stockAmount" autocomplete="off" value="#{wmsItemInventoryActionBean.stockAmount}" onkeypress="if(event.keyCode==13){onchange();return false;}">
<p:ajax process="@form" update="@form:focus" listener="#{wmsItemInventoryActionBean.save()}" oncomplete="itemNo.focus()"/>
</p:inputText>