User    Pass    













Key Benefits




Standards Supported




Download Now


API Documentation


Developers Guide


Code Examples


Updated Builds


Technical Articles






Jump to:

General WebRenderer Functions

  WebRenderer example code base.


Advanced WebRenderer functions


Application test examples


Deploying WebRenderer

WebRenderer DOM




Making use of the WebRenderer DOM to get FORM elements




Getting FORM Elements with the WebRenderer DOM

The WebRenderer DOM can be used to traverse through the structure of documents and find certain elements. This example displays navigating through the WebRenderer DOM and getting all FORM elements.

Example of getting Input type FORM Elements

try {
       IDocument doc = browser.getDocument();
       //Get the Forms in the Document
       IElementCollection forms = doc.getForms();
       System.out.println("There are " + forms.length() + " forms.");

       //Go through and find all the INPUTs for each form
       //and print thier name and value
       for (int i = 0; i < forms.length(); i++) {
                 System.out.println("<FORM " + i + ">");
                 IElement form = forms.item(i);
                 Vector inputs = new Vector();

                 //Call a function that recursivly goes through all
                 //children from an IElement and fills a Vector
                 //with children with the INPUT tag
                 getInputElementsForForm(form, inputs);

                 for (int j = 0; j < inputs.size(); j++) {
                           IElement input = (IElement) inputs.elementAt(j);
                           System.out.println( "INPUT: name:"+ input.getAttribute("name", 0) + "\t value:" + input.getValue());
                            if(input.getValue().indexOf("Google Search") != -1){
                                    googleSearchBtn = input;
                            } else if(input.getAttribute("name", 0).equals("q")){
                                    // Working on implementing/fixing setValue and setAttribute bug
                                    //System.out.println("Got the Q textfield");
                                    //input.setValue("Set within Java");
                                    //System.out.println("getAttribute: "+input.getAttribute("q", 0));
} catch (Exception ex) {
       System.out.println("Exception caught: " + e);


public void getInputElementsForForm(IElement at, Vector items) {
       //If the current element has the tagName INPUT, add it to the Vector
       if ((at.getTagName() != null) && (at.getTagName().equalsIgnoreCase("input"))) {
       } else {
       //It's not an Input so call this function on all it's children
                 IElementCollection childs = at.getChildElements();
                 if (childs != null) {
                           for (int i = 0; i < childs.length(); i++) {
                                    getInputElementsForForm(childs.item(i), items);




Millions of deployments and counting.. Users of JadeLiquid's tools can be found in every corner of the Earth




 > Enabling Flash in WebRenderer - Article
 > Browser Zoom Effect using WebRenderer - Article
 > Applet deployment techniques - Article
 > WebRenderer core features on display! - Article
   Additional News  
 > Enabling HTML 5 WebSockets in WebRenderer - Blog
 > 64bit WebRenderer deployment with Web Start - Blog
 > Deploying WebRenderer Server Edition in Tomcat - Blog
 > WebRenderer 6 adds performance text search - Blog


 Java and the Java Logo are trademarks or registered trademarks of Oracle Corporation in the United States and other countries 

Privacy Policy  |   Disclaimer