Sets the text for the title of this page. If there is not a title element on this page, then one has to be generated. @param message the new text
(final String message)
| 1168 | * @param message the new text |
| 1169 | */ |
| 1170 | public void setTitleText(final String message) { |
| 1171 | HtmlTitle titleElement = getTitleElement(); |
| 1172 | if (titleElement == null) { |
| 1173 | LOG.debug("No title element, creating one"); |
| 1174 | final HtmlHead head = (HtmlHead) getFirstChildElement(getDocumentElement(), HtmlHead.class); |
| 1175 | if (head == null) { |
| 1176 | // perhaps should we create head too? |
| 1177 | throw new IllegalStateException("Headelement was not defined for this page"); |
| 1178 | } |
| 1179 | final Map<String, DomAttr> emptyMap = Collections.emptyMap(); |
| 1180 | titleElement = new HtmlTitle(HtmlTitle.TAG_NAME, this, emptyMap); |
| 1181 | if (head.getFirstChild() != null) { |
| 1182 | head.getFirstChild().insertBefore(titleElement); |
| 1183 | } |
| 1184 | else { |
| 1185 | head.appendChild(titleElement); |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | titleElement.setNodeValue(message); |
| 1190 | } |
| 1191 | |
| 1192 | /** |
| 1193 | * Gets the first child of startElement that is an instance of the given class. |
no test coverage detected