CookFormLayout Tutorial: DefaultFormBuilder, Part 2


 

 

Support This Project

 

stats counter

 

Logo SourceForge.net Logo IntelliJ IDEA

Tutorial Example

tutorial_formbuilder2.xml in the CookFormLayout Java Web Start demo.

Introduction

This is the part 2 of the <formbuilder> tag tutorial. In this tutorial, we will see some more things that can be simplified.

1. Forget the RowSpec

One problem in all the previous tutorials is that one needs to determine the row spec before hand. When there are many rows, it becomes somewhat tedious to have "pref, 2dlu, " in the rowspec repeated over and over again. DefaultFormBuilder can automatically append "pref" part for us, we just need to specify the line gap between two rows.

<form-properties> retrieves the internal AbstractFormBuilder being used so that its properties, in this case, linegapsize, can be set.

<panel>
	<formbuilder>
		<formlayout
			columnspec="pref, 4dlu, 50dlu, 4dlu, min"
			rowspec=""
		>
		</formlayout>
		<form-properties linegapsize="DLUY2"/>
	</formbuilder>
</panel>

It seems to me that DefaultFormBuilder behaves differently for advancing to next line if rowspec is not manually set. <form-nextline> becomes less necessary, in fact it can be used only to indicate the current row of components are finished.

2. Row Grouping

DefaultFormBuilder keeps track a single active row group, which is actually sufficient for all layout purposes.

		<form-properties rowgroupingenabled="true"/>

3. Other Features

As mentioned in the first tutorial, <formlayout does not support changing row/column spec in the middle of adding components. With <formbuilder, however, you can with the <form-append> tag. You can see how it works in customareas.xml of the CookFormLayout Java Web Start demo.

(c) Copyright 2004-2007 Heng Yuan. All rights reserved.

Valid XHTML 1.0! Valid CSS!