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 525473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:40:32+00:00 2026-05-13T08:40:32+00:00

I have a JSF 1.2 application (Sun RI, Facelets, Richfaces) that was used only

  • 0

I have a JSF 1.2 application (Sun RI, Facelets, Richfaces) that was used only on IE6 browsers. Now, we must also support Firefox (yeah !).

In one of my pages, I have a form that contains a button that will re-render the whole form. After the re-rendering, some links (<h:commandLink/>) are added in this form.

The JSF code looks like this:

<h:form id="foobar">
    ...
    <a4j:commandButton ... reRender="foobar"/>
    ...
    <h:commandLink .../>
</h:form>

My problem is related to the HTML code generated by the command link component, which is as following:

<a href="#" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['foobar'],'...','');}return false">bla bla</a>

(for information, jsfcljs is the Javascript function generated by the component <h:commandLink/>)

The problem is that document.forms["foobar"] is working well when the page is initially rendered, but once the form is re-rendered after the Ajax call, this code does not work anymore on Firefox (but works on IE6).

This results on a Javascript error when I click on one link in the form after the Ajax call.

Note that if I call document.getElementById("foobar"); after the Ajax call, Firefox founds my form…

If you consider the following Javascript function:

function test() {
    var e = document.forms;
    var tmp = "";
    for (i = 0; i < e.length; i++) {
        tmp = tmp + e[i].id + " ; ";
    }
    alert(tmp);
}

when I run it before and after the Ajax call, I get the following results:

someForm ; anotherForm ; foobar ; // Before Ajax call on FF 
someForm ; anotherForm ; // After Ajax call on FF. PROBLEM HERE!

someForm ; anotherForm ; foobar ; // Before Ajax call on IE6 
someForm ; anotherForm ; foobar ; // After Ajax call on IE6

Here are my thoughts about the reason of the problem:

When the Ajax response is received on the client side, a4j is removing the reRender-ed elements (in particular my foobar form) from the DOM tree objects, which results in removing it from document.forms array.
Then, it adds again the foobar form with its new content. But Firefox does not update the document.forms array, while IE6 does.
That’s why document.forms["foobar"] returns undefined after the Ajax call.

My solution to solve this problem is to change the reRender attribute in order to re-render only sub-parts of the form, and not the form itself. This way, my links work.

However, I wanted to know if there is another way to solve this issue, without modifying the reRender attribute.
Any idea?


Edit

The Javascript code when a command link is clicked is the following:

function dpf(f) {
    var adp = f.adp;
    if (adp != null) {
        for (var i = 0; i < adp.length; i++) {
            f.removeChild(adp[i]);
        }
    }
};

function apf(f, pvp) {
    var adp = new Array();
    f.adp = adp;
    var ps = pvp.split(',');
    for (var i = 0, ii = 0; i < ps.length; i++, ii++) {
        var p = document.createElement("input");
        p.type = "hidden";
        p.name = ps[i];
        p.value = ps[i + 1];
        f.appendChild(p);
        adp[ii] = p;
        i += 1;
    }
};

function jsfcljs(f, pvp, t) {
    apf(f, pvp);
    var ft = f.target;
    if (t) {
        f.target = t;
    }
    f.submit();
    f.target = ft;
    dpf(f);
};

In the <h:commandLink> onclick attribute, we call the jsfcljs(document.forms['foobar'], 'someId', '') which is evaluated in jsfcljs(undefined, 'someId', ''). Then, when f is called, I get a Javacript error that says that f is undefined.

  • 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-05-13T08:40:32+00:00Added an answer on May 13, 2026 at 8:40 am

    The problem is actually an HTML one from what I see.

    Your form should be defined with a name and not simply an id attribute:

    Different browsers treat name and id equivalencies differently. If this does not solve your problem comment and I will produce a test case that does not require a server-side to demonstrate whatever effect you’re seeing.

    Another way around the problem code is to rewrite the inline onclick event calls on the client-side in order to reference the form by id with the document.getElementById(“foobar”) call instead of document.forms[“foobar”]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF application that uses mostly Richfaces. I would like to introduce
We have a JSF web application that uses Acegi security. We also have a
I have created a simple JSF application, now must to connect to SQL Server
We have a JSF 1.2 application with RichFaces 3.3.3 on JBoss 5.1. When we
I have a JSF 1.2 application that has a session going on and whenever
I have a JSF application in which I have different servlets and facelets. The
I have a JSF application that makes much use of session-scoped variables. A new
I have a JSF/ICEFaces application that was working fine but all of the sudden
Using: JSF 1.2, Facelets 1.1.15, GateIn 3.1 GA, Richfaces 3.3.3 I have some common
I have a JSF application with several major components and a component tree under

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.