use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WButtonRenderer_Test method testAllOptions.
@Test
public void testAllOptions() throws IOException, SAXException, XpathException {
WButton button = new WButton("All");
button.setDisabled(true);
setFlag(button, ComponentModel.HIDE_FLAG, true);
button.setToolTip("Title");
button.setAccessKey('T');
button.setImageUrl("http://localhost/image.png");
button.setImagePosition(ImagePosition.EAST);
button.setRenderAsLink(true);
button.setAjaxTarget(new WTextField());
button.setPopupTrigger(true);
setActiveContext(createUIContext());
WPanel validationComponent = new WPanel();
button.setAction(new ValidatingAction(new WValidationErrors(), validationComponent) {
@Override
public void executeOnValid(final ActionEvent event) {
// Do nothing
}
});
WContainer root = new WContainer();
root.add(button);
root.add(validationComponent);
assertXpathExists("//html:button[@id]", button);
assertXpathExists("//html:button[contains(@class, 'wc-linkbutton')]", button);
assertXpathEvaluatesTo(button.getText(), "//html:button", button);
assertXpathEvaluatesTo("disabled", "//html:button/@disabled", button);
assertXpathEvaluatesTo("hidden", "//html:button/@hidden", button);
assertXpathEvaluatesTo(button.getToolTip(), "//html:button/@title", button);
assertXpathUrlEvaluatesTo(button.getImageUrl(), "//html:button//html:img/@src", button);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imge')]", button);
assertXpathEvaluatesTo(button.getAccessKeyAsString(), "//html:button/@accesskey", button);
assertXpathEvaluatesTo("true", "//html:button/@aria-haspopup", button);
assertXpathEvaluatesTo(validationComponent.getId(), "//html:button/@data-wc-validate", button);
assertXpathEvaluatesTo(button.getId(), "//ui:ajaxtrigger/@triggerId", button);
button.setImagePosition(ImagePosition.NORTH);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgn')]", button);
button.setImagePosition(ImagePosition.SOUTH);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgs')]", button);
button.setImagePosition(ImagePosition.WEST);
assertXpathExists("//html:button/html:span[contains(@class, 'wc_btn_imgw')]", button);
button.setClientCommandOnly(true);
assertXpathEvaluatesTo("button", "//html:button/@type", button);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WButtonRenderer_Test method testRendererCorrectlyConfigured.
/**
* Test the Layout is correctly configured.
*/
@Test
public void testRendererCorrectlyConfigured() {
WButton component = new WButton();
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WButtonRenderer);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WDataTableRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WDataTable table = new WDataTable();
table.addColumn(new WTableColumn(getMaliciousContent(), WText.class));
table.addColumn(new WTableColumn(getMaliciousContent(), WText.class));
table.addColumn(new WTableColumn(getMaliciousContent(), WText.class));
table.setNoDataMessage(getMaliciousAttribute("ui:table"));
UIContext uic = createUIContext();
assertSafeContent(table);
WButton button = new WButton("dummy");
table.addAction(button);
table.addActionConstraint(button, new ActionConstraint(0, 1, false, getMaliciousAttribute("ui:action")));
assertSafeContent(table);
TableDataModel tableModel = createTableModel();
table.setDataModel(tableModel);
// clear out cached data from previous renders
uic.clearScratchMap();
assertSafeContent(table);
table.setCaption(getMaliciousAttribute("ui:table"));
assertSafeContent(table);
table.setSummary(getMaliciousAttribute("ui:table"));
assertSafeContent(table);
table.setSelectGroup(getMaliciousAttribute("ui:rowselection"));
assertSafeContent(table);
table.setActiveFilters(Arrays.asList(new String[] { getMaliciousAttribute("ui:table") }));
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WDataTableRenderer_Test method testDoPaintTableActionsWithConstraints.
@Test
public void testDoPaintTableActionsWithConstraints() throws IOException, SAXException, XpathException {
final int minSelectedRowCount1 = 1;
final int maxSelectedRowCount1 = 2;
final String message1 = "message1";
final int minSelectedRowCount2 = 1;
final int maxSelectedRowCount2 = 2;
final String message2 = "message2";
WDataTable component = new WDataTable();
component.addColumn(new WTableColumn(COL1_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL2_HEADING_TEST, WTextField.class));
component.addColumn(new WTableColumn(COL3_HEADING_TEST, WTextField.class));
TableDataModel tableModel = createTableModel();
component.setDataModel(tableModel);
component.setVisible(true);
WButton buttonOne = new WButton(TEST_ACTION_ONE);
WButton buttonTwo = new WButton(TEST_ACTION_TWO);
component.addAction(buttonOne);
component.addAction(buttonTwo);
component.addActionConstraint(buttonOne, new ActionConstraint(minSelectedRowCount1, maxSelectedRowCount1, true, message1));
component.addActionConstraint(buttonTwo, new ActionConstraint(minSelectedRowCount2, maxSelectedRowCount2, false, message2));
assertXpathExists("//ui:table/ui:actions", component);
assertXpathEvaluatesTo(TEST_ACTION_ONE, "//ui:table/ui:actions/ui:action[1]/html:button", component);
assertXpathEvaluatesTo(TEST_ACTION_TWO, "//ui:table/ui:actions/ui:action[2]/html:button", component);
String expectedWarning = "error";
assertXpathEvaluatesTo(((new Integer(minSelectedRowCount1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@minSelectedRows", component);
assertXpathEvaluatesTo(((new Integer(maxSelectedRowCount1))).toString(), "//ui:table/ui:actions/ui:action[1]/ui:condition/@maxSelectedRows", component);
assertXpathEvaluatesTo(expectedWarning, "//ui:table/ui:actions/ui:action[1]/ui:condition/@type", component);
assertXpathEvaluatesTo(message1, "//ui:table/ui:actions/ui:action[1]/ui:condition/@message", component);
expectedWarning = "warning";
assertXpathEvaluatesTo(((new Integer(minSelectedRowCount2))).toString(), "//ui:table/ui:actions/ui:action[2]/ui:condition/@minSelectedRows", component);
assertXpathEvaluatesTo(((new Integer(maxSelectedRowCount2))).toString(), "//ui:table/ui:actions/ui:action[2]/ui:condition/@maxSelectedRows", component);
assertXpathEvaluatesTo(expectedWarning, "//ui:table/ui:actions/ui:action[2]/ui:condition/@type", component);
assertXpathEvaluatesTo(message2, "//ui:table/ui:actions/ui:action[2]/ui:condition/@message", component);
}
use of com.github.bordertech.wcomponents.WButton in project wcomponents by BorderTech.
the class WPanelRenderer_Test method testRenderedFormatWithButton.
@Test
public void testRenderedFormatWithButton() throws IOException, SAXException, XpathException {
WPanel panel = new WPanel();
WButton button = new WButton("submit");
panel.add(button);
panel.setDefaultSubmitButton(button);
assertSchemaMatch(panel);
assertXpathEvaluatesTo(button.getId(), "//ui:panel/@buttonId", panel);
}
Aggregations