Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Closed Thread
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-05-2011, 12:20 PM   PM User | #1
katnyan
New to the CF scene

 
Join Date: May 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
katnyan is an unknown quantity at this point
Thumbs up below code is not working in windows7 ie8, but working fine in xp ie8. Please help me

below code is not working in windows7 ie8, but working fine in xp ie8




Code:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import netscape.javascript.JSObject;

public class htmlMenu extends Applet
    implements ActionListener
{

    public void init()
    {
        try
        {
            winLocal = JSObject.getWindow(this);
        }
        catch(Exception _ex)
        {
            System.out.println("Error: Applet cannot get window name. \nThis error will throw unhandled exceptions.\nMake sure you have the MAYSCRIPT attribute in your object or applet tag!");
        }
        paramItemCap_ = getParameter("itemcap");
        paramDisableList_ = getParameter("disable");
        paramCommonFunction_ = getParameter("commonfunction");
        boolMenuEnabled = true;
        if(paramItemCap_ != null && paramItemCap_ != "")
            intItemCap = Integer.parseInt(paramItemCap_) + 1;
        mnuMain = new PopupMenu();
        mnuSub = new Menu[intItemCap];
        mnuItem = new MenuItem[intItemCap];
        strAryFunctions = new String[intItemCap];
        if(!getNextParam(1))
        {
            intItemCap = 0;
            intLenDisableList = 0;
        }
        for(x = 1; x < intItemCap; x++)
        {
            intMaxItemID = x;
            intMenuParentID = Integer.parseInt(strMenuData.substring(0, intDLoc1));
            strMenuLabel = strMenuData.substring(intDLoc1 + 1, intDLoc2);
            strMenuFunction = strMenuData.substring(intDLoc2 + 1);
            if(strMenuFunction.length() < 1)
                strMenuFunction = paramCommonFunction_;
            if(strMenuLabel.equals("-"))
                buildSeparator(intMenuParentID);
            else
            if(strMenuFunction.equals("none") || strMenuFunction.equals("submenu"))
            {
                mnuSub[x] = new Menu(strMenuLabel);
                mnuSub[x].addActionListener(this);
                if(intMenuParentID == 0)
                    mnuMain.add(mnuSub[x]);
                else
                    mnuSub[intMenuParentID].add(mnuSub[x]);
            } else
            if(strMenuFunction.equals("url"))
            {
                menuURL = getParameter("url" + x);
                dlLoc = menuURL.indexOf("|");
                if(dlLoc != -1)
                {
                    strTemp = menuURL.substring(dlLoc + 1);
                    menuURL = menuURL.substring(0, dlLoc);
                    if(strTemp.equals("_top"))
                    {
                        strPre = "top.location.href='";
                        strPost = "';";
                    } else
                    if(strTemp.equals("_new"))
                    {
                        strPre = "window.open('";
                        strPost = "','NewWindow');";
                    } else
                    {
                        strPre = "top." + strTemp + ".location.href='";
                        strPost = "';";
                    }
                } else
                {
                    strPre = "location.href=";
                    strPost = "';";
                }
                strAryFunctions[x] = strMenuFunction;
                mnuItem[x] = new MenuItem(strMenuLabel);
                mnuItem[x].setActionCommand(strPre + menuURL + strPost);
                if(intMenuParentID == 0)
                    mnuMain.add(mnuItem[x]);
                else
                    mnuSub[intMenuParentID].add(mnuItem[x]);
            } else
            {
                strAryFunctions[x] = strMenuFunction;
                mnuItem[x] = new MenuItem(strMenuLabel);
                mnuItem[x].setActionCommand(strMenuFunction);
                if(intMenuParentID == 0)
                    mnuMain.add(mnuItem[x]);
                else
                    mnuSub[intMenuParentID].add(mnuItem[x]);
            }
            if(!getNextParam(x + 1))
                x = intItemCap;
        }

        add(mnuMain);
        mnuMain.addActionListener(this);
        if(paramDisableList_ != null && paramDisableList_.length() > 0)
        {
            paramDisableList_ += ",";
            strItemID = "0";
            intLenDisableList = paramDisableList_.length();
            for(x = 0; x <= intLenDisableList - 1; x++)
            {
                intChar = paramDisableList_.charAt(x);
                if(intChar != 44)
                    strItemID += (char)intChar;
                else
                    try
                    {
                        intItemID = Integer.parseInt(strItemID);
                        if(intItemID <= intMaxItemID)
                            setItemEnabled(intItemID, false);
                        strItemID = "0";
                    }
                    catch(NumberFormatException _ex)
                    {
                        strItemID = strItemID;
                        getAppletContext().showStatus("Invalid Disable Parameter");
                    }
            }

        }
    }

    private void setItemEnabled(int intItemID_, boolean boolEnabled_)
    {
        mnuItem[intItemID_].setEnabled(boolEnabled_);
    }

    private void buildSeparator(int parentID_)
    {
        if(parentID_ == 0)
            mnuMain.addSeparator();
        else
            mnuSub[menuItemParent].addSeparator();
    }

    private boolean getNextParam(int x_)
    {
        strMenuData = getParameter("item" + x_);
        if(strMenuData == null)
            return false;
        intDLoc1 = strMenuData.indexOf("|");
        if(intDLoc1 == -1)
            return false;
        intDLoc2 = strMenuData.lastIndexOf("|");
        if(intDLoc2 == intDLoc1)
        {
            strMenuData += "|";
            intDLoc2 = strMenuData.length() - 1;
        }
        return true;
    }

    public String getAppletInfo()
    {
        return "htmlMenu Java Applet\nComputer Task Group, Inc.\nCopyright 1999";
    }

    public void setMenuEnabled(boolean state_)
    {
        boolMenuEnabled = state_;
    }

    public void actionPerformed(ActionEvent e_)
    {
        String strCommand = e_.getActionCommand();
        String strArguments[] = {
            strCommand
        };
        if(strCommand == null || strCommand.length() < 1)
            try
            {
                winLocal.eval("alert('The page author has failed to supply an appropriate action for this menu item')");
            }
            catch(Exception _ex)
            {
                getAppletContext().showStatus("Error accessing function or window");
            }
        else
            winLocal.eval(strCommand);
    }

    public void showMenu(int intX_, int intY_)
    {
        if(boolMenuEnabled)
            mnuMain.show(this, intX_, intY_);
    }

    public htmlMenu()
    {
        intItemCap = 100;
    }

    JSObject winLocal;
    PopupMenu mnuMain;
    MenuItem mnuItem[];
    Menu mnuSub[];
    int intItemID;
    int intMaxItemID;
    int intMenuParentID;
    int intLenDisableList;
    int intDLoc1;
    int dlLoc;
    int intDLoc2;
    int menuItemParent;
    int intItemCap;
    int intChosenItem;
    int intChar;
    int x;
    boolean boolMenuEnabled;
    String menuURL;
    String strTemp;
    String strPre;
    String strPost;
    String strAryFunctions[];
    String strMenuLabel;
    String strMenuFunction;
    String strMenuData;
    String strItemID;
    String paramDisableList_;
    String paramItemCap_;
    String paramCommonFunction_;
}

Last edited by WA; 08-15-2011 at 08:15 AM..
katnyan is offline  
Old 05-06-2011, 01:18 AM   PM User | #2
Gox
Regular Coder

 
Gox's Avatar
 
Join Date: May 2006
Location: Ontario, Canada
Posts: 392
Thanks: 2
Thanked 20 Times in 20 Posts
Gox will become famous soon enough
What part isn't working?
Gox is offline  
Old 05-06-2011, 10:04 AM   PM User | #3
katnyan
New to the CF scene

 
Join Date: May 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
katnyan is an unknown quantity at this point
action lister is not working
katnyan is offline  
Old 07-30-2011, 08:12 PM   PM User | #4
AndrewCollins
New Coder

 
Join Date: Jul 2011
Location: Berkeley, CA
Posts: 20
Thanks: 2
Thanked 2 Times in 1 Post
AndrewCollins is an unknown quantity at this point
Fixed. PM sent.

If you have any other questions mate let me know.

Action lister needed minor adjustment.
AndrewCollins is offline  
The Following 2 Users Say Thank You to AndrewCollins For This Useful Post:
Dentist_Ali (08-16-2011), vincentpeter (08-15-2011)
Old 08-10-2011, 08:45 PM   PM User | #5
AndrewCollins
New Coder

 
Join Date: Jul 2011
Location: Berkeley, CA
Posts: 20
Thanks: 2
Thanked 2 Times in 1 Post
AndrewCollins is an unknown quantity at this point
Quote:
Originally Posted by AndrewCollins View Post
Fixed. PM sent.

If you have any other questions mate let me know.

Action lister needed minor adjustment.
I have it finished I don't have your email please email it to me.
__________________
AndrewCollins is offline  
Old 08-13-2011, 11:13 AM   PM User | #6
justin482000
New to the CF scene

 
Join Date: Aug 2011
Posts: 5
Thanks: 0
Thanked 1 Time in 1 Post
justin482000 is an unknown quantity at this point
Quote:
Originally Posted by AndrewCollins View Post
Fixed. PM sent.

If you have any other questions mate let me know.

Action lister needed minor adjustment.
why don't you also share the solution here on this thread, so everyone can benefit?

Thanks!
justin482000 is offline  
Old 08-13-2011, 11:15 AM   PM User | #7
praneybehl
New Coder

 
Join Date: Aug 2011
Location: Brisbane, AUS
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
praneybehl is an unknown quantity at this point
I agree, it would be nice if a solution could be shared.
praneybehl is offline  
Old 08-13-2011, 04:44 PM   PM User | #8
am335
New to the CF scene

 
Join Date: Aug 2011
Location: Florida, USA
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
am335 is an unknown quantity at this point
Quote:
Originally Posted by AndrewCollins View Post
Fixed. PM sent.

If you have any other questions mate let me know.

Action lister needed minor adjustment.
Andrew,
Will your solution work in 64-bit versions of IE? Also, will your solution behave in IE9? Would you mind posting your solution here?

Thanks.
am335 is offline  
Old 08-13-2011, 06:09 PM   PM User | #9
Coolest
New to the CF scene

 
Join Date: Aug 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Coolest is an unknown quantity at this point
Quote:
Originally Posted by AndrewCollins View Post
I have it finished I don't have your email please email it to me.
Anderw, please PM code to me as well.

Thanks.
Coolest is offline  
Old 08-14-2011, 07:39 AM   PM User | #10
justjoshhere
New Coder

 
Join Date: Aug 2011
Location: I live in Sydney, Australia but travel a lot for business
Posts: 14
Thanks: 0
Thanked 2 Times in 2 Posts
justjoshhere is an unknown quantity at this point
Hi folks, +1 for sharing your solution with the thread Andrew - if its not too much hassle anyways...

Also interested to know if anyone has worked out whether merely upgrading to IE9 will solve the problems, it seems like the path of least resistance
justjoshhere is offline  
Old 08-14-2011, 08:40 AM   PM User | #11
alexd1
New to the CF scene

 
Join Date: Aug 2011
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
alexd1 is an unknown quantity at this point
Andrew, I'd also be interested in the solution for this. I've had a look through with some friends of mine, and none of us can work out why it works in IE on XP but not Win7 - sometimes I really do think IE has a mind of its own.
alexd1 is offline  
Old 08-15-2011, 01:25 AM   PM User | #12
JamesMartes2011
New to the CF scene

 
Join Date: Aug 2011
Location: Philippines
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
JamesMartes2011 is an unknown quantity at this point
I am also having this problem. It would be great if Andrew could share it on this thread or pm us for the solution. Have been looking to fix this for some time now.
JamesMartes2011 is offline  
Old 08-15-2011, 01:38 AM   PM User | #13
siliconboy187
New to the CF scene

 
Join Date: Aug 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
siliconboy187 is an unknown quantity at this point
I would like that sent to me as well
siliconboy187 is offline  
Old 08-15-2011, 08:45 PM   PM User | #14
Sysbase
New to the CF scene

 
Join Date: Feb 2009
Posts: 8
Thanks: 1
Thanked 0 Times in 0 Posts
Sysbase is an unknown quantity at this point
Could you PM me the solution? I'm having the same problem with some Java in xp ie8 as well. Thanks!
__________________
Dog Stairs
Sysbase is offline  
Old 08-16-2011, 03:14 AM   PM User | #15
travin69
New Coder

 
Join Date: Aug 2011
Location: Virginia
Posts: 10
Thanks: 2
Thanked 1 Time in 1 Post
travin69 is an unknown quantity at this point
Please send details as well.

Poll: Who doesn't like windows?

Answer: Me, Me, Me

Thanks in advance.
travin69 is offline  
Closed Thread

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:48 PM.


Advertisement
Log in to turn off these ads.