com.google.gwt.dom.client.MetaElement Java Examples
The following examples show how to use
com.google.gwt.dom.client.MetaElement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NaluPluginGWT.java From nalu with Apache License 2.0 | 6 votes |
@Override public void updateMetaNameContent(String name, String content) { NodeList<Element> metaTagList = Document.get() .getElementsByTagName("meta"); for (int i = 0; i < metaTagList.getLength(); i++) { if (metaTagList.getItem(i) instanceof MetaElement) { MetaElement nodeListElement = (MetaElement) metaTagList.getItem(i); if (!Objects.isNull(nodeListElement.getName())) { if (nodeListElement.getName() .equals(name)) { nodeListElement.removeFromParent(); break; } } } } MetaElement metaElement = Document.get() .createMetaElement(); metaElement.setName("name"); metaElement.setContent("content"); Element headerElement = getHeaderNode(); if (!Objects.isNull(headerElement)) { headerElement.appendChild(metaElement); } }
Example #2
Source File: DocumentMeta.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 6 votes |
/** * Return the first meta tag from the head section with name matching. <br> * If createIfMissing the tag is created and added at the end of the head section.<br> * <p> * <strong>Note : </strong> the name is case insensitive * </p> * * @param name the name attribute of the metta tag * @param createIfMissing create the tag in the head section if missing * @return meta tag element or null */ public static MetaElement getDescriptionTag(String name, boolean createIfMissing) { Document doc = Document.get(); HeadElement head = doc.getHead(); assert head != null : "No head section found in the document"; assert name != null : "the name must not be null"; NodeList<Element> tags = head.getElementsByTagName("meta"); MetaElement metaTag = null; for (int i = 0; i < tags.getLength(); i++) { metaTag = (MetaElement) tags.getItem(i); if (name.equalsIgnoreCase(metaTag.getName())) { return metaTag; } } if (createIfMissing) { metaTag = doc.createMetaElement(); metaTag.setName(name); head.appendChild(metaTag); } return metaTag; }
Example #3
Source File: NaluPluginGWT.java From nalu with Apache License 2.0 | 5 votes |
@Override public void updateMetaPropertyContent(String property, String content) { NodeList<Element> metaTagList = Document.get() .getElementsByTagName("meta"); for (int i = 0; i < metaTagList.getLength(); i++) { if (metaTagList.getItem(i) instanceof MetaElement) { MetaElement nodeListElement = (MetaElement) metaTagList.getItem(i); if (!Objects.isNull(nodeListElement.getAttribute("property"))) { if (nodeListElement.getAttribute("property") .equals(property)) { nodeListElement.removeFromParent(); break; } } } } MetaElement metaElement = Document.get() .createMetaElement(); metaElement.setAttribute("property", property); metaElement.setContent("content"); Element headerElement = getHeaderNode(); if (!Objects.isNull(headerElement)) { headerElement.appendChild(metaElement); } }
Example #4
Source File: DemoGwtWebApp.java From demo-gwt-springboot with Apache License 2.0 | 5 votes |
private void addMetaElements() { logger.info("Add viewport"); MetaElement element = Document.get().createMetaElement(); element.setName("viewport"); element.setContent("width=device-width, initial-scale=1.0"); NodeList<Element> node = Document.get().getElementsByTagName("head"); Element elementHead = node.getItem(0); elementHead.appendChild(element); }
Example #5
Source File: CubaRichTextAreaWidget.java From cuba with Apache License 2.0 | 5 votes |
protected void setContentCharset() { rta.addInitializeHandler(event -> { IFrameElement iFrameElement = IFrameElement.as(rta.getElement()); HeadElement headElement = iFrameElement.getContentDocument().getHead(); MetaElement charsetMetaElement = Document.get().createMetaElement(); charsetMetaElement.setHttpEquiv(HttpHeaders.CONTENT_TYPE); charsetMetaElement.setContent(HttpHeaders.CONTENT_TYPE_TEXT_HTML_UTF8); headElement.appendChild(charsetMetaElement); }); }
Example #6
Source File: CsrfController.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
private void init() { NodeList<Element> tags = Document.get().getElementsByTagName("meta"); for (int i = 0; i < tags.getLength(); i++) { MetaElement metaTag = (MetaElement) tags.getItem(i); String metaName = metaTag.getName(); String metaContent = metaTag.getContent(); if (META_NAME_CSRF_TOKEN.equals(metaName) && !Strings.isNullOrEmpty(metaContent)) { this.token = metaContent; } if (META_NAME_CSRF_HEADER.equals(META_NAME_CSRF_HEADER) && !Strings.isNullOrEmpty(metaContent)) { this.header = metaContent; } } }