jsf 2 -单击第二个按钮后,jsf输入字段值消失



问题是,我试图按下一个按钮->去支持bean ->设置布尔值为假/真,并相应地显示一个弹出窗口。如果弹出窗口显示->调用该方法并执行它。

以上是工作,但输入字段,我得到的第一个按钮点击后似乎丢失了,当我点击弹出面板中的按钮。因此,我在第一次单击(它们在backing bean对象中获得)之后获得的所有参数都随着第二次单击(在弹出窗口中)而消失。这是什么呢?

它都在一个表单中,所有的按钮和输入字段等都在一个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 ...

这是我的视图(assign.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>

我很抱歉没有使视图更紧凑,但因为我猜问题是在视图中,我正在显示整个结构。

终于找到了

必须添加2个不同的a4j:区域。1用于表单,1用于弹出面板。

相关内容

  • 没有找到相关文章

最新更新