use of com.github.bordertech.wcomponents.WPartialDateField 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);
}
use of com.github.bordertech.wcomponents.WPartialDateField in project wcomponents by BorderTech.
the class WPartialDateFieldRenderer_Test method testDoPaintOptionals.
@Test
public void testDoPaintOptionals() throws IOException, SAXException, XpathException {
WPartialDateField dateField = new WPartialDateField();
// Optional attributes
dateField.setDisabled(true);
setFlag(dateField, ComponentModel.HIDE_FLAG, true);
dateField.setMandatory(true);
dateField.setToolTip(TEST_TITLE);
dateField.setAccessibleText(TEST_ALT_TEXT);
dateField.setDefaultSubmitButton(new WButton(TEST_BUTTON_ID));
assertSchemaMatch(dateField);
// Defaults
assertXpathExists("//ui:datefield", dateField);
assertXpathEvaluatesTo(dateField.getId(), "//ui:datefield/@id", dateField);
assertXpathEvaluatesTo("true", "//ui:datefield/@allowPartial", dateField);
// Optionals
assertXpathEvaluatesTo("true", "//ui:datefield/@disabled", dateField);
assertXpathEvaluatesTo("true", "//ui:datefield/@hidden", dateField);
assertXpathEvaluatesTo("true", "//ui:datefield/@required", dateField);
assertXpathEvaluatesTo(TEST_TITLE, "//ui:datefield/@toolTip", dateField);
assertXpathEvaluatesTo(TEST_ALT_TEXT, "//ui:datefield/@accessibleText", dateField);
assertXpathEvaluatesTo(String.valueOf(dateField.getDefaultSubmitButton().getId()), "//ui:datefield/@buttonId", dateField);
// Actual date value not set
assertXpathEvaluatesTo("", "//ui:datefield", dateField);
}
use of com.github.bordertech.wcomponents.WPartialDateField in project wcomponents by BorderTech.
the class WPartialDateFieldRenderer_Test method testDoPaintDefaults.
@Test
public void testDoPaintDefaults() throws IOException, SAXException, XpathException {
WPartialDateField dateField = new WPartialDateField();
assertSchemaMatch(dateField);
// defaults
assertXpathExists("//ui:datefield", dateField);
assertXpathEvaluatesTo(dateField.getId(), "//ui:datefield/@id", dateField);
assertXpathEvaluatesTo("true", "//ui:datefield/@allowPartial", dateField);
// actual date value not set
assertXpathEvaluatesTo("", "//ui:datefield", dateField);
}
use of com.github.bordertech.wcomponents.WPartialDateField in project wcomponents by BorderTech.
the class WPartialDateFieldRenderer_Test method testDoPaintActualDate.
@Test
public void testDoPaintActualDate() throws IOException, SAXException, XpathException {
WPartialDateField dateField = new WPartialDateField();
// Set actual date value
dateField.setPartialDate(1, 2, 2000);
assertSchemaMatch(dateField);
// Defaults
assertXpathExists("//ui:datefield", dateField);
assertXpathEvaluatesTo(dateField.getId(), "//ui:datefield/@id", dateField);
assertXpathEvaluatesTo("true", "//ui:datefield/@allowPartial", dateField);
// Actual date value
assertXpathEvaluatesTo("2000-02-01", "//ui:datefield/@date", dateField);
}
use of com.github.bordertech.wcomponents.WPartialDateField in project wcomponents by BorderTech.
the class WPartialDateFieldRenderer_Test method testDoPaintPartialDate.
@Test
public void testDoPaintPartialDate() throws IOException, SAXException, XpathException {
WPartialDateField dateField = new WPartialDateField();
// Set actual date value
dateField.setPartialDate(null, 1, 2000);
assertSchemaMatch(dateField);
// Defaults
assertXpathExists("//ui:datefield", dateField);
assertXpathEvaluatesTo(dateField.getId(), "//ui:datefield/@id", dateField);
assertXpathEvaluatesTo("true", "//ui:datefield/@allowPartial", dateField);
// Actual date value
assertXpathEvaluatesTo("2000-01-??", "//ui:datefield/@date", dateField);
}
Aggregations