Search in sources :

Example 61 with WButton

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

the class WPanelRenderer_Test method testRenderAllPanelTypes.

@Test
public void testRenderAllPanelTypes() throws IOException, SAXException, XpathException {
    // Tests that all panel types are schema valid
    for (WPanel.Type type : WPanel.Type.values()) {
        WPanel panel = new WPanel(type);
        WButton button = new WButton("submit");
        panel.add(button);
        panel.setDefaultSubmitButton(button);
        panel.setTitleText("Panel title");
        assertSchemaMatch(panel);
    }
}
Also used : WPanel(com.github.bordertech.wcomponents.WPanel) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 62 with WButton

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

the class WTableRenderer_Test method testDoPaintTableActionsInvisibleButton.

@Test
public void testDoPaintTableActionsInvisibleButton() throws IOException, SAXException, XpathException {
    WTable component = new WTable();
    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));
    TableModel tableModel = createTableModel();
    component.setTableModel(tableModel);
    component.setVisible(true);
    WButton button1 = new WButton(TEST_ACTION_ONE);
    component.addAction(button1);
    // Visible
    assertXpathExists("//ui:table/ui:actions", component);
    // Not Visible
    button1.setVisible(false);
    assertXpathNotExists("//ui:table/ui:actions", component);
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) TableModel(com.github.bordertech.wcomponents.WTable.TableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) Test(org.junit.Test)

Example 63 with WButton

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

the class WTableRenderer_Test method testDoPaintTableActions.

@Test
public void testDoPaintTableActions() throws IOException, SAXException, XpathException {
    WTable component = new WTable();
    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));
    TableModel tableModel = createTableModel();
    component.setTableModel(tableModel);
    component.setVisible(true);
    component.addAction(new WButton(TEST_ACTION_ONE));
    component.addAction(new WButton(TEST_ACTION_TWO));
    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);
}
Also used : WTable(com.github.bordertech.wcomponents.WTable) WTableColumn(com.github.bordertech.wcomponents.WTableColumn) WTextField(com.github.bordertech.wcomponents.WTextField) WButton(com.github.bordertech.wcomponents.WButton) TableModel(com.github.bordertech.wcomponents.WTable.TableModel) AdapterBasicTableModel(com.github.bordertech.wcomponents.AdapterBasicTableModel) SimpleTableModel(com.github.bordertech.wcomponents.SimpleTableModel) Test(org.junit.Test)

Example 64 with WButton

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

the class WTextAreaRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WTextArea field = new WTextArea();
    WButton button = new WButton();
    WContainer root = new WContainer();
    root.add(field);
    root.add(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getId(), "//ui:textarea/@id", field);
    assertXpathNotExists("//ui:textarea/@disabled", field);
    assertXpathNotExists("//ui:textarea/@hidden", field);
    assertXpathNotExists("//ui:textarea/@required", field);
    assertXpathNotExists("//ui:textarea/@readOnly", field);
    assertXpathNotExists("//ui:textarea/@minLength", field);
    assertXpathNotExists("//ui:textarea/@maxLength", field);
    assertXpathNotExists("//ui:textarea/@toolTip", field);
    assertXpathNotExists("//ui:textarea/@accessibleText", field);
    assertXpathNotExists("//ui:textarea/@rows", field);
    assertXpathNotExists("//ui:textarea/@cols", field);
    assertXpathNotExists("//ui:textarea/ui:rtf", field);
    field.setDisabled(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@disabled", field);
    setFlag(field, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@hidden", field);
    field.setMandatory(true);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("true", "//ui:textarea/@required", field);
    field.setMinLength(45);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("45", "//ui:textarea/@minLength", field);
    field.setMaxLength(50);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("50", "//ui:textarea/@maxLength", field);
    field.setToolTip("tooltip");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getToolTip(), "//ui:textarea/@toolTip", field);
    field.setAccessibleText("accessible");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getAccessibleText(), "//ui:textarea/@accessibleText", field);
    field.setRows(20);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("20", "//ui:textarea/@rows", field);
    field.setColumns(40);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("40", "//ui:textarea/@cols", field);
    field.setRichTextArea(false);
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:textarea/ui:rtf", field);
    field.setRichTextArea(true);
    assertSchemaMatch(field);
    assertXpathExists("//ui:textarea/ui:rtf", field);
    field.setDefaultSubmitButton(button);
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(button.getId(), "//ui:textarea/@buttonId", field);
    field.setPattern("");
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:textarea/@pattern", field);
    // Pattern is not supported on the client for TextArea, and will not be rendered
    field.setPattern("test[123]");
    assertSchemaMatch(field);
    assertXpathNotExists("//ui:textarea/@pattern", field);
    field.setText("Hello");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo(field.getText(), "normalize-space(//ui:textarea)", field);
    field.setPlaceholder("enter stuff here");
    assertSchemaMatch(field);
    assertXpathEvaluatesTo("enter stuff here", "//ui:textarea/@placeholder", field);
}
Also used : WTextArea(com.github.bordertech.wcomponents.WTextArea) WContainer(com.github.bordertech.wcomponents.WContainer) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Example 65 with WButton

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

the class WToggleButtonRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    WToggleButton toggle = new WToggleButton();
    WComponentGroup<WToggleButton> group = new WComponentGroup<>();
    WButton button = new WButton("test");
    WContainer root = new WContainer();
    root.add(toggle);
    root.add(group);
    root.add(button);
    setActiveContext(createUIContext());
    assertSchemaMatch(toggle);
    assertXpathExists("//ui:togglebutton", toggle);
    assertXpathEvaluatesTo(toggle.getId(), "//ui:togglebutton/@id", toggle);
    // Check disabled
    assertXpathNotExists("//ui:togglebutton/@disabled", toggle);
    toggle.setDisabled(true);
    assertSchemaMatch(toggle);
    assertXpathEvaluatesTo("true", "//ui:togglebutton/@disabled", toggle);
    // Check hidden
    assertXpathNotExists("//ui:togglebutton/@hidden", toggle);
    setFlag(toggle, ComponentModel.HIDE_FLAG, true);
    assertSchemaMatch(toggle);
    assertXpathEvaluatesTo("true", "//ui:togglebutton/@hidden", toggle);
    // Check selected
    assertXpathNotExists("//ui:togglebutton/@selected", toggle);
    toggle.setSelected(true);
    assertSchemaMatch(toggle);
    assertXpathEvaluatesTo("true", "//ui:togglebutton/@selected", toggle);
    // Check toolTip
    assertXpathNotExists("//ui:togglebutton/@toolTip", toggle);
    toggle.setToolTip("WCheckBox_Test.testRenderedFormat.title");
    assertSchemaMatch(toggle);
    assertXpathEvaluatesTo(toggle.getToolTip(), "//ui:togglebutton/@toolTip", toggle);
    // Check accessibleText
    assertXpathNotExists("//ui:togglebutton/@accessibleText", toggle);
    toggle.setAccessibleText("WCheckBox_Test.testRenderedFormat.accessibleText");
    assertSchemaMatch(toggle);
    assertXpathEvaluatesTo(toggle.getAccessibleText(), "//ui:togglebutton/@accessibleText", toggle);
}
Also used : WContainer(com.github.bordertech.wcomponents.WContainer) WToggleButton(com.github.bordertech.wcomponents.WToggleButton) WComponentGroup(com.github.bordertech.wcomponents.WComponentGroup) WButton(com.github.bordertech.wcomponents.WButton) Test(org.junit.Test)

Aggregations

WButton (com.github.bordertech.wcomponents.WButton)76 Test (org.junit.Test)39 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)25 Action (com.github.bordertech.wcomponents.Action)20 WAjaxControl (com.github.bordertech.wcomponents.WAjaxControl)18 WTextField (com.github.bordertech.wcomponents.WTextField)17 WHeading (com.github.bordertech.wcomponents.WHeading)16 WContainer (com.github.bordertech.wcomponents.WContainer)14 WPanel (com.github.bordertech.wcomponents.WPanel)13 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)11 ValidatingAction (com.github.bordertech.wcomponents.validation.ValidatingAction)10 WLabel (com.github.bordertech.wcomponents.WLabel)9 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)8 UIContext (com.github.bordertech.wcomponents.UIContext)7 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)7 WText (com.github.bordertech.wcomponents.WText)6 WDataTable (com.github.bordertech.wcomponents.WDataTable)5 WFieldSet (com.github.bordertech.wcomponents.WFieldSet)5 WTable (com.github.bordertech.wcomponents.WTable)5 AdapterBasicTableModel (com.github.bordertech.wcomponents.AdapterBasicTableModel)4