XSP JSF FacesContext addMessage does not always work

124 Views Asked by At

I have a JSF page where the user is entering several information. When the user submits the data it is first validated and if the submission is succesful the user should get a FacesMessage also.

I have a custom control for a menubar which I am using in every single page:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xc="http://www.ibm.com/xsp/custom">
    <xp:panel>
        <xp:this.facets>
             <!-- Some Logos and stuff -->
              <xp:panel xp:key="contentFacet">
                    <xp:callback facetName="contentContainer"></xp:callback>
              </xp:panel>
        </xp:this.facets>
    </xp:panel>
</xp:view>

The menu is then used the following way:

<xc:cc_layout_main><xp:this.facets>
    <xp:panel xp:key="contentContainer">
        <xc:cc_content_form></xc:cc_content_form></xp:panel>
    </xp:this.facets></xc:cc_layout_main>

The cc_content_form uses this control:

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:messages id="messages1" styleClass="test" layout="table"
        errorClass="alert-warning" fatalClass="alert-danger"
        infoClass="alert-info" warnClass="alert-warning" showDetail="true"
        showSummary="true" disableTheme="false" globalOnly="false">
    </xp:messages>

    <xp:scriptBlock id="scriptBlock1">
        <xp:this.value><![CDATA[
// Validierungs Nachrichten entfernen
var delayMs = 750;
$('body')
    .on('click', function(event){
        x$('#{id:messages1}').delay(delayMs).fadeOut(500);
    })
    .on('keyup', function(event){
        x$('#{id:messages1}').delay(delayMs).fadeOut(500);          
    })
]]></xp:this.value>
    </xp:scriptBlock>

</xp:view>

In the submit function I am using this in the validation function:

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "error", "some error")); 

This call is wrapped in a helper class method with a singletone pattern so it can be used from all pages. For the validation messages this works just fine but further down in the valdiation method before I return the actionResult "xsp-success" it does not work. No message shows up, I do not get any Exception.

Can anybody help on this?

1

There are 1 best solutions below

0
On

Turns out I messed up the NavigationRules ... Its working just fine