001/* 002 * Copyright 2012 GWT-Bootstrap 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.github.gwtbootstrap.client.ui; 017 018import com.github.gwtbootstrap.client.ui.constants.Constants; 019import com.google.gwt.user.client.ui.HasHTML; 020import com.google.gwt.user.client.ui.HasText; 021 022 023/** 024 * HelpBlock is a form help text widget. 025 * <p> 026 * HelpBlock can include html and widget 027 * <h3>UiBinder Usage:</h3> 028 * 029 * <pre> 030 * {@code 031 * <b:HelpBlock> 032 * HelpBlock can include html and widgets<br/> 033 * <b:Code>text</b:Code> 034 * <a href="#">a</a> 035 * </b:HelpBlock> 036 * } 037 * </pre> 038 * </p> 039 * 040 * @since 2.0.4.0 041 * 042 * @author ohashi keisuke 043 * 044 * @see Controls 045 * @see HelpInline 046 * @see <a href="http://twitter.github.com/bootstrap/base-css.html#forms">Bootstrap documentation</a> 047 */ 048public class HelpBlock extends Paragraph implements HasHTML, HasText { 049 050 /** 051 * Creates an empty widget. 052 */ 053 public HelpBlock() { 054 this(""); 055 } 056 057 /** 058 * Creates a widget with the html set.. 059 * @param html content html 060 */ 061 public HelpBlock(String html) { 062 super(html); 063 setStyleName(Constants.HELP_BLOCK); 064 } 065 066 /** 067 * Gets this object's contents as HTML. 068 * 069 * @return the object's HTML 070 */ 071 @Override 072 public String getHTML() { 073 return getElement().getInnerHTML(); 074 } 075 076 /** 077 * Sets this object's contents via HTML. Use care when setting an object's 078 * HTML; it is an easy way to expose script-based security problems. Consider 079 * using {@link #setText(String)} whenever possible. 080 * 081 * @param html the object's new HTML 082 */ 083 @Override 084 public void setHTML(String html) { 085 getElement().setInnerHTML(html); 086 } 087}