Geertjan is a DZone Zone Leader and has posted 468 posts at DZone. You can read more from them at their website. View Full User Profile

Getting Even Further with Spring RCP (1)

07.07.2008
| 32493 views |
  • submit to reddit
In Getting Further with Spring RCP, we rebuilt part of the "Simple" sample from the Spring RCP distribution from scratch. We looked at a number of Spring RCP classes—"AbstractObjectTable", "AbstractView", "CommandGroup", "AbstractForm", "TableFormBuilder", "TitledPageApplicationDialog", and "DefaultRulesSource".

In this part, we'll go a few steps further. We'll get acquainted with the "CompositeForm" class, which we'll use to create two different layouts for changing our data, as shown in the two screenshots below, first a tabbed view and then a tree-based hierarchical view:

The cool thing about the above two dialogs is that the difference between them is only one line of code.

After that, we'll change the table display of our data to a tree hierarchy:

Finally, we'll look at some other ways of presenting our data, such as these:

Again, the difference between the two data views above is one line of code!

Table of Contents

 

Note: The completed example, from the end of the second section of this part, is available as a NetBeans project, as part of the Spring RCP Tooling plugin in the NetBeans Plugin Portal, from version 1.4 of the plugin onwards. Open the New Project wizard (Ctrl-Shift-N) and you should find "Spring RCP Tutorial Part 2" in the "Samples | Spring Rich Client" category. The sample "Spring RCP Tutorial Part 3" provides the code for the second part of this article, which discusses some alternative explorer views that you could use to display your data to the user.

 

AttachmentSize
figure-1.png23.7 KB
figure-2.png27.1 KB
figure-3.png17.91 KB
figure-4.png20.39 KB
figure-5.png12.4 KB
figure-6.png36.5 KB
figure-7.png24.6 KB
figure-8.png43.48 KB
Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Andreas Mueller replied on Fri, 2009/10/09 - 5:35am

I'm starting to learn Spring RCP and I really want to thank you for your great tutorials.

But I'm having problems to compile the code after introducing the HierarchicalFormModel.

The lines

customerForm = new CustomerForm(FormModelHelper.createChildPageFormModel(ownerFormModel, null));
addressForm = new AddressForm(FormModelHelper.createChildPageFormModel(ownerFormModel, null));

have errors and I have no idea how to change the constructors of CustomerForm and AddressForm to make it compile.

Did I miss the source code for this?

Thanks!

Andreas Mueller replied on Fri, 2009/10/09 - 5:47am

Sorry,
I did not expect it to be so easy.
I changed the constructor of AddressForm to

AddressForm(ValidatingFormModel model) {
    super(model.getParent().getFormObject());
    setId("address");
 }

 and of CustomerForm to

CustomerForm(ValidatingFormModel model) {
    super(model.getParent().getFormObject());
    setId("customer");
  }

and that was it!

Great!

Andreas Mueller replied on Fri, 2009/10/09 - 6:07am

Obviously it is not as easy as I thought.

After making the abovementioned changes in the constructors the code compiles and the app runs, but changes in data are not saved to the model.

Any help available?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.