【发布时间】:2014-05-24 00:36:29
【问题描述】:
我使用 JSF + Primefaces 3.2.1。
页面上有一个p:datatable,在每一行我都有“编辑”按钮。当我单击该按钮时,页面的页脚会呈现一个用于编辑该行的表单。然后我需要向下滚动以更改值..
但我需要浏览器在单击基本 HTML 工作中的 Anchors 之类的“编辑”按钮后自动滚动到那里。
我找到了这个决定:
FacesContext.getCurrentInstance().getExternalContext().redirect("pProvidersPriceAppointment.xhtml#anchor1");
它可以工作,但是我的 update="@form" 无法正常工作。所以底部的表单不会呈现。刷新页面后渲染。
如何使用 p:commandButton 或 h:commandButton 来做到这一点?)
我的按钮:
<p:commandButton id="providerEdit" actionListener="#{providersPriceAppointment.setEditProvider(provider.id)}" icon="iconEdit" update="@form"/>
Bean方法:
public void setEditProvider(int id) throws IOException {
for (int i = 0; i < providersList.size(); i++) {
ProvidersExt p = providersList.get(i);
if (p.getId() == id) {
providerForEdit = p;
break;
}
}
enableEdit = true;
FacesContext.getCurrentInstance().getExternalContext().redirect("pProvidersPriceAppointment.xhtml#anchor1");
}
页脚中的表格:
<a name="anchor1"/>
<p:fieldset id="editFieldset" legend="blablabla" rendered="#{providersPriceAppointment.enableEdit}"/>
...
</p:fieldset>
【问题讨论】:
标签: jsf primefaces