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);
}
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);
}
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");
}
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);
}
}
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);
}
Aggregations