Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8820939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:43:53+00:00 2026-06-14T05:43:53+00:00

I have a JSF web application in JBoss 7.1 and Richfaces 4.1. I tried

  • 0

I have a JSF web application in JBoss 7.1 and Richfaces 4.1. I tried to configure a custom error page in web.xml but came across the problem, that this does not work for AJAX requests. As a solution I tried to use Omnifaces FullAjaxExceptionHandler which displays the error page fine.

However I wanted to add a form that allows the user to enter additional information and send this, along with the exception, as an email to me. The problem is that on the error page, the submit buttons does not work. When I click on it the error page just reloaded. On the next click everything works as expected.

The same problem occurs with h:commandlinks in a small menu that is in the template of the error page.

I’m quite new to JSF so I don’t really know why this happens and how it can be fixed. Or is there a better way to accomplish this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:43:54+00:00Added an answer on June 14, 2026 at 5:43 am

    This is related to JSF spec issue 790 which boils down to that ajax-updating some component which in turn contains one or more <h:form> components doesn’t properly update the new view state identifier of those forms.

    This issue is fixed in the upcoming JSF 2.2, but until then you’ve to do with the following JavaScript based workaround.

    jsf.ajax.addOnEvent(function(data) {
        if (data.status == "success") {
            var viewState = getViewState(data.responseXML);
    
            if (viewState) {
                for (var i = 0; i < document.forms.length; i++) {
                    var form = document.forms[i];
    
                    if (!hasViewState(form)) {
                        createViewState(form, viewState);
                    }
                }
            }
        }
    });
    
    function getViewState(responseXML) {
        var updates = responseXML.getElementsByTagName("update");
    
        for (var i = 0; i < updates.length; i++) {
            var update = updates[i];
    
            if (update.getAttribute("id") == "javax.faces.ViewState") {
                return update.firstChild.nodeValue;
            }
        }
    
        return null;
    }
    
    function hasViewState(form) {
        for (var i = 0; i < form.elements.length; i++) {
            if (form.elements[i].name == "javax.faces.ViewState") {
                return true;
            }
        }
    
        return false;
    }
    
    function createViewState(form, viewState) {
        var hidden;
    
        try {
            hidden = document.createElement("<input name='javax.faces.ViewState'>"); // IE6-8.
        } catch(e) {
            hidden = document.createElement("input");
            hidden.setAttribute("name", "javax.faces.ViewState");
        }
    
        hidden.setAttribute("type", "hidden");
        hidden.setAttribute("value", viewState);
        hidden.setAttribute("autocomplete", "off");
        form.appendChild(hidden);
    }
    

    Just include it as <h:outputScript name="some.js" target="head"> inside the <h:body> of the error page. If you can’t guarantee that the page uses JSF <f:ajax>, then you might want to add an additional if (typeof jsf !== 'undefined') check before jsf.ajax.addOnEvent() call.

    The JSF component library PrimeFaces has already solved this issue in its core ajax engine, so if you happen to use it already, you might want to replace all <f:ajax> links/buttons by the PrimeFaces ones.

    See also:

    • Communication in JSF 2.0 – Ajax rendering of content which contains another form
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have Web Application which should use JSF 2.0 libraries included in WEB-INF/lib... but
i have a JSF web application. I use Beans as Spring Beans (not JSF
I have a Java-JSF Web Application on GlassFish, in which I want to use
I creating a web application using JSF,Hibernate,Spring. I have added a filter for checking
jboss-as-7.1.1, dynamic web module 3.0, JSF 2.0 (Mojarra), Eclipse Indigo sr2 I have an
We have JSF web application that generates XLS file and gives user link to
I have a pretty big JSF web application. I must convert the application to
I have a JSF (Mojarra) v2.1.11, Primefaces v3.4.2, Java 6 web application using jQuery
I have created a web application using JSF 2.0. I got feedback from my
I am writing a web application using JSF 2. I have downloaded mojarra-2.1.3-FCS-binary.zip and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.