wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Across JSPs wrong JavaScript Function with the same prototype is getting called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Across JSPs wrong JavaScript Function with the same prototype is getting called" Watch "Across JSPs wrong JavaScript Function with the same prototype is getting called" New topic
Author

Across JSPs wrong JavaScript Function with the same prototype is getting called

Gajendra Tomer
Ranch Hand

Joined: Sep 22, 2008
Posts: 32
Hi There !

Use Case Description:
------------------------
I have a report as JSP and in this JSP I have one "Select Job" button and few dropdowns into the "Filter" section of this report.

When user clicks on "Select Job" button a popup window of "Job List" opens from where user can filter desired "Job" over which he/she wants to generate report.

Problem Description:
-----------------------
In order to capture selected filters I have defined Javascript function: "captureDropDownSelectedValues(filters)" not only in report JSP but also in "Job List" JSP which appears in popup window .

Please note that the name and prototype of "captureDropDownSelectedValues(filters)" is same in both JSPs.

Now issue here is that when I click "Select Job" button in report JSP & configures filters there then it shows me "Job List" JSP perfectly fine and captures filters properly but the same is not happening in report JSP...I mean when I set filters in report JSP and click "Generate Report" then in order to capture report filter values I am expecting that browser should call report's "captureDropDownSelectedValues(filters)" function whereas browser is calling "captureDropDownSelectedValues(filters)" function of "Job List" JSP page...I verified this in "Firebug".

Any idea why is so?

Gajendra
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Your problem description could use code since the words do not paint a clear picture.

Eric
Gajendra Tomer
Ranch Hand

Joined: Sep 22, 2008
Posts: 32
Code may complicate the issue description...ok let me rephrase it in a simplified way.

Say we have 2 JSPs...JSP1 & JSP2 and having identical javascript functions with identical code...say the name of that function is "function1()".

Now what's happening that when we call "function1()" of both JSPs one after another then IE8 get goofed up and call "function1()" of JSP1 instead of JSP2.

Tomar

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61623
    
  67

What leads you to believe that? Only one page is loaded at a time, unless you have frames or a frameset.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18887
    
    8

Gajendra Tomer wrote:Now what's happening that when we call "function1()" of both JSPs one after another then IE8 get goofed up and call "function1()" of JSP1 instead of JSP2.


And the code of both functions is identical, so I don't see why that's a problem or how you could even notice it.
Gajendra Tomer
Ranch Hand

Joined: Sep 22, 2008
Posts: 32
Hi Paul & Bear!

I noticed this(that the wrong function is getting called) while debugging javascript code in "Firebug".

When I changed the name of those identical functions then it started working fine.

Code for your reference:
-------------------------


SNIPPET1:

JSP1(having identical function:"function1()") is having following snippet:
--------------------------------------

Note that function:"selectSomethingID();" mentioned above invokes JSP2(having identical function:"function1()").

Also, JSP1 is having following code snippet from where it invokes "function1()":


SNIPPET2:



So, what happens if we click button 1st which is given in SNIPPET1 then it invokes function:"function1()" of JSP2...that's ok....but just after that....if panel(refer SNIPPET2) invokes function:"function1()" of JSP1 then it doesn't get invoked rather function:"function1()" of JSP2 is invoked.

This I noticed in Firebug.

I hope now you will be clear with the problem scenario.

Gajendra

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Across JSPs wrong JavaScript Function with the same prototype is getting called