@Override public void execute(final ActionEvent event) { tf4.setDisabled(!tf4.isDisabled()); } });
/** * Override preparePaintComponent to test that dynamic attributes are handled correctly. * * @param request the request that triggered the paint. */ @Override protected void preparePaintComponent(final Request request) { if (!isInitialised()) { // Default some values. tf3.setDisabled(true); tf1.setText("blah blah"); tf2.setText("abc"); tf3.setText("abc"); setInitialised(true); } }
/** * Test validate - where isDisableable and isDisabled. */ @Test public void testValidateIfIsDisableable() { // instanceOf Disableable and isDisabled implies abort validate() WTextField date = new WTextField(); date.addValidator(new MyValidator()); date.setLocked(true); setActiveContext(createUIContext()); date.setDisabled(true); List<Diagnostic> diags = new ArrayList<>(); date.validate(diags); // this calls validate(uic,diags) in WComponent parent class - the one being tested Assert.assertTrue("diags list should be empty", diags.isEmpty()); resetContext(); date.validate(diags); Assert.assertFalse("Diags list should not be empty", diags.isEmpty()); }
/** * Creates a WDropdownSpecialCharHandlingExample. */ public WDropdownSpecialCharHandlingExample() { drop.setOptions(new String[]{null, ">", "<", "&", "\"", "normal"}); WFieldLayout flay = new WFieldLayout(); flay.setLabelWidth(25); add(flay); flay.addField("Select an option", drop); text = new WTextField(); text.setDisabled(true); flay.addField("Selected option output", text); WButton submit = new WButton("Submit"); flay.addField((WLabel) null, submit); submit.setAction(new Action() { @Override public void execute(final ActionEvent event) { String selected = (String) drop.getSelected(); text.setText(selected); } }); } }
tf4.setDisabled(true); fieldLayout.addField("Disabled", tf4);
textfield.setDisabled(true); layout.addField("Disabled input", textfield); textfield.setDisabled(true); layout.addField("Disabled input with value", textfield);
assertXpathNotExists("//ui:textfield/@autocomplete", textField); textField.setDisabled(true); assertSchemaMatch(textField); assertXpathEvaluatesTo("true", "//ui:textfield/@disabled", textField);