Results 1 to 6 of 6

Thread: How to Manipulate DOM of Applet's Web Page?

  1. #1
    Join Date
    Aug 2006
    Posts
    122

    How to Manipulate DOM of Applet's Web Page?

    Hi Friends,
    Last time you all guys helped me a lot for solving my issue in Java coding. Now I am working on an applets. I am having a doubt about the manipulating DOM of applets web page.!! So thought that you guys will help me again. So please explain me how to Manipulate DOM of Applet's Web Page? If possible please provide me the necessary coding by which it would be easy for me to understand.!! Thanks a Lot in Advance.!!
    In the end, we will remember not the words of our enemies, but the silence of our friends.
    -Martin Luther King Jr.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: How to Manipulate DOM of Applet's Web Page?

    Before using the DOM of Applet's Web Page, I think that you should know some basic things that are very important from the Java's point of view. The Java DOM API is an implementation of the Java bindings specified in Document Object Model (DOM). In this, only the core DOM interfaces are implemented. Every web page is composed of a series of nested objects. These objects make up the Document Object Model (DOM). The primary purpose of the Java DOM API is to allow Java Applets and Pluglets to interact with and modify the document they are embedded into. Hope that you got some points from this post.!!

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: How to Manipulate DOM of Applet's Web Page?

    The Java DOM API is written as a very thin layer on top of the C++ coreDOM API using JNI. The DOM API provides a standardized, versatile view of a document's contents. By supporting the DOM API, a program allows its data to be manipulated by other routines. Hence, each Java object delegates all method calls to the corresponding C++ coreDOM object. You can use the DOM calls for solving a very wide of range of problems, but it is not necessary that it can solve all the problems. You can say a DOM implementation as a software which takes the parsed XML or HTML document and makes it available for processing via the DOM interfaces.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: How to Manipulate DOM of Applet's Web Page?

    I have provided you with an example of coding that can retrieve a reference to a Document object in the DOMDump applet's start method. The following is the sample of the coding :
    Code:
    public void start() {
        try {
            Class c = Class.forName("URL goes here");
            Method mtd = c.getMethod("getDocument",
                                   new Class[] { java.applet.Applet.class });
            
            HTMLDocument doc = (HTMLDocument) mtd.invoke(null, new Object[] { this });
            HTMLBodyElement body = (HTMLBodyElement) doc.getBody();
            dump(body, INDENT);
        } catch (Exception e) {
            System.out.println("New Java Plug-In not available");
        }
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: How to Manipulate DOM of Applet's Web Page?

    I know how to use DOM in HTML. So I am providing the same so that it may help you. There are two ways of using the HTML module of the DOM. The following are the two ways :
    1. You may write the script of JavaScript or the VBScript on your page.
    2. The other way is by using an external application such as a plug-in, ActiveX control, or Java applet, that accesses the document through your browser.

    Also the good point is that DOM can be implemented using CORBA, COM, or Java Virtual Machine runtime bindings.

  6. #6
    Join Date
    Nov 2008
    Posts
    996

    Re: How to Manipulate DOM of Applet's Web Page?

    The DOMDump applet traverses the DOM tree and writes its contents to the Java Console log. You can check this in following code :
    Code:
    private void DOMdump(Node root, String prefix) {
        if (root instanceof Element) {
            System.out.println(prefix + ((Element) root).getTagName() + 
                                  " / " + root.getClass().getName());
        } else if (root instanceof CharacterData) {
            String data = ((CharacterData) root).getData().trim();
            if (!data.equals("")) {
                System.out.println(prefix + "CharacterData: " + data);
            }
        } else {
            System.out.println(prefix + root.getClass().getName());
        }
        NamedNodeMap attrs = root.getAttributes();
        if (attrs != null) {
            int len = attrs.getLength();
            for (int i = 0; i < len; i++) {
                Node attr = attrs.item(i);
                System.out.print(prefix + HALF_INDENT + "attribute " + i + ": " +
                                 attr.getNodeName());
                if (attr instanceof Attr) {
                    System.out.print(" = " + ((Attr) attr).getValue());
                }
                System.out.println();
            }
        }
    
        if (root.hasChildNodes()) {
            NodeList children = root.getChildNodes();
            if (children != null) {
                int len = children.getLength();
                for (int i = 0; i < len; i++) {
                    dump(children.item(i), prefix + INDENT);
                }
            }
        }
    }

Similar Threads

  1. How to manipulate an ISO images
    By Zeppelin in forum Operating Systems
    Replies: 4
    Last Post: 31-12-2010, 01:44 AM
  2. How to Manipulate XML with XPath in VBScript
    By Zavier in forum Software Development
    Replies: 4
    Last Post: 18-04-2010, 03:05 AM
  3. How to manipulate JavaScript text?
    By Juaquine in forum Software Development
    Replies: 4
    Last Post: 11-02-2010, 05:46 PM
  4. How to Manipulate Array in Perl?
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 20-01-2010, 02:51 PM
  5. Manipulate jQuery with PHP
    By Zecho in forum Software Development
    Replies: 5
    Last Post: 16-06-2009, 02:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,055,199.57683 seconds with 16 queries