Search in sources :

Example 1 with SafeHtmlBuilder

use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.

the class I18N2Test method sh.

/**
 * Wrapper to easily convert a String literal to a SafeHtml instance.
 *
 * @param string
 * @return a SafeHtml wrapper around the supplied string
 */
private SafeHtml sh(String string) {
    SafeHtmlBuilder buf = new SafeHtmlBuilder();
    buf.appendHtmlConstant(string);
    return buf.toSafeHtml();
}
Also used : SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 2 with SafeHtmlBuilder

use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.

the class AbstractCell method setValue.

public void setValue(Context context, Element parent, C value) {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    render(context, value, sb);
    parent.setInnerSafeHtml(sb.toSafeHtml());
}
Also used : SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 3 with SafeHtmlBuilder

use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.

the class EditTextCellTest method testRenderViewDataDoneEditing.

/**
 * Test rendering the cell with a valid value and view data, but without
 * editing.
 */
public void testRenderViewDataDoneEditing() {
    EditTextCell cell = createCell();
    ViewData viewData = new ViewData("originalValue");
    viewData.setText("newValue");
    viewData.setEditing(false);
    cell.setViewData(DEFAULT_KEY, viewData);
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, DEFAULT_KEY);
    cell.render(context, "originalValue", sb);
    assertEquals("newValue", sb.toSafeHtml().asString());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) ViewData(org.gwtproject.cell.client.EditTextCell.ViewData) SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 4 with SafeHtmlBuilder

use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.

the class EditTextCellTest method testRenderUnsafeHtml.

/**
 * Test rendering the cell with a malicious value.
 */
public void testRenderUnsafeHtml() {
    EditTextCell cell = createCell();
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, null);
    cell.render(context, "<script>malicious</script>", sb);
    assertEquals("&lt;script&gt;malicious&lt;/script&gt;", sb.toSafeHtml().asString());
}
Also used : Context(org.gwtproject.cell.client.Cell.Context) SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Example 5 with SafeHtmlBuilder

use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.

the class EditableCellTestBase method testRenderViewData.

/**
 * Test rendering the cell with a valid value and view data.
 */
public void testRenderViewData() {
    AbstractEditableCell<T, V> cell = createCell();
    T value = createCellValue();
    cell.setViewData(DEFAULT_KEY, createCellViewData());
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    Context context = new Context(0, 0, DEFAULT_KEY);
    cell.render(context, value, sb);
    String expectedInnerHtmlViewData = getExpectedInnerHtmlViewData();
    String asString = sb.toSafeHtml().asString();
    assertEquals(expectedInnerHtmlViewData, asString);
}
Also used : SafeHtmlBuilder(org.gwtproject.safehtml.shared.SafeHtmlBuilder)

Aggregations

SafeHtmlBuilder (org.gwtproject.safehtml.shared.SafeHtmlBuilder)32 Context (org.gwtproject.cell.client.Cell.Context)13 ArrayList (java.util.ArrayList)4 Element (org.gwtproject.dom.client.Element)3 AbstractCell (org.gwtproject.cell.client.AbstractCell)2 ViewData (org.gwtproject.cell.client.EditTextCell.ViewData)2 TextCell (org.gwtproject.cell.client.TextCell)2 ImageElement (org.gwtproject.dom.client.ImageElement)2 ListDataProvider (org.gwtproject.view.client.ListDataProvider)2 TreeViewModel (org.gwtproject.view.client.TreeViewModel)2 HashSet (java.util.HashSet)1 List (java.util.List)1 TreeSet (java.util.TreeSet)1 JavaScriptObject (org.gwtproject.core.client.JavaScriptObject)1 JsArrayInteger (org.gwtproject.core.client.JsArrayInteger)1 Scheduler (org.gwtproject.core.client.Scheduler)1 Style (org.gwtproject.dom.client.Style)1 SafeHtml (org.gwtproject.safehtml.shared.SafeHtml)1 HorizontalAlignmentConstant (org.gwtproject.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant)1 VerticalAlignmentConstant (org.gwtproject.user.client.ui.HasVerticalAlignment.VerticalAlignmentConstant)1