从托管bean调用函数,并在完成后将焦点设置为所需的组件

时间:2015-06-05 05:47:31

标签: jsf primefaces

我有一个p:selectOneMenu从托管bean调用一个方法。我想再添加一个功能。因此,在调用该特定函数后,我想将焦点设置为<p:selectOneMenu id="particulars" filter="true" filterMatchMode="startsWith" value="#{receiptMB.selectedFeeSchemeDetail.planId}" style="width:120px !important;"> <f:selectItem itemLabel="Select" itemValue="" /> <f:selectItems value="#{receiptMB.incomeSchemes}" var="acc" itemLabel="#{acc.feeInstallment}" itemValue="#{acc.planId}" /> <p:ajax event="change" listener="#{receiptMB.onIncomeSourceSelect()}" update=":messageGrowl :receiptEntryForm:planId :receiptEntryForm:newVouchDetails txtQty totalAmount particulars :receiptEntryForm:planId :receiptEntryForm:receiptSource advAmtRemaining advCheckBox amtPaid" /> </p:selectOneMenu> <p:commandButton value="#{bundle.add}" icon="ui-icon-plus" partialSubmit="true" process="jvPanel autoCompleteData" id="addVoucher" actionListener="#{receiptMB.loadTableData}" update=":messageGrowl cmdSave :receiptEntryForm:newVouchDetails txtQty totalAmount particulars :receiptEntryForm:planId :receiptEntryForm:receiptSource advAmtRemaining advCheckBox amtPaid"> </p:commandButton>

我的代码是:

{{1}}

请建议我一些解决方案。

1 个答案:

答案 0 :(得分:0)

您可以在操作方法中使用RequestContext:

RequestContext context = RequestContext.getCurrentInstance();
context.scrollTo("receiptEntryForm:particulars");

您可以查看primefaces文档并展示更多信息。