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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 285k
  • Answers 285k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In the context of if statements I'm with you, it… May 13, 2026 at 4:38 pm
  • Editorial Team
    Editorial Team added an answer You can always use [navigationController setNavigationBarHidden:YES animated:NO]; or set it… May 13, 2026 at 4:38 pm
  • Editorial Team
    Editorial Team added an answer Can I easily build a JSON-RPC consumer in .NET? Yes.… May 13, 2026 at 4:38 pm

Related Questions

Explanation: I have a JSF command link that sets a member in the backing
I'm a undergrad Student at a German University. I have a team Programming Course
I have a Web Application deployed to a local Glassfish server which I would
Guys, for some reason EL is not telling actions from properties. I have this
I am running a Seam web application with Richfaces for the JSF implementation. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.