Skip to content

Commit ca75b7d

Browse files
Merge pull request #1733 from JohnMcGuinness/remove-usage-of-WBeanContainer
Remove usage of WBeanContainer from framework and examples
2 parents 33dab2f + b063014 commit ca75b7d

24 files changed

+127
-65
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
### API Changes
66

77
### Enhancements
8+
* Removed usage of deprecated APIs from the framework and examples. Including the following:
9+
- Replaced usage of `WBeanContainer` with `WContainer`. #1733
10+
- Replaced usage of `int` heading levels with `HeadingLevel` values. #1734
11+
- Replaced usage of `int` spacing for `FlowLayout` with `Size` based spacing, #1735
12+
- Replaced usage of `int` spacing for `ColumnLayout` with `Size` based spacing. #1736
813

914
### Bug Fixes
1015

wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WDataTableRowRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private Class<? extends WComponent> getRowRendererClass() {
171171
* The renderer wrapper is responsible for ensuring that the renderer is only used when needed (ie. it is only
172172
* involved in processing of certain rows), and ensuring that data is passed to / from the renderer when required.
173173
*/
174-
private static final class RendererWrapper extends WBeanContainer implements BeanProvider {
174+
private static final class RendererWrapper extends WContainer implements BeanProvider {
175175

176176
/**
177177
* The table that this wrapper belongs to.

wcomponents-core/src/main/java/com/github/bordertech/wcomponents/WTableRowRenderer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public RowIdWrapper getCurrentRowIdWrapper() {
153153
* The renderer wrapper is responsible for ensuring that the renderer is only used when needed (ie. it is only
154154
* involved in processing of certain rows), and ensuring that data is passed to / from the renderer when required.
155155
*/
156-
private static final class RendererWrapper extends WBeanContainer implements BeanProvider {
156+
private static final class RendererWrapper extends WContainer implements BeanProvider {
157157

158158
/**
159159
* The table that this wrapper belongs to.

wcomponents-core/src/test/java/com/github/bordertech/wcomponents/AbstractWMultiSelectList_Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,15 +1029,15 @@ public void testDoHandleRequestBeanBound() {
10291029
// Set Bean Property
10301030
multi.setBeanProperty("myOptions");
10311031

1032-
WBeanContainer beanContainer = new WBeanContainer();
1033-
beanContainer.add(multi);
1032+
WContainer container = new WContainer();
1033+
container.add(multi);
10341034

10351035
multi.setLocked(true);
10361036
setActiveContext(createUIContext());
10371037

10381038
// Set a Bean that has no selections
10391039
MyBean bean = new MyBean();
1040-
beanContainer.setBean(bean);
1040+
container.setBean(bean);
10411041

10421042
// Test Nothing Selected and Empty Request (No Change)
10431043
MockRequest request = setupNothingSelectedRequest(multi);

wcomponents-core/src/test/java/com/github/bordertech/wcomponents/AbstractWSingleSelectList_Test.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,15 @@ public void testDoHandleRequestBeanBound() {
776776
// Set Bean Property
777777
single.setBeanProperty("myOption");
778778

779-
WBeanContainer beanContainer = new WBeanContainer();
780-
beanContainer.add(single);
779+
WContainer container = new WContainer();
780+
container.add(single);
781781

782782
single.setLocked(true);
783783
setActiveContext(createUIContext());
784784

785785
// Set a Bean that has no selections
786786
MyBean bean = new MyBean();
787-
beanContainer.setBean(bean);
787+
container.setBean(bean);
788788

789789
// Test Nothing Selected and Empty Request (No Change)
790790
MockRequest request = setupNothingSelectedRequest(single);

wcomponents-core/src/test/java/com/github/bordertech/wcomponents/UIContextImpl_Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public void handleRequest(final Request request) {
416416

417417
// Setup the top level repeater
418418
WRepeater repeater = new WRepeater();
419-
WBeanContainer content = new WBeanContainer() {
419+
WContainer content = new WContainer() {
420420
@Override
421421
public void handleRequest(final Request request) {
422422
super.handleRequest(request);
@@ -513,7 +513,7 @@ public void handleRequest(final Request request) {
513513

514514
// Setup the top level repeater
515515
WRepeater repeater = new WRepeater();
516-
WBeanContainer content = new WBeanContainer();
516+
WContainer content = new WContainer();
517517
content.add(repeater2);
518518
repeater.setRepeatedComponent(content);
519519

wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WComponentsPerformance_Test.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void testWComponentAppCorrectness() throws Exception {
4747

4848
setActiveContext(uic);
4949
Assert.assertEquals("Incorrect property1 value", "p1_1",
50-
((SimpleFormBean) app.beanContainer.getBean()).getProperty1());
50+
((SimpleFormBean) app.container.getBean()).getProperty1());
5151
Assert.assertEquals("Incorrect property2 value", "p2_1",
52-
((SimpleFormBean) app.beanContainer.getBean()).getProperty2());
52+
((SimpleFormBean) app.container.getBean()).getProperty2());
5353
}
5454

5555
/**
@@ -181,13 +181,13 @@ private void sendSimpleRequest(final HttpSession session, final int step) {
181181
*/
182182
public static final class SimpleApp extends WApplication {
183183

184-
private final WBeanContainer beanContainer = new WBeanContainer();
184+
private final WContainer container = new WContainer();
185185

186186
/**
187187
* Creates a SimpleApp.
188188
*/
189189
public SimpleApp() {
190-
add(beanContainer);
190+
add(container);
191191

192192
WTextField property1 = new WTextField();
193193
WTextField property2 = new WTextField();
@@ -198,30 +198,30 @@ public SimpleApp() {
198198
property1.setIdName("txt1");
199199
property2.setIdName("txt2");
200200

201-
beanContainer.add(new WLabel("Property 1:", property1));
202-
beanContainer.add(property1);
203-
beanContainer.add(new WLabel("Property 2:", property2));
204-
beanContainer.add(property2);
201+
container.add(new WLabel("Property 1:", property1));
202+
container.add(property1);
203+
container.add(new WLabel("Property 2:", property2));
204+
container.add(property2);
205205

206206
WButton submit = new WButton("Submit");
207207
submit.setIdName("btn");
208208

209209
submit.setAction(new Action() {
210210
@Override
211211
public void execute(final ActionEvent event) {
212-
WebUtilities.updateBeanValue(beanContainer);
212+
WebUtilities.updateBeanValue(container);
213213
}
214214
});
215215

216-
beanContainer.add(submit);
216+
container.add(submit);
217217
}
218218

219219
@Override
220220
protected void preparePaintComponent(final Request request) {
221221
super.preparePaintComponent(request);
222222

223223
if (!isInitialised()) {
224-
beanContainer.setBean(new SimpleFormBean());
224+
container.setBean(new SimpleFormBean());
225225
setInitialised(true);
226226
}
227227
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.github.bordertech.wcomponents;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
/**
7+
* Unit tests for {@link WContainer}.
8+
*
9+
* @author John McGuinness
10+
* @since 1.5.20
11+
*/
12+
public class WContainer_Test extends AbstractWComponentTestCase {
13+
14+
@Test
15+
public void testChildAccessors() {
16+
WContainer container = new WContainer();
17+
18+
// Check no children
19+
Assert.assertEquals("Should have no child count", 0, container.getChildCount());
20+
21+
// Add child
22+
WComponent child = new DefaultWComponent();
23+
container.add(child);
24+
25+
// Check child
26+
Assert.assertEquals("Incorrect child count", 1, container.getChildCount());
27+
Assert.assertEquals("Incorrect child index", 0, container.getIndexOfChild(child));
28+
Assert.assertEquals("Incorrect child returned", child, container.getChildAt(0));
29+
30+
// Remove child
31+
container.remove(child);
32+
33+
// Check no children
34+
Assert.assertEquals("Should have no child count after removing", 0, container.getChildCount());
35+
36+
// Check getChildren
37+
container.add(child);
38+
Assert.assertEquals("Incorrect child count", 1, container.getChildren().size());
39+
Assert.assertEquals("Incorrect child index", 0, container.getChildren().indexOf(child));
40+
Assert.assertEquals("Incorrect child returned", child, container.getChildren().get(0));
41+
42+
try {
43+
container.getChildren().add(new DefaultWComponent());
44+
Assert.fail("Expected getChildren() to return unmodifiable List.");
45+
} catch (UnsupportedOperationException e) {
46+
Assert.assertEquals("Incorrect child count", 1, container.getChildren().size());
47+
}
48+
}
49+
50+
@Test
51+
public void testNamingContextAccessors() {
52+
assertAccessorsCorrect(new WContainer(), WContainer::isNamingContext, WContainer::setNamingContext, false, true, false);
53+
}
54+
55+
@Test
56+
public void testNamingContextIdAccessor() {
57+
String id = "test";
58+
NamingContextable naming = new WContainer();
59+
naming.setIdName(id);
60+
Assert.assertEquals("Incorrect component id", id, naming.getId());
61+
Assert.assertEquals("Naming context should match component id", id, naming.
62+
getNamingContextId());
63+
}
64+
}

wcomponents-core/src/test/java/com/github/bordertech/wcomponents/WRadioButton_Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void testReadOnlyGroup() {
250250
public void testRadioButtonInRepeater() {
251251
RadioButtonGroup group = new RadioButtonGroup();
252252

253-
WBeanContainer repeated = new WBeanContainer();
253+
WContainer repeated = new WContainer();
254254
repeated.add(group.addRadioButton());
255255

256256
WRepeater repeater = new WRepeater(repeated);

wcomponents-core/src/test/java/com/github/bordertech/wcomponents/servlet/WServletPerformance_Test.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.github.bordertech.wcomponents.Request;
99
import com.github.bordertech.wcomponents.UIContext;
1010
import com.github.bordertech.wcomponents.WApplication;
11-
import com.github.bordertech.wcomponents.WBeanContainer;
11+
import com.github.bordertech.wcomponents.WContainer;
1212
import com.github.bordertech.wcomponents.WButton;
1313
import com.github.bordertech.wcomponents.WComponent;
1414
import com.github.bordertech.wcomponents.WLabel;
@@ -76,9 +76,9 @@ public void testWServletAppCorrectness() throws Exception {
7676
setActiveContext(uic);
7777
Assert.assertEquals("Incorrect step", 2, uic.getEnvironment().getStep());
7878
Assert.assertEquals("Incorrect property1 value", "p1_1",
79-
((SimpleFormBean) app.beanContainer.getBean()).getProperty1());
79+
((SimpleFormBean) app.container.getBean()).getProperty1());
8080
Assert.assertEquals("Incorrect property2 value", "p2_1",
81-
((SimpleFormBean) app.beanContainer.getBean()).getProperty2());
81+
((SimpleFormBean) app.container.getBean()).getProperty2());
8282
}
8383

8484
/**
@@ -275,42 +275,42 @@ public WComponent getUI(final Object httpServletRequest) {
275275
*/
276276
public static final class SimpleApp extends WApplication {
277277

278-
private final WBeanContainer beanContainer = new WBeanContainer();
278+
private final WContainer container = new WContainer();
279279

280280
/**
281281
* Creates a SimpleApp.
282282
*/
283283
public SimpleApp() {
284-
add(beanContainer);
284+
add(container);
285285

286286
WTextField property1 = new WTextField();
287287
property1.setBeanProperty("property1");
288288
WTextField property2 = new WTextField();
289289
property2.setBeanProperty("property2");
290290

291-
beanContainer.add(new WLabel("Property 1:", property1));
292-
beanContainer.add(property1);
293-
beanContainer.add(new WLabel("Property 2:", property2));
294-
beanContainer.add(property2);
291+
container.add(new WLabel("Property 1:", property1));
292+
container.add(property1);
293+
container.add(new WLabel("Property 2:", property2));
294+
container.add(property2);
295295

296296
WButton submit = new WButton("Submit");
297297

298298
submit.setAction(new Action() {
299299
@Override
300300
public void execute(final ActionEvent event) {
301-
WebUtilities.updateBeanValue(beanContainer);
301+
WebUtilities.updateBeanValue(container);
302302
}
303303
});
304304

305-
beanContainer.add(submit);
305+
container.add(submit);
306306
}
307307

308308
@Override
309309
protected void preparePaintComponent(final Request request) {
310310
super.preparePaintComponent(request);
311311

312312
if (!isInitialised()) {
313-
beanContainer.setBean(new SimpleFormBean());
313+
container.setBean(new SimpleFormBean());
314314
setInitialised(true);
315315
}
316316
}

wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/InputBeanBindingExample.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.github.bordertech.wcomponents.SubordinateTarget;
1010
import com.github.bordertech.wcomponents.WAjaxControl;
1111
import com.github.bordertech.wcomponents.WBeanComponent;
12-
import com.github.bordertech.wcomponents.WBeanContainer;
1312
import com.github.bordertech.wcomponents.WButton;
1413
import com.github.bordertech.wcomponents.WCheckBox;
1514
import com.github.bordertech.wcomponents.WCheckBoxSelect;
@@ -66,7 +65,7 @@
6665
* @author Jonathan Austin
6766
* @since 1.0.0
6867
*/
69-
public class InputBeanBindingExample extends WBeanContainer {
68+
public class InputBeanBindingExample extends WContainer {
7069

7170
/**
7271
* Example options.

wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/WRadioButtonInRepeater.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.github.bordertech.wcomponents.Request;
99
import com.github.bordertech.wcomponents.Size;
1010
import com.github.bordertech.wcomponents.WAjaxControl;
11-
import com.github.bordertech.wcomponents.WBeanContainer;
1211
import com.github.bordertech.wcomponents.WButton;
1312
import com.github.bordertech.wcomponents.WContainer;
1413
import com.github.bordertech.wcomponents.WFieldLayout;
@@ -126,7 +125,7 @@ protected void preparePaintComponent(final Request request) {
126125
/**
127126
* A Class that has a radio button that is repeated.
128127
*/
129-
public static class MyComponent extends WBeanContainer {
128+
public static class MyComponent extends WContainer {
130129

131130
/**
132131
* Label for the radio button.

wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableBeanProviderExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.github.bordertech.wcomponents.AbstractBeanTableDataModel;
44
import com.github.bordertech.wcomponents.BeanProvider;
55
import com.github.bordertech.wcomponents.BeanProviderBound;
6-
import com.github.bordertech.wcomponents.WBeanContainer;
6+
import com.github.bordertech.wcomponents.WContainer;
77
import com.github.bordertech.wcomponents.WButton;
88
import com.github.bordertech.wcomponents.WDataTable;
99
import com.github.bordertech.wcomponents.WTableColumn;
@@ -22,7 +22,7 @@
2222
* @author Yiannis Paschalidis
2323
* @since 1.0.0
2424
*/
25-
public class DataTableBeanProviderExample extends WBeanContainer {
25+
public class DataTableBeanProviderExample extends WContainer {
2626

2727
/**
2828
* A fake "application cache", that holds the data which is displayed by the table.

wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/DataTableOptionsExample.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import com.github.bordertech.wcomponents.TableDataModel;
1111
import com.github.bordertech.wcomponents.TableTreeNode;
1212
import com.github.bordertech.wcomponents.TreeTableDataModel;
13-
import com.github.bordertech.wcomponents.WBeanContainer;
1413
import com.github.bordertech.wcomponents.WButton;
1514
import com.github.bordertech.wcomponents.WCheckBox;
1615
import com.github.bordertech.wcomponents.WContainer;
@@ -854,7 +853,7 @@ public void setColumnC(final String columnC) {
854853
*
855854
* @since 1.0.0
856855
*/
857-
public static final class ExtraDetailsPanel extends WBeanContainer {
856+
public static final class ExtraDetailsPanel extends WContainer {
858857

859858
/**
860859
* Construct the component.

wcomponents-examples/src/main/java/com/github/bordertech/wcomponents/examples/datatable/TreeTableExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.github.bordertech.wcomponents.AbstractTreeTableDataModel;
44
import com.github.bordertech.wcomponents.Request;
55
import com.github.bordertech.wcomponents.TableTreeNode;
6-
import com.github.bordertech.wcomponents.WBeanContainer;
6+
import com.github.bordertech.wcomponents.WContainer;
77
import com.github.bordertech.wcomponents.WButton;
88
import com.github.bordertech.wcomponents.WDataTable;
99
import com.github.bordertech.wcomponents.WDataTable.ExpandMode;
@@ -379,7 +379,7 @@ public void setExpiryDate(final Date expiryDate) {
379379
*
380380
* @author Yiannis Paschalidis
381381
*/
382-
public static final class TravelDocPanel extends WBeanContainer {
382+
public static final class TravelDocPanel extends WContainer {
383383

384384
/**
385385
* Creates a TravelDocPanel.

0 commit comments

Comments
 (0)