0
问题是我试图按下一个按钮 - >去支持bean - >设置一个布尔值为false/true,并相应地显示一个弹出窗口。如果弹出窗口显示 - >调用方法并执行它。JSF输入字段值在第二次按钮点击后消失
上述工作正常,但当单击弹出式面板中的按钮时,第一次单击按钮后出现的输入字段似乎已丢失。所以我第一次点击后获得的所有参数(他们进入后台bean对象)都会随着第二次点击而消失(在弹出窗口中)。这可能是什么?
这一切都在一种形式,所有的按钮和inputfields等在一个a4j:地区..后台没有验证错误。
我有以下支持bean(注意,我故意没有把整个BB在那里与人的内喷射等):
@ManagedBean(name = "dossierInTreatmentBB")
@ViewScoped
public class DossierInTreatmentBackingBean {
/** The show center popup. */
private boolean showCenterPopup;
/** The continue assign without report. */
private boolean continueAssignWithoutReport;
public void assign() throws IOException {
if (!continueAssignWithoutReport) {
ExternalOffice eo = annucompLocal.findOfficeByCrestraCode(getEntity().getServiceTreatment());
showCenterPopup = OfficeLevel.CENTER.equals(eo.getServiceType().getOfficeLevel())
}
if (!showCenterPopup) {
dossierInTreatmentDossierLocal.assign();
//refreshes the entity
setDTO(null);
if (!DossierContext.isEditAllowed(getDossier())) {
String url = getRequestContextPath() + "/dossier/consult/detail.jsf?id=%s";
redirect(url, getDossier().getId().toString());
}
}
}
/**
* Assign without report.
* @throws IOException Signals that an I/O exception has occurred.
*/
public void assignWithoutReport() throws IOException {
showCenterPopup = false;
continueAssignWithoutReport = true;
assign();
}
... needed getters and setters ...
,这是我的看法(分配。 XHTML):
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:fragment xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ccffdecorate="http://java.sun.com/jsf/composite/ccffdecorate"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<a4j:region>
<h:panelGrid layout="block" styleClass="rSplitPanel2" columns="2"
rendered="#{not empty entityBB.entity}">
"some input fields"
</h:panelGrid>
<h:panelGroup layout="block" styleClass="rButtonPanel">
<h:commandButton value="#{AppMessages['general.action.save']}">
<a4j:ajax
render="dossierInTreatmentPanel :messages centerPopupGroup"
listener="#{entityBB.assign}" status="ajaxStatus"
oncomplete="#{rich:component('centerPopup')}.show()" />
</h:commandButton>
<h:commandButton value="#{AppMessages['general.action.cancel']}">
<a4j:ajax execute="@this" render="dossierInTreatmentPanel :messages"
listener="#{entityBB.cancel}" status="ajaxStatus" />
</h:commandButton>
</h:panelGroup>
<h:panelGroup id="centerPopupGroup">
<rich:popupPanel id="centerPopup" modal="true" autosized="true"
rendered="#{entityBB.showCenterPopup}"
onmaskclick="#{rich:component('centerPopupPanel')}.hide()">
<div class="rButtonPanel">
<h:commandButton value="#{AppMessages['general.action.next']}">
<a4j:ajax listener="#{entityBB.assignWithoutReport()}"
status="ajaxStatus"
oncomplete="#{rich:component('centerPopup')}.hide();" />
</h:commandButton>
<h:commandButton value="#{AppMessages['general.action.cancel']}">
<a4j:ajax listener="#{entityBB.cancel}" limitRender="true"
status="ajaxStatus"
onclick="#{rich:component('centerPopup')}.hide(); return false;" />
</h:commandButton>
</div>
</rich:popupPanel>
</h:panelGroup>
</a4j:region>
dit.xhtml:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:e="http://minfin.regondes2/entity"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:l="http://minfin.regondes2/layout">
<ui:include src="assignBlock/assign.xhtml" />
dossier.xhtml:
<h:form>
<ui:include src="dit.xhtml" />
</h:form>
我不使意见更紧凑抱歉,因为我猜问题是定位于视图我展示的整体结构。
您正在将DTO设置为空,您的第二次点击是否应该发生? – Makhiel
输入字段设置为空。不是整个DTO。我的猜测是我用“重置(读取:空)”值重新提交表单,但我无法解释如何或为什么。 – GregD