Search in sources :

Example 1 with WText

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

the class DevToolkit_Test method setUp.

@Before
public void setUp() {
    UIContext uic = new UIContextImpl();
    uic.setUI(new WText("dummy"));
    UIContextHolder.pushContext(uic);
    Config.getInstance().setProperty(ConfigurationProperties.DEVELOPER_TOOKIT, "true");
}
Also used : UIContext(com.github.bordertech.wcomponents.UIContext) WText(com.github.bordertech.wcomponents.WText) UIContextImpl(com.github.bordertech.wcomponents.UIContextImpl) Before(org.junit.Before)

Example 2 with WText

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

the class WCheckBoxSelectExample method addReadOnlyExamples.

/**
 * Examples of readonly states.
 */
private void addReadOnlyExamples() {
    add(new WHeading(HeadingLevel.H3, "Read-only WCheckBoxSelect examples"));
    add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above." + " When the readOnly state is specified only those options which are selected are output."));
    // NOTE: when there are 0 or 1 selections the frame is not rendered.
    add(new WHeading(HeadingLevel.H4, "Read only with no selection"));
    WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with no selection");
    add(new WText("end of unselected read only example"));
    add(new WHeading(HeadingLevel.H4, "Read only with one selection"));
    select = new SelectWithSingleSelected("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with one selection");
    add(new WHeading(HeadingLevel.H4, "Read only with many selections and no frame"));
    select = new SelectWithSingleSelected("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with many selections");
    select.setFrameless(true);
    add(new WHeading(HeadingLevel.H4, "Read only with many selections and COLUMN layout"));
    select = new SelectWithSingleSelected("australian_state");
    add(select);
    select.setReadOnly(true);
    select.setToolTip("Read only with many selections");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    // read only in a WFieldLayout
    add(new WHeading(HeadingLevel.H4, "Read only in a WFieldLayout"));
    add(new ExplanatoryText("Each read only example is preceded by an editable example with the same options and selection. This is to ensure the" + " CSS works properly."));
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(25);
    add(layout);
    // no selections
    select = new WCheckBoxSelect("australian_state");
    select.setFrameless(true);
    layout.addField("No selections were made", select);
    select = new WCheckBoxSelect("australian_state");
    select.setFrameless(true);
    select.setReadOnly(true);
    layout.addField("No selections were made (read only)", select);
    // one selection
    select = new SelectWithSingleSelected("australian_state");
    select.setFrameless(true);
    layout.addField("One selection was made", select);
    select = new SelectWithSingleSelected("australian_state");
    select.setFrameless(true);
    select.setReadOnly(true);
    layout.addField("One selection was made (read only)", select);
    // many selections
    select = new SelectWithManySelected("australian_state");
    layout.addField("Many selections with frame", select);
    select = new SelectWithManySelected("australian_state");
    select.setReadOnly(true);
    layout.addField("Many selections with frame (read only)", select);
    // columns with selections
    select = new SelectWithSingleSelected("australian_state");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    select.setFrameless(true);
    layout.addField("many selections, frameless, COLUMN layout (3 columns)", select);
    select = new SelectWithManySelected("australian_state");
    select.setReadOnly(true);
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
    select.setButtonColumns(3);
    select.setFrameless(true);
    layout.addField("many selections, frameless, COLUMN layout (3 columns) (read only)", select);
    // flat with selections
    select = new SelectWithManySelected("australian_state");
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
    select.setFrameless(true);
    layout.addField("Many selections, frameless, FLAT layout", select);
    select = new SelectWithManySelected("australian_state");
    select.setReadOnly(true);
    select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
    select.setFrameless(true);
    layout.addField("Many selections, frameless, FLAT layout (read only)", select);
}
Also used : WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) ExplanatoryText(com.github.bordertech.wcomponents.examples.common.ExplanatoryText) WHeading(com.github.bordertech.wcomponents.WHeading) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect)

Example 3 with WText

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

the class SubordinateControlOptionsExample method setupTrigger.

/**
 * Setup the trigger for the subordinate control.
 */
private void setupTrigger() {
    String label = drpTriggerType.getSelected() + " Trigger";
    WFieldLayout layout = new WFieldLayout();
    layout.setLabelWidth(LABEL_WIDTH);
    buildControlPanel.add(layout);
    switch((TriggerType) drpTriggerType.getSelected()) {
        case RADIOBUTTONGROUP:
            trigger = new RadioButtonGroup();
            WFieldSet rbSet = new WFieldSet("Select an option");
            RadioButtonGroup group = (RadioButtonGroup) trigger;
            WRadioButton rb1 = group.addRadioButton("A");
            WRadioButton rb2 = group.addRadioButton("B");
            WRadioButton rb3 = group.addRadioButton("C");
            rbSet.add(group);
            rbSet.add(rb1);
            rbSet.add(new WLabel("A", rb1));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb2);
            rbSet.add(new WLabel("B", rb2));
            rbSet.add(new WText("\u00a0"));
            rbSet.add(rb3);
            rbSet.add(new WLabel("C", rb3));
            layout.addField(label, rbSet);
            return;
        case CHECKBOX:
            trigger = new WCheckBox();
            break;
        case CHECKBOXSELECT:
            trigger = new WCheckBoxSelect(LOOKUP_TABLE_NAME);
            break;
        case DATEFIELD:
            trigger = new WDateField();
            break;
        case DROPDOWN:
            trigger = new WDropdown(new TableWithNullOption(LOOKUP_TABLE_NAME));
            break;
        case EMAILFIELD:
            trigger = new WEmailField();
            break;
        case MULTISELECT:
            trigger = new WMultiSelect(LOOKUP_TABLE_NAME);
            break;
        case MULTISELECTPAIR:
            trigger = new WMultiSelectPair(LOOKUP_TABLE_NAME);
            break;
        case NUMBERFIELD:
            trigger = new WNumberField();
            break;
        case PARTIALDATEFIELD:
            trigger = new WPartialDateField();
            break;
        case PASSWORDFIELD:
            trigger = new WPasswordField();
            break;
        case PHONENUMBERFIELD:
            trigger = new WPhoneNumberField();
            break;
        case RADIOBUTTONSELECT:
            trigger = new WRadioButtonSelect(LOOKUP_TABLE_NAME);
            break;
        case SINGLESELECT:
            trigger = new WSingleSelect(LOOKUP_TABLE_NAME);
            break;
        case TEXTAREA:
            trigger = new WTextArea();
            ((WTextArea) trigger).setMaxLength(1000);
            break;
        case TEXTFIELD:
            trigger = new WTextField();
            break;
        default:
            throw new SystemException("Trigger type not valid");
    }
    layout.addField(label, trigger);
}
Also used : WFieldSet(com.github.bordertech.wcomponents.WFieldSet) WNumberField(com.github.bordertech.wcomponents.WNumberField) WEmailField(com.github.bordertech.wcomponents.WEmailField) WPasswordField(com.github.bordertech.wcomponents.WPasswordField) WMultiSelect(com.github.bordertech.wcomponents.WMultiSelect) WLabel(com.github.bordertech.wcomponents.WLabel) WTextArea(com.github.bordertech.wcomponents.WTextArea) WRadioButton(com.github.bordertech.wcomponents.WRadioButton) WDropdown(com.github.bordertech.wcomponents.WDropdown) SystemException(com.github.bordertech.wcomponents.util.SystemException) WText(com.github.bordertech.wcomponents.WText) WFieldLayout(com.github.bordertech.wcomponents.WFieldLayout) TableWithNullOption(com.github.bordertech.wcomponents.examples.common.ExampleLookupTable.TableWithNullOption) WRadioButtonSelect(com.github.bordertech.wcomponents.WRadioButtonSelect) WTextField(com.github.bordertech.wcomponents.WTextField) WCheckBoxSelect(com.github.bordertech.wcomponents.WCheckBoxSelect) WMultiSelectPair(com.github.bordertech.wcomponents.WMultiSelectPair) WPhoneNumberField(com.github.bordertech.wcomponents.WPhoneNumberField) WSingleSelect(com.github.bordertech.wcomponents.WSingleSelect) RadioButtonGroup(com.github.bordertech.wcomponents.RadioButtonGroup) WCheckBox(com.github.bordertech.wcomponents.WCheckBox) WPartialDateField(com.github.bordertech.wcomponents.WPartialDateField) WDateField(com.github.bordertech.wcomponents.WDateField)

Example 4 with WText

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

the class WServlet_Test method testSubSessionsEnabled.

@Test
public void testSubSessionsEnabled() throws ServletException, IOException {
    Config.getInstance().setProperty(ConfigurationProperties.SERVLET_ENABLE_SUBSESSIONS, "true");
    MyWServlet servlet = new MyWServlet(new WText("test"));
    servlet.init(new MockServletConfig());
    MockHttpSession session = new MockHttpSession();
    // Initial request will be missing a SSID, will create a new subsession (id = 0)
    MockHttpServletRequest request = new MockHttpServletRequest(session);
    servlet.service(request, new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 1, servlet.lastInvocationCount);
    // Passing in an invalid SSID should return same subsession (id = 0)
    request = new MockHttpServletRequest(session);
    request.setParameter("ssid", "asdf");
    servlet.service(request, new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 2, servlet.lastInvocationCount);
    // Missing SSID should create a new subession (id = 1)
    request = new MockHttpServletRequest(session);
    servlet.service(request, new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 1, servlet.lastInvocationCount);
    // Should update the primary session (id = 0)
    request = new MockHttpServletRequest(session);
    request.setParameter("ssid", "0");
    servlet.service(request, new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 3, servlet.lastInvocationCount);
    // Should update the secondary session (id = 1)
    request = new MockHttpServletRequest(session);
    request.setParameter("ssid", "1");
    servlet.service(request, new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 2, servlet.lastInvocationCount);
}
Also used : WText(com.github.bordertech.wcomponents.WText) MockHttpServletRequest(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest) MockServletConfig(com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig) MockHttpSession(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession) MockHttpServletResponse(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletResponse) Test(org.junit.Test)

Example 5 with WText

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

the class WServlet_Test method testSubSessionsDisabledNoSSID.

@Test
public void testSubSessionsDisabledNoSSID() throws ServletException, IOException {
    Config.getInstance().setProperty(ConfigurationProperties.SERVLET_ENABLE_SUBSESSIONS, "false");
    MyWServlet servlet = new MyWServlet(new WText("test"));
    servlet.init(new MockServletConfig());
    MockHttpSession session = new MockHttpSession();
    servlet.service(new MockHttpServletRequest(session), new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 1, servlet.lastInvocationCount);
    servlet.service(new MockHttpServletRequest(session), new MockHttpServletResponse());
    Assert.assertEquals("Incorrect invocation count", 2, servlet.lastInvocationCount);
}
Also used : WText(com.github.bordertech.wcomponents.WText) MockHttpServletRequest(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletRequest) MockServletConfig(com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig) MockHttpSession(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpSession) MockHttpServletResponse(com.github.bordertech.wcomponents.util.mock.servlet.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

WText (com.github.bordertech.wcomponents.WText)100 Test (org.junit.Test)63 WPanel (com.github.bordertech.wcomponents.WPanel)18 WCollapsible (com.github.bordertech.wcomponents.WCollapsible)10 WDecoratedLabel (com.github.bordertech.wcomponents.WDecoratedLabel)10 WHeading (com.github.bordertech.wcomponents.WHeading)10 UIContext (com.github.bordertech.wcomponents.UIContext)9 WTabSet (com.github.bordertech.wcomponents.WTabSet)7 DefaultWComponent (com.github.bordertech.wcomponents.DefaultWComponent)6 WList (com.github.bordertech.wcomponents.WList)6 WebXmlRenderContext (com.github.bordertech.wcomponents.servlet.WebXmlRenderContext)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)6 MockServletConfig (com.github.bordertech.wcomponents.util.mock.servlet.MockServletConfig)6 ActionEvent (com.github.bordertech.wcomponents.ActionEvent)5 WFieldLayout (com.github.bordertech.wcomponents.WFieldLayout)5 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)5 WImage (com.github.bordertech.wcomponents.WImage)5 WTableColumn (com.github.bordertech.wcomponents.WTableColumn)5 WTextField (com.github.bordertech.wcomponents.WTextField)5 ExplanatoryText (com.github.bordertech.wcomponents.examples.common.ExplanatoryText)5