Search in sources :

Example 1 with WAbbrText

use of com.github.bordertech.wcomponents.WAbbrText in project wcomponents by BorderTech.

the class WAbbrTextRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    String textString = "abbreviated string";
    String description = "The really long non-abbreviated string";
    WAbbrText text = new WAbbrText();
    text.setText(textString);
    text.setToolTip(description);
    // Test with no abbreviation
    assertSchemaMatch(text);
    assertXpathEvaluatesTo(textString, "//html:abbr", text);
    assertXpathEvaluatesTo(description, "//html:abbr/@title", text);
}
Also used : WAbbrText(com.github.bordertech.wcomponents.WAbbrText) Test(org.junit.Test)

Example 2 with WAbbrText

use of com.github.bordertech.wcomponents.WAbbrText in project wcomponents by BorderTech.

the class WAbbrTextRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WAbbrText component = new WAbbrText();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WAbbrTextRenderer);
}
Also used : WAbbrText(com.github.bordertech.wcomponents.WAbbrText) Test(org.junit.Test)

Example 3 with WAbbrText

use of com.github.bordertech.wcomponents.WAbbrText in project wcomponents by BorderTech.

the class WAbbrTextRenderer method doRender.

/**
 * Paints the given WAbbrText.
 *
 * @param component the WAbbrText to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WAbbrText abbrText = (WAbbrText) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("abbr");
    xml.appendOptionalAttribute("title", abbrText.getToolTip());
    xml.appendOptionalAttribute("class", abbrText.getHtmlClass());
    xml.appendClose();
    xml.append(abbrText.getText(), abbrText.isEncodeText());
    xml.appendEndTag("abbr");
}
Also used : WAbbrText(com.github.bordertech.wcomponents.WAbbrText) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 4 with WAbbrText

use of com.github.bordertech.wcomponents.WAbbrText in project wcomponents by BorderTech.

the class WAbbrTextExample method preparePaintComponent.

/**
 * {@inheritDoc}
 */
@Override
protected void preparePaintComponent(final Request request) {
    super.preparePaintComponent(request);
    if (!isInitialised()) {
        LookupTable lookup = Factory.newInstance(LookupTable.class);
        for (Object entry : lookup.getTable("sex")) {
            WAbbrText abbr = new WAbbrText();
            abbr.setTextWithDesc(entry);
            crtSexPanel.add(abbr);
        }
        for (Object entry : lookup.getTable("icao")) {
            WAbbrText abbr = new WAbbrText();
            abbr.setTextWithCode(entry);
            crtIcaoPanel.add(abbr);
        }
        setInitialised(true);
    }
}
Also used : LookupTable(com.github.bordertech.wcomponents.util.LookupTable) WAbbrText(com.github.bordertech.wcomponents.WAbbrText)

Example 5 with WAbbrText

use of com.github.bordertech.wcomponents.WAbbrText in project wcomponents by BorderTech.

the class WAbbrTextRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WAbbrText text = new WAbbrText();
    text.setText(getMaliciousContent());
    assertSafeContent(text);
    text.setToolTip(getMaliciousAttribute("html:abbr"));
    assertSafeContent(text);
}
Also used : WAbbrText(com.github.bordertech.wcomponents.WAbbrText) Test(org.junit.Test)

Aggregations

WAbbrText (com.github.bordertech.wcomponents.WAbbrText)5 Test (org.junit.Test)3 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1 LookupTable (com.github.bordertech.wcomponents.util.LookupTable)1