Example usage for com.google.gwt.user.client DOM getAttribute

List of usage examples for com.google.gwt.user.client DOM getAttribute

Introduction

In this page you can find the example usage for com.google.gwt.user.client DOM getAttribute.

Prototype

@Deprecated
public static String getAttribute(Element elem, String attr) 

Source Link

Document

Gets any named property from an element, as a string.

Usage

From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineWidget.java

/**
 * Returns the height of the widget in pixels
 * //from  w w w .  jav a  2  s.  com
 * @return A pixel height
 */
@SuppressWarnings("deprecation")
public int getWidgetHeight() {
    try {
        int height = Integer.parseInt(DOM.getAttribute(root.getElement(), "height").replaceAll("px", ""));
        return height;
    } catch (Exception e) {
        try {
            int height = Integer
                    .parseInt(DOM.getStyleAttribute(root.getElement(), "height").replaceAll("px", ""));
            return height;
        } catch (Exception f) {
            return root.getOffsetHeight();
        }
    }
}

From source file:com.spaceapplications.vaadin.addon.eventtimeline.gwt.client.VEventTimelineWidget.java

@SuppressWarnings("deprecation")
public int getWidgetWidth() {
    try {/*w  ww. ja  v a 2  s  .c  om*/
        int width = Integer.parseInt(DOM.getAttribute(root.getElement(), "width").replaceAll("px", ""));
        return width;
    } catch (Exception e) {
        try {
            int width = Integer
                    .parseInt(DOM.getStyleAttribute(root.getElement(), "width").replaceAll("px", ""));
            return width;
        } catch (Exception f) {
            return root.getOffsetWidth();
        }
    }
}

From source file:com.vaadin.addon.timeline.gwt.client.VTimelineWidget.java

/**
 * Returns the height of the widget in pixels
 * //from   w  ww. ja va  2  s.  c  o  m
 * @return A pixel height
 */
public int getWidgetHeight() {
    try {
        int height = Integer.parseInt(DOM.getAttribute(getElement(), "height").replaceAll("px", ""));
        return height;
    } catch (Exception e) {
        try {
            int height = Integer.parseInt(DOM.getStyleAttribute(getElement(), "height").replaceAll("px", ""));
            return height;
        } catch (Exception f) {
            return getOffsetHeight();
        }
    }
}

From source file:com.vaadin.addon.timeline.gwt.client.VTimelineWidget.java

public int getWidgetWidth() {
    try {//ww w  .  j av  a2  s  .  c  o m
        int width = Integer.parseInt(DOM.getAttribute(getElement(), "width").replaceAll("px", ""));
        return width;
    } catch (Exception e) {
        try {
            int width = Integer.parseInt(DOM.getStyleAttribute(getElement(), "width").replaceAll("px", ""));
            return width;
        } catch (Exception f) {
            return getOffsetWidth();
        }
    }
}

From source file:ibeans.client.util.ExternalHyperlink.java

License:Open Source License

public final String getLink() {
    return DOM.getAttribute(this.anchorElem, "href");
}

From source file:ibeans.client.util.ExternalHyperlink.java

License:Open Source License

public final String getTarget() {
    return DOM.getAttribute(this.anchorElem, "target");
}

From source file:org.ajax4jsf.gwt.client.ComponentEntryPoint.java

License:Open Source License

public void onModuleLoad() {
    // Init callback script
    String jsFunction = "_create_" + GWT.getModuleName().replace('.', '_');
    initJS(jsFunction);//from   w  ww  . j  a  v a  2 s  .  c o m
    List elements = findElementsForClass(RootPanel.getBodyElement(), GWT.getModuleName());
    Element viewStateField = DOM.getElementById("javax.faces.ViewState");
    if (null != viewStateField) {
        viewState = DOM.getAttribute(viewStateField, "value");
    }
    for (Iterator iter = elements.iterator(); iter.hasNext();) {
        Element element = (Element) iter.next();
        String id = DOM.getAttribute(element, "id");
        // got viev state parameter
        Widget widget = createWidget(id);
        // RootPanel clear it content - widget can need use it.
        RootPanel panel = RootPanel.get(id);
        panel.add(widget);
    }
}

From source file:org.ajax4jsf.gwt.client.ComponentEntryPoint.java

License:Open Source License

/**
 * Fill parameters map by data from given element. If data element don't have child elements,
 * got content as text, else - put new map with content of recursive same method.
 * @param dataElement// w w  w . j  a va  2 s .  c o m
 * @param params
 * @param childCount
 */
private void fillParamsMap(Element dataElement, Map params, int childCount) {
    for (int it = 0; it < childCount; it++) {
        Element data = DOM.getChild(dataElement, it);
        String key = DOM.getAttribute(data, "title");
        if (null != key) {
            int dataChildCount = DOM.getChildCount(data);
            if (dataChildCount > 0) {
                // Put data from child elements as new map
                Map innerData = new HashMap(dataChildCount);
                fillParamsMap(data, innerData, dataChildCount);
                params.put(key, innerData);
            } else {
                // Simple text value
                String innerText = DOM.getInnerText(data);
                params.put(key, innerText);
            }
        }
    }
}

From source file:org.ajax4jsf.gwt.client.ComponentEntryPoint.java

License:Open Source License

/**
 * Get a named meta property from the current root panel's head element.
 * Statically cached for efficiency.  Whoops, what if there are different meta properties
 * on each page?/*from  w  ww .  jav a 2s .  com*/
 */
public static String getMetaProperty(String propName) {
    if (gwtMetaProperties == null) {
        gwtMetaProperties = new HashMap();

        Element bodyElement = RootPanel.getBodyElement();
        // go up to the parent
        Element htmlElement = DOM.getParent(bodyElement);
        // iterate over meta children
        Element headElement = DOM.getFirstChild(htmlElement);

        int count = DOM.getChildCount(headElement);
        for (int i = 0; i < count; i++) {
            Element nextChild = DOM.getChild(headElement, i);
            if ("meta".equalsIgnoreCase(getElementTagName(nextChild))) {
                String nameAttribute = DOM.getAttribute(nextChild, "name");
                if ("gwt:property".equals(nameAttribute)) {
                    String contentAttribute = DOM.getAttribute(nextChild, "content");
                    if (contentAttribute != null) {
                        int eqPos = contentAttribute.indexOf("=");
                        if (eqPos != -1) {
                            String name = contentAttribute.substring(0, eqPos);
                            gwtMetaProperties.put(name, contentAttribute.substring(eqPos + 1));
                        }
                    }
                }
            }
        }
    }

    return (String) gwtMetaProperties.get(propName);
}

From source file:org.ajax4jsf.gwt.client.ComponentEntryPoint.java

License:Open Source License

/**
 * Check for dom element is have specified ctyle class.
 *
 * @param element/*from ww w . j  a  v  a  2  s  .  c o  m*/
 * @param className
 */
public static boolean isHaveClass(Element element, String className) {
    String c = DOM.getAttribute(element, "className");

    if (c != null) {
        String[] p = c.split(" ");

        for (int x = 0; x < p.length; x++) {
            if (p[x].equals(className)) {
                return true;
            }
        }
    }
    return false;
}