/** * Creates a WDropdownSubmitOnChangeExample. */ public WDropdownSubmitOnChangeExample() { actMessage.setEncodeText(false); add(new ExplanatoryText("Any form control component which is not a WButton will show a visible warning in its label if its " + "submitOnChange property is set true.")); WFieldLayout flay = new WFieldLayout(); add(flay); flay.setLabelWidth(25); flay.setMargin(new Margin(null, null, Size.LARGE, null)); flay.addField("State", stateSelector).getLabel().setHint("Selecting a state will update the available regions."); flay.addField("Region", regionSelector); // Used to test control of visibility as part of submit on change. add(actMessage); actMessage.setVisible(false); stateSelector.setOptions(new String[]{null, STATE_ACT, STATE_NSW, STATE_VIC}); //This is the flag which causes accessibility problems. It may be removed completely in future versions of WComponents. //you should use AJAX instead stateSelector.setSubmitOnChange(true); stateSelector.setActionOnChange(new Action() { @Override public void execute(final ActionEvent event) { updateRegion(); regionSelector.resetData(); } }); regionSelector.setSubmitOnChange(true); }
dropdown.setSubmitOnChange(cbSubmitOnChange.isSelected());
@Test public void testDoPaint() throws IOException, SAXException, XpathException { // Shared options. WDropdown drop = new WDropdown(); drop.setLocked(true); assertSchemaMatch(drop); assertXpathEvaluatesTo("0", "count(//ui:dropdown/ui:option)", drop); drop.setOptions(new String[]{"A", "B", "C"}); assertSchemaMatch(drop); assertXpathEvaluatesTo("3", "count(//ui:dropdown/ui:option)", drop); drop.setSubmitOnChange(true); assertSchemaMatch(drop); // User specific options. drop.setLocked(true); setActiveContext(createUIContext()); resetContext(); drop = new WDropdown(new String[]{"A", "B"}); assertXpathEvaluatesTo("2", "count(//ui:dropdown/ui:option)", drop); assertXpathEvaluatesTo(drop.getId(), "//ui:dropdown/@id", drop); assertXpathExists("//ui:dropdown[ui:option='A']", drop); assertXpathExists("//ui:dropdown[ui:option='B']", drop); Assert.assertTrue("Dropdown should be in default state", drop.isDefaultState()); setActiveContext(createUIContext()); drop.setOptions(new String[]{"X"}); assertXpathEvaluatesTo("1", "count(//ui:dropdown/ui:option)", drop); assertXpathExists("//ui:dropdown[ui:option='X']", drop); }
assertXpathEvaluatesTo("true", "//ui:dropdown/@required", drop); drop.setSubmitOnChange(true); assertSchemaMatch(drop); assertXpathEvaluatesTo("true", "//ui:dropdown/@submitOnChange", drop);