【问题标题】:Error Message in modal JSF doesn´t work模态 JSF 中的错误消息不起作用
【发布时间】:2013-12-23 20:07:53
【问题描述】:

我在 jsf 中有一个 xhtm,在里面有一个 modal。

在这个模式中,我有一个字段,我正在尝试验证并返回错误。

我的代码:

模态:

    <rich:popupPanel id="cancelssi" modal="true" width="500" height="280" zindex="2" domElementAttachment="form" show="#{demandasMB.showCancelar}" showWhenRendered="#{demandasMB.showCancelar}" >
    ...  


<h:panelGroup layout="block" class="area-input-100" id="idmotivocancelamentopanel">
                <h:panelGroup  class="label-campo">Justificativa de cancelamento:</h:panelGroup>    
                <h:inputTextarea styleClass="textarea-form-2-linhas" id="idmotivocancelamento" value="#{demandasMB.demandas.cnmmotivocancelamento}" maxlength="255"/>
                <h:message for="idmotivocancelamento" />                                    
            </h:panelGroup> 

            <h:panelGroup layout="block" class="clear"/>

            <h:panelGroup layout="block" styleClass="alinhaBotao">
                <h:commandButton value="Cancelar">
                    <f:ajax render="idmotivocancelamento idmotivocancelamentopanel" 
                                event="click"
                                listener="#{demandasMB.preCancelar()}"
                                execute="@form"
                                />
                </h:commandButton>          
                <h:commandButton value="Fechar"/>           
            </h:panelGroup>
    </rich:popupPanel>

在我的 MB 中:

    public void preCancelar(){

    if(StringUtils.isBlank(demandas.getCnmmotivocancelamento())){

        FacesMessage fm = new FacesMessage("Favor preencher");
        FacesContext.getCurrentInstance().addMessage("idmotivocancelamento",fm);

    }else{
        showConfirmacaoCancelar = true;
        showCancelar = false;
    }
}

我正在构建 FacesMessage,但没有出现在我的模式中。

我做错了什么?

谢谢

【问题讨论】:

    标签: jsf jsf-2 richfaces


    【解决方案1】:

    您需要 ajax 更新 idmotivocancelamentopanel 以反映您正在添加的 FacesMessages

    另一种方法是使用&lt;rich:message/&gt;。使用ajaxRendered="true" 属性将允许消息组件在ajax 请求上自动更新。因此,您将拥有:

    <rich:message for="idmotivocancelamento" ajaxRendered="true"/>
    

    【讨论】:

      猜你喜欢
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 2018-09-07
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      相关资源
      最近更新 更多