@Test public void testHide() { SubordinateBuilder builder = new SubordinateBuilder(); WCheckBox input = new WCheckBox(); builder.condition().equals(input, "false"); builder.whenTrue().hide(input); setActiveContext(createUIContext()); Assert.assertFalse("Component should be initially visible", input.isHidden()); builder.build().applyTheControls(); Assert.assertTrue("Component should be hidden", input.isHidden()); }
@Test public void testHideIn() { SubordinateBuilder builder = new SubordinateBuilder(); WCheckBox input1 = new WCheckBox(); WCheckBox input2 = new WCheckBox(); WCheckBox input3 = new WCheckBox(); WComponentGroup<SubordinateTarget> group = new WComponentGroup<>(); group.addToGroup(input1); group.addToGroup(input2); group.addToGroup(input3); // True Condition builder.condition().equals(new WCheckBox(), "false"); // HideIn Action builder.whenTrue().hideIn(input2, group); setActiveContext(createUIContext()); // Set initial states (opposite to end state) setFlag(input1, ComponentModel.HIDE_FLAG, true); setFlag(input2, ComponentModel.HIDE_FLAG, false); setFlag(input3, ComponentModel.HIDE_FLAG, true); Assert.assertTrue("hideIn - Input1 Component should be hidden", input1.isHidden()); Assert.assertFalse("hideIn - Input2 Component should not be hidden", input2.isHidden()); Assert.assertTrue("hideIn - Input3 Component should be hidden", input3.isHidden()); builder.build().applyTheControls(); Assert.assertFalse("hideIn - Input1 Component should not be hidden", input1.isHidden()); Assert.assertTrue("hideIn - Input2 Component should be hidden", input2.isHidden()); Assert.assertFalse("hideIn - Input3 Component should not be hidden", input3.isHidden()); }
@Test public void testShowIn() { SubordinateBuilder builder = new SubordinateBuilder(); WCheckBox input1 = new WCheckBox(); WCheckBox input2 = new WCheckBox(); WCheckBox input3 = new WCheckBox(); WComponentGroup<SubordinateTarget> group = new WComponentGroup<>(); group.addToGroup(input1); group.addToGroup(input2); group.addToGroup(input3); // True Condition builder.condition().equals(new WCheckBox(), "false"); // ShowIn Action builder.whenTrue().showIn(input2, group); setActiveContext(createUIContext()); // Set initial states (opposite to end state) setFlag(input1, ComponentModel.HIDE_FLAG, false); setFlag(input2, ComponentModel.HIDE_FLAG, true); setFlag(input3, ComponentModel.HIDE_FLAG, false); Assert.assertFalse("showIn - Input1 Component should not be hidden", input1.isHidden()); Assert.assertTrue("showIn - Input2 Component should be initially hidden", input2.isHidden()); Assert.assertFalse("showIn - Input3 Component should not be hidden", input3.isHidden()); builder.build().applyTheControls(); Assert.assertTrue("showIn - Input1 Component should be hidden", input1.isHidden()); Assert.assertFalse("showIn - Input2 Component should not be hidden", input2.isHidden()); Assert.assertTrue("showIn - Input3 Component should be hidden", input3.isHidden()); }
@Test public void testShow() { SubordinateBuilder builder = new SubordinateBuilder(); WCheckBox input = new WCheckBox(); builder.condition().equals(input, "false"); builder.whenTrue().show(input); setActiveContext(createUIContext()); setFlag(input, ComponentModel.HIDE_FLAG, true); Assert.assertTrue("Component should be initially hidden", input.isHidden()); builder.build().applyTheControls(); Assert.assertFalse("Component should be visible", input.isHidden()); }
@Test public void testOptional() { SubordinateBuilder builder = new SubordinateBuilder(); WCheckBox input = new WCheckBox(); builder.condition().equals(input, "false"); builder.whenTrue().setOptional(input); setActiveContext(createUIContext()); input.setMandatory(true); Assert.assertTrue("Component should be initially mandatory", input.isMandatory()); builder.build().applyTheControls(); Assert.assertFalse("Component should be mandatory", input.isHidden()); }
xml.appendOptionalAttribute("class", component.getHtmlClass()); xml.appendOptionalAttribute("track", component.isTracking(), "true"); xml.appendOptionalAttribute("hidden", checkBox.isHidden(), "true"); xml.appendOptionalAttribute("selected", checkBox.isSelected(), "true"); if (readOnly) {