103
form4j Manual http://sourceforge.net/projects/form4j 0.5 2004.06.10 Form4j 0.5 1 06/10/2004 form4j 0.5 Manual

form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

form4jManual

http://sourceforge.net/projects/form4j0.5 2004.06.10

Form4j 0.5 1 06/10/2004

form4j 0.5Manual

Page 2: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

Form4j 0.5 2 06/10/2004

Page 3: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

Table of Contents1 Intro...............................................................................................7

1.1 Purpose...................................................................................7

1.2 Basic Features........................................................................7

1.3 Endorsements.........................................................................8

2 form4j Installation.........................................................................9

2.1 Getting form4j.........................................................................9

2.2 System Requirements.............................................................92.2.1 To integrate form4j within your own Project....................92.2.2 To build form4j.................................................................9

2.3 Installing form4j....................................................................102.3.1 Source Distribution........................................................10

3 Getting Started............................................................................11

3.1 Establish the environment....................................................11

3.2 Create HelloWorld.java.........................................................11

3.3 Create helloData.xml.............................................................11

3.4 Create helloForm.xml...........................................................12

3.5 Verifying ..............................................................................12

3.6 Compiling..............................................................................12

3.7 Running.................................................................................13

4 form4j Concepts..........................................................................15

4.1 DOM Model...........................................................................15

4.2 XPath....................................................................................164.2.1 Relative vs.absolute Addressing.....................................16

4.3 Attribute Inheritance............................................................17

4.4 Layout...................................................................................184.4.1 Discussion......................................................................18

5 Form Definition...........................................................................19

5.1 Anatomy of a Form Definition...............................................19

Form4j 0.5 3 06/10/2004

Page 4: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5.2 Form Layout..........................................................................20

5.3 Conditions.............................................................................205.3.1 Constant Conditions.......................................................225.3.2 Nested Conditions..........................................................22

5.4 Areas.....................................................................................235.4.1 Area Titles......................................................................235.4.2 Area Borders..................................................................24

5.5 Taxonomy of Form Fields......................................................27

5.6 Common Attributes...............................................................27

5.7 Common Data Field Attributes..............................................28

5.8 Value Enumerations..............................................................305.8.1 Attributes.......................................................................31

5.9 Advanced Processing with Data Adapters.............................33

5.10 Colors..................................................................................355.10.1 Color Names.................................................................355.10.2 RGB Colors...................................................................35

5.11 Fonts...................................................................................365.11.1 Font Families................................................................365.11.2 Font Styles...................................................................365.11.3 Font Sizes.....................................................................36

5.12 Action Fields.......................................................................375.12.1 ActionButton................................................................37

5.13 Boolean Fields.....................................................................415.13.1 Checkbox.....................................................................41

5.14 Choice Fields......................................................................435.14.1 Choices: Describing Sets of Values..............................435.14.2 Combo..........................................................................445.14.3 Radiobutton..................................................................455.14.4 Spinner........................................................................475.14.5 Tabs.............................................................................48

5.15 Container Fields..................................................................515.15.1 Box...............................................................................51

5.16 Data Fields..........................................................................555.16.1 Autoexpand..................................................................555.16.2 Datefield.......................................................................585.16.3 FileDialog.....................................................................625.16.4 Link..............................................................................645.16.5 Password......................................................................655.16.6 Picture..........................................................................66

Form4j 0.5 4 06/10/2004

Page 5: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5.16.7 Textarea.......................................................................675.16.8 Textfield........................................................................68

5.17 Display Fields......................................................................715.17.1 Calculated.....................................................................715.17.2 Filler.............................................................................725.17.3 Label............................................................................735.17.4 Image...........................................................................74

5.18 Node Data Fields.................................................................755.18.1 HTML Area...................................................................755.18.2 MultiChoice..................................................................775.18.3 Table.............................................................................815.18.5 Tree..............................................................................91

6 Roadmap....................................................................................101

7 License......................................................................................102

8 Credits.......................................................................................103

Form4j 0.5 5 06/10/2004

Page 6: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

Form4j 0.5 6 06/10/2004

Page 7: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

1 Intro 1 Intro

1 Intro

1.1 Purpose

form4j is a java package to provide easy interactive GUI forms forjava clients.

Two reasons led to the implementation of this package:

• Most projects with java clients need some type of interactive dataentry

• XML has become enough widespread to base such a formpackage entirely on it.

The always occuring functionalities for data entry should be coveredby a single package - free from business logic, but easilyembeddable into a wide variety of data entry and manipulationtasks.

1.2 Basic Features

• Data interchange based completely on XML.form4j eats any data in XML format.

• Form definitions also in XML.

• XPath expressions are used to give full flexibility to referenceany data from specific form fields.

• The form layout is based on TableLayout to give enoughflexibility without too many layouting attributes.

• A DOMModel ensures full MVC (Model-View-Controller)functionality among different form fields pointing to the sameunderlying data.

• Conditional form elements: Any fields or form areas may bebound to XPath expressions on the data, to control Visibility andEditability.

• Inherited attributes: To avoid stupid repetition of fieldattributes within the form definition, many attributes areinheritable from ancestor elements.

Form4j 0.5 7 06/10/2004

Page 8: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

1 Intro 1.3 Endorsements

1.3 Endorsements

www.sourceforge.net

www.junit.org

jakarta.apache.org/bsf

logging.apache.org/log4j

Form4j 0.5 8 06/10/2004

Page 9: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

2 form4j Installation 2 form4j Installation

2 form4j Installation

2.1 Getting form4j

http://sourceforge.net/projects/form4j

2.2 System Requirements

2.2.1 To integrate form4j within your own Project

After pointing your classpath to form4j0.5.jar, form4j will run onany jdk1.4 Java Virtual Machine. For logging purposes you'lladditionally need on your classpath:

• log4j library on your classpath

2.2.2 To build form4j

To re-build form4j from the source distribution you will need:

• jdk1.4 or later Java Virtual Machine • ant 1.6 or later Ant installed

Form4j 0.5 9 06/10/2004

Page 10: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

2 form4j Installation 2.3 Installing form4j

2.3 Installing form4j

2.3.1 Source Distribution

The source distribution of form4j consists of the following directorylayout:

form4j +--- build.xml // the primay ant build script to build form4j | +--- config // contains configuration files. Namely: log4j.properties | +--- docs // contains documentation | +--- css // stylesheets for the docus | | | +--- images // various logos and images for html documentation | | | +--- manual // form4j manual | | | +--- uml // some uml diagrams | +--- dtd // contains the form4j.dtd defining syntax of form definitions | +--- lib // contains external jars needed at runtime | +--- test // contains jars needed for test purposes only | | +--- src // contains all java sources | +--- samples // form definition examples | +--- data // xml data for the examples | | | +--- forms // form definitions for the examples | | | +--- images // images for the examples

Just extract the source distribution into a directory of your choiceand change into that directory

To see form4j in action, just type:ant selfPortrait

Form4j 0.5 10 06/10/2004

Page 11: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

3 Getting Started 3 Getting Started

3 Getting StartedThis sections shows how to create the simplest possible form4j

3.1 Establish the environment

1. Create a directory for this example and change into it. 2. Create a directory jars to hold the jars. 3. Obtain and copy the form4j0.5.jar into the jars subdirectory.4. Obtain and copy the log4j.jar into the jars subdirectory.

Your current directory should now contain: current directory +--- jars +--- form4j0.5.jar +--- log4j.jar

3.2 Create HelloWorld.java

import javax.swing.*;import javax.xml.parsers.DocumentBuilderFactory;

import org.form4j.form.main.*;

public class HelloWorld {

public static void main(String args[]) { try { JFrame frame = new JFrame("HelloWorld");

Form form = new FormImpl( DocumentBuilderFactory.newInstance(). newDocumentBuilder().parse("helloData.xml"), DocumentBuilderFactory.newInstance(). newDocumentBuilder().parse("helloForm.xml") );

frame.getContentPane().add((JComponent)form); frame.pack(); frame.show(); } catch (Exception e) { e.printStackTrace(); } }}

3.3 Create helloData.xml

<hello>Hello Text</hello>

Form4j 0.5 11 06/10/2004

Page 12: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

3 Getting Started 3.4 Create helloForm.xml

3.4 Create helloForm.xml

<FormDefinition version="0.2">

<!-- declarations for the underlying TableLayout --> <Layout> <Constants> <Constant name="BORDER" value="20.0"/> <Constant name="GAP" value="20.0"/> <Constant name="LABEL" value="-2.0"/><!-- TableLayoutConstants.PREFERRED --> <Constant name="FIELD" value="-2.0"/><!-- TableLayoutConstants.PREFERRED --> <Constant name="ROW" value="-2.0"/><!-- TableLayoutConstants.PREFERRED --> </Constants> <Columns>BORDER,LABEL,GAP,FIELD,BORDER</Columns> <Rows>BORDER,ROW,BORDER</Rows> </Layout>

<!-- form areas and fields --> <Area> <Fields> <Label constraints="1, 1, l, t">Simple Textfield</Label> <TextField constraints="3, 1, l, t" key="/hello/text()"/> </Fields> </Area>

</FormDefinition>

Now you're almost there!

3.5 Verifying

Now you should have the following things in the current directory: current directory +--- HelloWorld.java +--- helloData.xml +--- helloForm.xml +--- jars +--- form4j0.5.jar +--- log4j.jar

3.6 Compiling

On Unixes

javac -classpath .:jars/form4j0.5.jar:jars/log4j.jar HelloWorld.java

On Windows

javac -classpath .;jars\form4j0.5.jar;jars\log4j.jar HelloWorld.java

Form4j 0.5 12 06/10/2004

Page 13: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

3 Getting Started 3.7 Running

3.7 Running

On Unixes

java -classpath .:jars/form4j0.5.jar:jars/log4j.jar HelloWorld

On Windows

java -classpath .;jars\form4j0.5.jar;jars\log4j.jar HelloWorld

Form4j 0.5 13 06/10/2004

Page 14: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

3 Getting Started 3.7 Running

Form4j 0.5 14 06/10/2004

Page 15: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

4 form4j Concepts 4 form4j Concepts

4 form4j Concepts

4.1 DOM Model

form4j operates on external data provided as XML through aninternal DOM Model.

An interactive modification of a form field changes the model andmay in turn trigger item change and condition change events onother parts of the form.

• For each form field referencing the same data an Item Change issent.This is primarily used to synchronize different views of the samedata.

• For each declared condition that is affected by a model change, aCondition Change is sent to all registered condition listeners.This is primarily used to show/hide conditional subforms and toenable/disable specific form fields.

While the above item change mechanism is not so surprising, thecondition mechanism is an interesting, generalized way to signalmodel changes beyond elementary item changes to registeredmodel (condition) listeners.

Form4j 0.5 15 06/10/2004

Page 16: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

4 form4j Concepts 4.1 DOM Model

A condition is expressed within the form definition as a namedXPath predicate. Any quality of the underlying data, that may beexpressed as an XPath expression, may serve as condition.

4.2 XPath

The most important application of XPath in form4j is the mannerhow XML data is referenced from the data fields.A data field may point to:

• source data as attribute using the key attribute: •• ... key="/sourceDocument/dataNode@attribute" ...•

• The source document would then look like: •• <sourceDocument>• <dataNode attribute="MYDATA"/>• </sourceDocument>•

• source data as element text using the key attribute: •• ... key="/sourceDocument/dataNode/text()" ...•

• The source document would then look like: •• <sourceDocument>• <dataNode>MYDATA<dataNode>• </sourceDocument>•

A further generalisation, with form fields operating on wholesubtrees of the source document, exists for NodeDataFields (e.g.Form Tree,Table,HTMLArea)

An XPath tutorial/reference is beyond the scope of this document.

4.2.1 Relative vs.absolute Addressing

In most of the cases (as in the above examples) you will have asingle XPath key, connecting your data with your form field.(absolute Addressing)

Form4j 0.5 16 06/10/2004

Page 17: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

4 form4j Concepts 4.2.1 Relative vs.absolute Addressing

However, if you use the Tree field, relative Addressing comes inhandy. When using the Tree field you want to select among severaltree nodes of a specific type and fill the same sub-form with thevalues of one of the nodes. In these cases the key can be maderelative by filling in the relativeRoot and relativeIndex attributes:

... key="text()" relativeRoot="/sourceDocument/dataNode" relativeIndex="1"...

Such a keydefinition is concatenated to yield:

/sourceDocument/dataNode[1]/text()

Using a special tree selection listener, the [1] in the relative keymay be changed dynamically, so that all such fields point todifferent nodes depending on the tree selection.

4.3 Attribute Inheritance

To avoid endless repetition of the same attributes within the formdefinitions, an inheritance mechanism is widely applied.The condition attributes visibleWhen, enabledWhen and severaldisplay attributes such as foreground, background, font arealways inherited from the ancestor nodes of the form definition:

inheritedAttribute = ancestor-or-self::*[@inheritedAttribute != ''][0]

For display attributes: When no ancestor defines the specificattribute, then the platform default is taken.

Form4j 0.5 17 06/10/2004

Page 18: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

4 form4j Concepts 4.4 Layout

4.4 Layout

The layouting of form components is based on the TableLayout. (Ifyou're serious about doing elaborate form layouts, it's a good ideato have a look into the table layout article).

4.4.1 Discussion

We thought it's not a good idea, to base a form layout on rigidpixel coordinates, because:

• different platforms may render the same component in differentsizes

• localized version of the same form definition, will usually causedifferent component sizes

On the other hand: The standard GridBagLayout - included with theJava Releases from early on - is famous for its complexity. Usingthis layout manager would have made the layout aspects of formdefinitions an inacceptable burden... While evaluating several third party layout managers, we finallychose the TableLayout, because:

• It seems natural to think about form layouts in table like terms. • The underlying table grid, with fixed and dynamically sized cells,

handles varying component sizes easily. • The placement of components with the constraints mechanism,

needs a single layout related attribute per form field definition.

Form4j 0.5 18 06/10/2004

Page 19: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5 Form Definition

5 Form Definition

5.1 Anatomy of a Form Definition

This anatomy has its equivalent within the XML form definitions: <FormDefinition version="0.2">

<Layout> <!-- declaration for the table layout --> </Layout>

<Conditions> <!-- optional XPath expr. to control conditional form parts --> </Conditions> <!-- evt.nested areas with common attributes and form fields --> <Area> <Fields>

<Area> <Fields> </Fields> </Area>

</Fields> </Area>

</FormDefinition>

Form4j 0.5 19 06/10/2004

Page 20: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.2 Form Layout

5.2 Form Layout

The layouting of form components is based on the TableLayout. (Ifyou're serious about doing elaborate form layouts, it's a good ideato have a look into the table layout article).

Basically, the table layout needs a global description of rows andcolumns to define the table cells. Single components are thenassigned to one or more table cells by their specific constraints. To make the XML definition more readable, we predefine therow/column declarations by a set of constant declarations. Theseconstants may subsequently be used within the row and columnsdeclarations. A 5x5 layout may look like: <!-- declarations for the underlying TableLayout --><Layout> <Constants> <Constant name="BORDER" value="20.0"/> <Constant name="GAP" value="10.0"/> <Constant name="FIELD" value="&TableLayoutConstants.PREFERRED;"/> <Constant name="ROW" value="&TableLayoutConstants.PREFERRED;"/> </Constants> <Columns>BORDER,FIELD,GAP,FIELD,BORDER</Columns> <Rows>BORDER,ROW,GAP,ROW,BORDER</Rows></Layout>

This layout declaration defines a table with the following cells: 20pix height 20pix preferred 10pix preferred 20pix

preferred height 20pix preferred 10pix preferred 20pix

10pix height 20pix preferred 10pix preferred 20pix

preferred height 20pix preferred 10pix preferred 20pix

20pix height 20pix preferred 10pix preferred 20pix

The effective size of the cells named preferred depends on thepreferred size of the form fields you'll later associate with thesecells.

5.3 Conditions

The visibility (and for some fields also the editability) may becontrolled by XPath Conditions.The underlying model re-evaluates all these conditions wheneverthe data changes. All form elements 'listening' to some conditionmay change their visibility (editability) in turn.This general feature may be used to achieve:

• Conditional SubformsWhen some areas of the form depend on some data content, youmay use such conditions to switch among subforms.Of course, some form fields such as a Tab,Combo,Radio,etc. may

Form4j 0.5 20 06/10/2004

Page 21: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.3 Conditions

cause the re-evaluation of the conditions by changing datacontent.

• Multipage FormsWhich is only a different way to look at conditional subforms -dependent on some pageselector within the data (See thefollowing example).

Example: Multipage FormLet's sketch out, how to create a two page form based on thefollowing XML Data!

<twoPageForm> <pageNr>0</pageNr> <!-- more xml data --></twoPageForm>

The pageNr field may have two values 0,1 to select among the twopages. To declare conditions for each page, we would have thefollowing conditions element within the formdefinition:

<!-- conditions to switch the two pages of this form definition --><Conditions> <Condition name="IsPage0" xpathPredicate="/twoPageForm/pageNr[text() = '0']" /> <Condition name="IsPage1" xpathPredicate="/twoPageForm/pageNr[text() = '1']" /></Conditions>

Then we collect all form elements for each page into separate Areaelements:

<!-- form elements for page 0 --><Area visibleWhen='IsPage0'> <!-- form fields of page 0 ... --></Area>

<!-- form elements for page 1 --><Area visibleWhen='IsPage1'> <!-- form fields of page 1 ... --></Area>

To allow interactive selection among the form pages, we may add atab element, that references the /twoPageForm/pageNr/text()value within the data, causing the specific form area to becomevisible: <!-- a tab as page selector --><Tab constraints="1, 3, 9, 3" key="/twoPageForm/pageNr/text()" selection="0,1"/>

Form4j 0.5 21 06/10/2004

Page 22: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.3 Conditions

Caution with white-space! When you use text() in the xpathpredicates! If in doubt, use normalize-space(text()) to ignorewhite space.

5.3.1 Constant Conditions

Instead of a qualified condition name, the following constantconditions may occur within the visibleWhen and enabledWhencondition attributes:

• true (ANDed with any ancestor conditions) • false (ANDed with any ancestor conditions) • always (not ANDed with any ancestor conditions) • never (not ANDed with any ancestor conditions)

5.3.2 Nested Conditions

Condition bound attributes are ANDed along their ancestor axis. For an visibleWhen condition in some field, all eventually existingvisibleWhen are ANDed: they all must be true for the specific fieldto become visible. The only exception from this nesting rule are the constantconditions always and never. These are evaluated directly, withouttaking any ancestor conditions into account.

Form4j 0.5 22 06/10/2004

Page 23: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.4 Areas

5.4 Areas

Form areas are elements to structure form definitions.They have no effect on the layout and don't correspond to swingcontainers.Typical usage for areas are:

• Group some form fields with the same (inherited) attributesand declare these attributes only within the parent Areaelement.

• Enclose conditional subforms within Area elements and havea visibleWhen condition attribute control the visiblity of thewhole area. (See the example for conditional subforms in the conditionssection).

• Enclose form areas within borders. Whenever one of the areafields is focused, the surrounding border will change itscolors.

5.4.1 Area Titles

Area titles are very similar to plain Labels, except that theirconstraints are defined within a titleConstraints attribute andtheir text within a title attribute in the area element.Attribute Description Req. Inher.

titleConstraints

The TableLayout constraints for the area ti-tle.When this parameter is missing, the area willhave no title.

No No

title The title for this area No No

focusTitleColorThe foreground color for this title, when oneof the area fields become focused. (See the colors section)

No Yes

Form4j 0.5 23 06/10/2004

Page 24: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.4.2 Area Borders

5.4.2 Area Borders

Attribute Description Req. Inher.

borderConstraints

The border constraints for thearea borders.Usually row1,col1,row2,col2. When this attribute exists, a bor-der rectangle with these con-straints is painted. The borderline will appear exactly in themiddle of the resp. column/row. Full control over border locationsand gaps is achieved by havingspecific inner-border columns/rowin the layout definition.

No No

borderLightColor

The color of the lighted part of theengraved border line when nofield in this area is focused.(See the colors section)

No Yes

borderShadowColor

The color of the shaded part ofthe engraved border line when nofield in this area is focused.(See the colors section)

No Yes

focusBorderLightColor

The color of the lighted part of theengraved border line when a fieldin this area is focused.(See the colors section)

No Yes

focusBorderShadowColor

The color of the shaded part ofthe engraved border line when afield in this area is focused.(See the colors section)

No Yes

Form4j 0.5 24 06/10/2004

Page 25: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.4.2 Area Borders

Example

<Area borderConstraints="1,17,7,20" titleConstraints="2,17,6,17,l,c" title="Account"> <Fields>...</Fields> </Area>

Note how the borders are drawn in the middles of the rows/columnsdeclared by the borderConstraints="1,17,7,20" attribute:

When one of the fields becomes focused, the same border looksslightly different:

Form4j 0.5 25 06/10/2004

Page 26: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.4.2 Area Borders

Form4j 0.5 26 06/10/2004

Page 27: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.5 Taxonomy of Form Fields

5.5 Taxonomy of Form Fields

Form fields are the building blocks of form4j.

5.6 Common Attributes

Besides their specific attributes, all form fields have the followingcommon set of attributes: Attribute Description Req. Inher.

backgroundThe background color for this field.(See the colors section)

No Yes

class

By default, this attribute points to the form4j in-ternal class for the form field. The only reasonto override this attribute, is to experiment withown implementations of form field classes.

No No

constraints The TableLayout constraints for this field. Yes No

enabledWhenThe condition name if this field's editability de-pends on some condition.true,false are possible values too.

No Yes

Form4j 0.5 27 06/10/2004

Page 28: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.6 Common Attributes

Attribute Description Req. Inher.

fontThe font for this field.(See the fonts section)

No Yes

foregroundThe foreground color for this field.(See the colors section)

No Yes

name

The symbolic unique name for this field.By default a unique, artifical name is assignedto each field. This name - generated from thepath in the form definition - is used to referencethe fields for marking or to delegate actions. In some cases it is easier to assign your ownname to some or all form fields.

No No

tipThe tooltip for this field.Multiline tooltips are possible using \n as line-feed.

No No

visibleWhenThe condition name if this field's visibility de-pends on some condition.

No Yes

5.7 Common Data Field Attributes

All fields associated with xml data additionally need the followingattributes: Attribute Description Req. Inher.

default The default value for this field. No No

changeListenerThe classname of a FieldChangeListener,that gets called whenever the content of thefield changes.

No No

dirtyIgnorable

When set to true, no dirty signalling occurs.

This is used primarily when you have choicefields (Tabs) to control the visibility of sev-eral form pages and a form page changedoes not make the data 'dirty'. Default is false.

No No

focusListenerThe classname of a standard java.awt.even-t.FocusListener, that gets called wheneverthe field gains or looses focus.

No No

key

The XPath key for this field.An XPath key may either point into the XMLData to an element's text or to some at-tribute of an element.When the field is interactively changed,then the referenced node will change ac-cordingly. For Node Data Fields the key may select anodelist out of the form's xml data.

Yes No

keyListenerThe classname of a standard java.awt.even-t.KeyListener, that gets called whenever the(focus) field receives a keyboard event.

No No

Form4j 0.5 28 06/10/2004

Page 29: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.7 Common Data Field Attributes

Attribute Description Req. Inher.

mandatory

Controls the optional/mandatory behavior ofthis field. During form data entry this attribute has noeffect. Only when getData() is called to ob-tain the form's data and any mandatoryfields are empty, then these fields aremarked and a MandatoryFieldsEmptyExcep-tion is thrown. Default is false.

No No

modelTriggering

Controls on what situation a model changewill be triggered and the actual field con-tent is transferred back to the model.Possible values are focus|item.

• focusModel change is triggered when thefocus for this field is lost.

• itemModel change occurs for eachchange on the field's content.

Default is focus.

No No

relativeIndexrelativeRoot

Advanced: does only make sense, whenmultiple xml nodes are to be displayed with-in the same (sub)form. When one of the tree nodes is selected, thenfield with these attributes were redirectedto show values from the selected node. The full xpath key for such fields becomes:relativeRoot[relativeIndex]/key Only relativeRoot needs to be specified -relativeIndex is programmaticallychanged by DefaultTreeSelectionListener

No No

whenEmpty

What to do, when no data is at key?Possible values are:

• useDefault (field default is used), • leaveEmpty (Field is left empty, even

when formatting pattern isvalidated),

• fail (field is not created).

Default is useDefault.

No No

Form4j 0.5 29 06/10/2004

Page 30: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.8 Value Enumerations

5.8 Value Enumerations

On several occasions a feature to describe sets of - potentiallyexternal - values is needed. The primary consumers of such sets arethe Choice Fields, where a visual choice among several given valuesis to be presented.

A single element of such an enumeration consists in up to fourparts:

• item: the mandatory key or id of the element

• name: the optional visual name of the element. Using names in an enumeration is comparable to a name/valuepair approach, where you want to deal with keys internally whileshowing some (potentially) localized strings externally.

• active: this optional part is a bit harder to understand. Thesituation where you need this flag arises, when an element of theset is no longer selectable, but you still want to display the oldvalue. In a choice data field an inactive enumeration element isdisplayed in grey color and cannot be selected anymore.

• code: this optional element simply gives a third possibility toreference a enumeration element. The obvious example is a city selection task, where you have a(id,cityname,zip) entity. The cityname is to be presented readonlyand the zip must be an autocomplete field. Entering partially zipcodes into the zip field will autocomplete the zip and the citynamefield - while internally the id is used within the form's xml data.

While we provide a default implementation of theEnumFacadeInterface, your implementation may need a differentimplementation, when for example the id,names are to be fetchedfrom a webapplication or a J2EE businesstier. Thus the following attributes only apply to our defaultimplementation, whereas specific external implementations willneed more and other attributes (JNDI names,url,etc.).

Form4j 0.5 30 06/10/2004

Page 31: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.8.1 Attributes

5.8.1 Attributes

The default enumeration implementation recognizes the followingattributes:

Attribute Description Req. Inher.

name

The unqiue name of this descriptor. When you needthe same descriptor several times, it only need to bedeclared once. Subsequent uses of the same de-scriptor are done by using the same name attributeas the single attribute of the descriptor.

No No

class

The classname of the enumeration implementation. When your situation needs a specific implementa-tion you just need to provide its classname here. Default is org.form4j.form.field.util.EnumFa-cadeImpl.

No No

url

An URL that delivers the xml-data for the enumera-tion. With the XPath Expressions of the other attributes,we specify how this xml data is to be used to createthe the enumeration elements.

No No

idPath The XPath expression that selects the id part out ofthe base xml data of the enumeration.

Yes No

namePathThe XPath expression that selects the optionalname part out of the base xml data of the enumera-tion.

No No

codePathThe XPath expression that selects the optional codepart out of the base xml data of the enumeration.

No No

activePathThe XPath expression that selects the optional ac-tive part out of the base xml data of the enumera-tion.

No No

Examples

For the following two examples we rely on an xml file with somecountry data. It is located atfile:samples/data/countries.data.xml and looks like:

<countries> <country key='1' iso3='ARE' name='Abu Dhabi' active='true'/> <!-- ... --> <country key='257' iso3='ZWE' name='Zimbabwe' active='true'/> </countries>

The simplest form is a name/value pair situation:

<EnumDescriptor name="countryEnum" url ="file:samples/data/countries.data.xml" idPath ="/countries/country/@key" namePath ="/countries/country/@name"

Form4j 0.5 31 06/10/2004

Page 32: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.8.1 Attributes

/>

When we need active and iso codes value too, we just extend theprevious descriptor slightly:

<EnumDescriptor name="countryEnum" url ="file:samples/data/countries.data.xml" idPath ="/countries/country/@key" codePath ="/countries/country/@iso3" namePath ="/countries/country/@name" activePath="/countries/country/@active" />

Form4j 0.5 32 06/10/2004

Page 33: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.9 Advanced Processing with DataAdapters

5.9 Advanced Processing with DataAdapters

SECTION INCOMPLETE

• org.form4j.form.adapter.DataAdapter • org.form4j.form.adapter.DefaultDataAdapter • org.form4j.form.adapter.DataAdapterCall

Data adapters are only used in advanced form operations whenexternal data need to be retrieved and mapped into the form's xmldata.

1. Key Selection The first step is to always to select one or several keys forprocessing by the Data Adapter. This step may appear visually in very different fashions:

• selection of on or several rows in Table form field • clicking on an item in a MultiChoice form field • dragging or selecting tree nodes in a Tree form field

2. Operation Together with the key selection an operation selected. Thisagain depends on the governing form field and consists inoperations like:

• ADD • DEL • REPLACE • RETRIEVE_AND_MAP

Its the governing form fields responsability to set up aDataAdapterCall and launch the next step:

3. Data Adapter Processing The data adapter accepts its processing task defined by theabove steps and its own attributes. An ADD operation for example cause retrieval of external dataand insertion into the form's local xml data.

4. Mapping Whenever the external data has a different structure or whenthe external data should be mapped into some other arbitraryform fields, the data adapter includes a mapping step.

<DataAdapterDescriptor url ="file:samples/data/countries.data.xml" foreignKeyTemplate="/countries/country[@iso3={0}]" localKeyTemplate ="/multichoice/country[@iso3={0}]" />

This example establishes a foreign key relation using some iso3

Form4j 0.5 33 06/10/2004

Page 34: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.9 Advanced Processing with DataAdapters

attribute of country nodes. When the unselected country 'Antarctica' with ISO-Code ATA isselected, then the key templates {0} are resolved by ATA and theforeign key becomes: /multichoice/country[@iso3='ATA'] The data adapter thenretrieves the node using this key and inserts it into the form's xmldata.

Form4j 0.5 34 06/10/2004

Page 35: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.10 Colors

5.10 Colors

5.10.1 Color Names

The following (java) colornames are valid values forbackground/foreground attributes:

• white • green • orange • yellow • red • blue • cyan • magenta • pink • gray • lightGray • darkGray • black

To specify a white background, the attribute looks like:background="white".

5.10.2 RGB Colors

Alternatively hexadecimal Red Green Blue color codes may be usedwithin background/foreground attributes. To specify a white background, the attribute looks like:background="#ffffff".

Form4j 0.5 35 06/10/2004

Page 36: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.11 Fonts

5.11 Fonts

If you just want to increase/decrease the size of some inherited font,use the relative way to specify the font attribute:

font="+30%" or font="-20%"

An absolute font attribute consists of threeparts:FAMILY.STYLE.SIZE

5.11.1 Font Families

Unfortunately the available font families are platform dependent. Asafe bet is to use Dialog and DialogInput as platform independentfont family names.To obtain a list of available font family names for your platform,consult: getAvailableFontFamilyNames()!

5.11.2 Font Styles

The following styles are possible:

• PLAIN • BOLD • ITALIC

5.11.3 Font Sizes

The Didot Point Size for this font.An Integer number between 8..24 is known to work.

font="Dialog.PLAIN.12"

Form4j 0.5 36 06/10/2004

Page 37: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.12 Action Fields

5.12 Action Fields

Action fields are not associated with the XML Data through someXPath Key. Typically they trigger some action - external to the form4j - bycalling some assignable action listener.

5.12.1 ActionButton

Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27)

Attribute Description Req. Inher.text The text of the button. No No

image an image filename or url for the label's icon No No

rollover an image filename or url for the buttons'srollovericon

No No

pressedan image filename or url for the buttons'spressed icon

No No

focus an image filename or url for the buttons's fo-cused icon

No No

borderPaintedControls border painting around the button.Possible values are true|false. Default is true.

No No

actionCommandSome string that gets passed as actionCom-mand to any assigned action listener

No No

actionListener

Classname(s) of the associated ActionListen-er(s) This actionlistener will be called when-ever the button is clicked.

It is possible to use a comma separated listof action listener classnames, when morethan one action listener should be triggeredby this button.

No No

Action Listener

An evident question when writing and assigning ActionListeners is:How can I determine the Form and the Field Definition for theAction Button that triggered me?The following java methods - integrated into your action listener -will do this job:

import org.form4j.form.field.Field;import org.form4j.form.main.Form;

public void actionPerformed(ActionEvent evt) { log.info("Event " + evt);

Form4j 0.5 37 06/10/2004

Page 38: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.12.1 ActionButton

log.info("Parent Form " + getParentForm(evt)); log.info("Field " + getField(evt)); log.info("FieldDescriptor " + getField(evt). getFieldDescriptor());} private Form getParentForm(ActionEvent evt) { return (Form) SwingUtilities.getAncestorOfClass( Form.class, (Component) evt.getSource() );}

private Field getField(ActionEvent evt) { return getParentForm(evt). getFieldByComponent((JComponent)evt.getSource());}

Examples

To create an Action Button labeled Action, triggeringmy.special.ActionListener at cell 3,3 use:

<ActionButton constraints="3,3" text="Action" actionListener="my.special.ActionListener" />

For the same button, but with rollover and pressed images, use:

<ActionButton constraints ="3,3" actionListener="my.special.ActionListener" image ="samples/images/emptyButton.gif" pressed ="samples/images/emptyButton.pressed.gif" rollover ="samples/images/emptyButton.rollover.gif" />

Form4j 0.5 38 06/10/2004

Page 39: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.12.1 ActionButton

Delegated Actions

Action buttons may trigger actions on other form fields through adelegation mechanism.

<ActionButton constraints="4,3,l,t" name="someButton" actionCommand="doIt" image="/images/bulb.png" > <DelegateAction delegates="FieldName0,FieldName1"/> </ActionButton>

This declaration triggers the action listener(s) of the named fieldsFieldName0 and FieldName1 to be triggered.Other action listeners - assigned through the actionListenerattribute - are not affected by this additional mechanism. When the delegates need different action commands than the actionbutton itself, it is possible to override the button's actionCommandattribute, using:

<ActionButton constraints="4,3,l,t" name="someButton" actionCommand="doIt" image ="/images/bulb.png" > <DelegateAction actionCommand="doFieldName0" delegates="FieldName0"/> <DelegateAction actionCommand="doFieldName1" delegates="FieldName1"/> </ActionButton>

This variation triggers the actions of FieldName0 with the actioncommand doFieldName0 and the actions of FieldName1 with theaction command doFieldName1. The following fields are potential delegates:

• File Dialog • Link • Table

More Examples with Action Buttons (Source Distro) Form Data Description• actionButtons data Action Button Variations

• box data Delegated Action Buttons in Box Containers

• bsfAction data Action Button triggers Scripting Languages

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 39 06/10/2004

Page 40: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.12.1 ActionButton

Form4j 0.5 40 06/10/2004

Page 41: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.13 Boolean Fields

5.13 Boolean Fields

Boolean fields are primarily two valued fields with two differentvisual states. A third state may come into play, when the associated data node isempty. In this case, manipulating the field control will turn booleanfields non-empty. From then on normal behavior rules. (See thegeneral whenEmpty attribute!)

5.13.1 Checkbox

Specific Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 )

Attribute Description Req. Inher.

falseValueThe value that signifies an unselected check-box. Default is false.

No No

text The label just right of the checkbox No No

trueValueThe value that signifies a selected checkbox Default is false.

No No

radioGroup

Specifying some group name here - makes allcheckboxes with the same groupname behavelike radio buttons (mutually exclusive selec-tion). Effectively a way to get radio buttonsbut without the layout restrictions of the plainRadio field.

No No

actionListener

Classname(s) of the associated ActionListener(s) This actionlistener will be called wheneverthe checkbox is clicked.

It is possible to use a comma separated list ofaction listener classnames, when more thanone action listener should be triggered by thisbutton.

No No

Form4j 0.5 41 06/10/2004

Page 42: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.13.1 Checkbox

Examples

To create a Checkbox form field referencing data at /data@validwith true|false at cell 3,3 (left,top aligned) use:

<Checkbox constraints="3,3,l,t" key="/data@valid"/>

To create a Checkbox form field referencing data at /data/valid/text() with YES|NO values and an associated text use:

<Checkbox constraints="3,3,c,t" key="/data/valid/text()" trueValue="YES" falseValue="NO" text="checkbox text" />

Form4j 0.5 42 06/10/2004

Page 43: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14 Choice Fields

5.14 Choice Fields

5.14.1 Choices: Describing Sets of Values

Besides their specific attributes, all choice fields have the followingcommon set of attributes to describe the set of selectable values: Attribute Description Req. Inher.

selection

A list of selectable values for this field, separated bythe value of the separator attribute (Default ,).For each of the values, a combo box item is createdand labeled directly with the value. Selecting a spe-cific item from the combobox, updates the the refer-enced text/attribute with the associated value. (~Value is a shorthand notation to say that this valueshould only be displayable but not selectable. Seethe active attribute on Enumeration Values)

Yes* No

labels

A list of labels for this field, separated by the valueof the separator attribute (Default ,)Use this optional list of item labels, when you don'twant to display the values from selection directly. For each of list elements, a combobox item is createdand labeled with the label. Selecting one of the com-bobox items, updates the the referenced text/at-tribute with the associated value.This list must have the same count of elements asthe list of selection.

No No

separatorThe separator character to separate lists(selection,labels,elementTips) for this field. Default is ,

No No

* Another way to describe the set of selectable values, is the use ofan Enumeration. In cases where non-constant external set of valuesare needed, you should consider this alternative.

Selectable Values as Attributes

<ChoiceField constraints="3,3,l,t" key="/data@selectABCD" selection="A,B,C,D"/>

Selectable Values as Enumeration

<ChoiceField constraints="3,3,l,t" key="/data@selectCountry" > <EnumDescriptor name="countryEnum" url ="file:samples/data/countries.data.xml" idPath ="/countries/country/@key" namePath ="/countries/country/@name" /> </ChoiceField>

Form4j 0.5 43 06/10/2004

Page 44: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.2 Combo

5.14.2 Combo

A regular, no-thrills combo box.

Attributes

More Attributes: Choices (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

Examples

To create a Combobox form field with three selections with the textI am a Label, referencing data at /data@selectABCD with A|B|Cvalues, at cell 3,3 (left,top aligned) use:

<ChoiceField constraints="3,3,l,t" key="/data@selectABCD" selection="A,B,~C,D"/>

To create a Combobox form field with three selections labeled AText,B Text,C Text,D Text, referencing data at /data/selectABCD/text() with A|B|C values at cell 3,3 (center,topaligned) use:

<ChoiceField constraints="3,3,c,t" key="/data/selectABCD/text()" selection="A,B,C,D" labels="A Text,B Text,C Text,D Text" />

More Examples with ChoiceFields (Source Distro) Form Data Description• choice data Elementary Tab

• conditional data Conditional Subforms

• enum data Collection of Choice Fields

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 44 06/10/2004

Page 45: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.3 Radiobutton

5.14.3 Radiobutton

Attributes

More Attributes: Choices (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

Attribute Description Req. Inher.

elementTips

A list of tooltips for each radio button, separatedby the value of the separator attribute (Default,).Multiline tooltips are possible using \n as line-feed.This list must have the same count of elementsas the list of selection.

No No

orientationThe orientation of the radiobuttons. Possible val-ues are horizontal|vertical. Default is vertical

No No

Examples

To create a Radiobutton form field with three radio buttons labeledA|B|C, referencing data at /data@selectABCD with A|B|C values, atcell 3,3 (left,top aligned) use:

<Radio constraints="3,3,l,t" key="/data@selectABCD" selection="A,B,~C,D"/>

To create a Radiobutton form field with three radio buttons labeledA Text,B Text,C Text,D Text, referencing data at /data/selectABCD/text() with A|B|C values at cell 3,3 (center,topaligned) use:

<Radio constraints="3,3,c,t" key="/data/selectABCD/text()" selection="A,B,C,D" labels="A Text,B Text,C Text,D Text" />

Form4j 0.5 45 06/10/2004

Page 46: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.3 Radiobutton

More Examples with Radio Buttons (Source Distro) Form Data Description• radio data Elementary Radio Button

• conditional data Conditional Subforms

• enum data Collection of Choice Fields

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 46 06/10/2004

Page 47: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.4 Spinner

5.14.4 Spinner

Attributes

More Attributes: Choices (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

Attribute Description Req. Inher.

elementTips

A list of tooltips for each spinner item, separatedby the value of the separator attribute (Default ,).Multiline tooltips are possible using \n as line-feed.This list must have the same count of elementsas the list of selection.

No No

Examples

To create a Spinner form field with four selections, referencing dataat /data@selectABCD with A|B|C|D values, at cell 3,3 (left,topaligned) use:

<Spinner constraints="3,3,l,t" key="/data@selectABCD" selection="A,B,~C,D"/>

To create a Spinner form field with four selections labeled A Text,BText,C Text,D Text, referencing data at /data/selectABCD/text() with A|B|C values at cell 3,3 (center,top aligned) use:

<Spinner constraints="3,3,c,t" key="/data/selectABCD/text()" selection="A,B,C,D" labels="A Text,B Text,C Text,D Text" />

More Examples with Spinners (Source Distro) Form Data Description• spinner data Elementary Spinner Field

• conditional data Conditional Subforms

• enum data Collection of Choice Fields

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 47 06/10/2004

Page 48: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.5 Tabs

5.14.5 Tabs

Tab fields are much like Tabbed Panes (JTabbedPane), withoutassociated panels. Only the tab items are shown to select amongmultiple values.Typically, this type of form field is used, to control conditionalsubforms. This is achieved by having

1. a condition associated with each tab item. 2. form areas for each of the tabs, governed by these conditions

See the example for conditional subforms in the conditions section.

Attributes

More Attributes: Choices (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

Attribute Description Req. Inher.

elementIcons

A list of icon file names/url for each tab item,separated by the value of the separator at-tribute (Default ,).This list must have the same count of elementsas the list of selection.

No No

elementTips

A list of tooltips for each tab item, separated bythe value of the separator attribute (Default ,).Multiline tooltips are possible using \n as line-feed.This list must have the same count of elementsas the list of selection.

No No

Examples

To create a Tab form field with three tabs labeled A|B|C,referencing data at /data@selectABCD with A|B|C values, spanningfrom cell 3,3 to cell 3,5 use:

<Tab constraints="3,3,3,5" key="/data@selectABCD" selection="A,B,~C,D" />

Form4j 0.5 48 06/10/2004

Page 49: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.5 Tabs

To create a Tab form field with three tabs labeled A Text,B Text,CText,D Text, referencing data at /data/selectABCD/text() withA|B|C values, spanning from cell 3,3 to cell 3,5 use:

<Tab constraints="3,3,3,5" key="/data/selectABCD/text()" selection="A,B,C,D" labels="A Text,B Text,C Text,D Text" />

More Examples with Tabs (Source Distro) Form Data Description• tab data Elementary Tab

• conditional data Conditional Subforms

• enum data Collection of Choice Fields

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 49 06/10/2004

Page 50: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.14.5 Tabs

Form4j 0.5 50 06/10/2004

Page 51: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.15 Container Fields

5.15 Container Fields

Container fields are for pure sub-layout purposes. The are veryhandy when a group of small things (such as little action buttons)are to be grouped together without adding lots of columns/rows tothe overall form layout. Other fields gets added to container fields by using the container'sname as constraints.

5.15.1 Box

This container field is the form4j incarnation of java's BoxLayout.

Attributes

Attribute Description Req. Inher.

constraints The TableLayout constraints for this field. Yes No

nameThe container name. Other fields will use thisname to get added to the container - insteadof using their own table layout constraints.

Yes No

axisThe axis along with the containers compo-nents gets layouted.Possible values are: x or y

Yes No

borderControls border painting around the contain-erPossible values are true|false.

No

Default isfalse.

No

Examples

The declaration to create a box container with three action buttonslooks like:

<Box constraints="3,3,l,t" name="Box0" axis="x"/> <ActionButton constraints="Box0" image="/images/op.minus.png"/> <ActionButton constraints="Box0" image="/images/op.plus.png"/> <ActionButton constraints="Box0" image="/images/op.dotdot.png"/>

Form4j 0.5 51 06/10/2004

Page 52: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.15.1 Box

This exhaustive example shows all the different ways a boxcontainer with three buttons may be place around another arectangular form area (a table or anything):

<Box constraints="1, 1, r, t" axis="y" name="BoxLeftTop"/> <ActionButton constraints="BoxLeftTop" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxLeftTop" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxLeftTop" borderPainted="true" image="/images/op.dotdot.png"/>

<Box constraints="1, 1, r, c" axis="y" name="BoxLeftCenter"/> <ActionButton constraints="BoxLeftCenter" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxLeftCenter" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxLeftCenter" borderPainted="true" image="/images/op.dotdot.png"/>

<Box constraints="1, 1, r, b" axis="y" name="BoxLeftBottom"/> <ActionButton constraints="BoxLeftBottom" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxLeftBottom" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxLeftBottom" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="3, 1, l, t" axis="y" name="BoxRightTop"/> <ActionButton constraints="BoxRightTop" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxRightTop" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxRightTop" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="3, 1, l, c" axis="y" name="BoxRightCenter"/> <ActionButton constraints="BoxRightCenter" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxRightCenter" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxRightCenter" borderPainted="true" image="/images/op.dotdot.png"/>

Form4j 0.5 52 06/10/2004

Page 53: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.15.1 Box

<Box constraints="3, 1, l, b" axis="y" name="BoxRightBottom"/> <ActionButton constraints="BoxRightBottom" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxRightBottom" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxRightBottom" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="2, 0, l, b" axis="x" name="BoxTopLeft"/> <ActionButton constraints="BoxTopLeft" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxTopLeft" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxTopLeft" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="2, 0, c, b" axis="x" name="BoxTopCenter"/> <ActionButton constraints="BoxTopCenter" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxTopCenter" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxTopCenter" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="2, 0, r, b" axis="x" name="BoxTopRight"/> <ActionButton constraints="BoxTopRight" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxTopRight" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxTopRight" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="2, 2, l, t" axis="x" name="BoxBottomLeft"/> <ActionButton constraints="BoxBottomLeft" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxBottomLeft" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxBottomLeft" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="2, 2, c, t" axis="x" name="BoxBottomCenter"/> <ActionButton constraints="BoxBottomCenter" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxBottomCenter" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxBottomCenter" borderPainted="true" image="/images/op.dotdot.png"/> <Box constraints="2, 2, r, t" axis="x" name="BoxBottomRight"/> <ActionButton constraints="BoxBottomRight" borderPainted="true" image="/images/op.minus.png"/> <ActionButton constraints="BoxBottomRight" borderPainted="true" image="/images/op.plus.png"/> <ActionButton constraints="BoxBottomRight" borderPainted="true" image="/images/op.dotdot.png"/>

Form4j 0.5 53 06/10/2004

Page 54: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.15.1 Box

Form4j 0.5 54 06/10/2004

Page 55: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16 Data Fields

5.16 Data Fields

5.16.1 Autoexpand

The most complex field among the data fields provides severalvariations of autocompletion of partial data entry into a text field. To describe the set of acceptable values for an autoexpand field, thesame Enumeration is used as for the Choice Fields.

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 )

Attribute Description Req. Inher.

ignoreAmbivalence

When set to true, no combo box to re-solve any remaining ambivalence will ap-pear. Even when the partial input match-es several possible values, the one shownin the text field is taken when the fieldlooses its focus. When set to false, a combo box with allpossible values will appear when thefield looses its focus. This allows directselection of possible autocompletion val-ues. When the selection in the combo ismade by clicking the appropriate value,the combo will disappear and the select-ed values is tranferred into the autocom-pletion field. Default is true

No No

lookupBy

Tells the autoexpand field what part ofthe enumeration should be used for theautocompletion lookup. Possible values are id|code|name. Default is name

No No

ambivalenceOn

When ignoreAmbivalence=false andthe combo to resolve ambivalencesshould popup over another field, thanthis field's name is filled in here. (The ZIP Example allows entry of ZIPsinto an Autoexpand field, but resolvesambivalences in terms of city names overthe city name field)

No No

Examples

For the following two examples we rely on an xml file with somecountry data.

It is located at file:samples/data/countries.data.xml and lookslike:

Form4j 0.5 55 06/10/2004

Page 56: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.1 Autoexpand

<countries> <country key='1' iso3='ARE' name='Abu Dhabi' active='true'/> <!-- ... --> <country key='257' iso3='ZWE' name='Zimbabwe' active='true'/> </countries>

The simplest form is a single textfield with an associated set ofpossible values: <Autoexpand constraints="1,1" key="/data/country/id/text()" > <EnumDescriptor name="countryEnum" url ="file:samples/data/countries.data.xml" idPath ="/countries/country/@key" namePath ="/countries/country/@name" /> </Autoexpand>

Whenever the focus leaves this field and there are several possiblecompletion values, the first one is taken as the final value for theform's xml data without prompting the user to resolve thisambivalence. The next example just changes this behavior by declaringignoreAmbivalence='false';

<Autoexpand constraints="1,1" key="/data/country/id/text()" ignoreAmbivalence="false" > <EnumDescriptor name="countryEnum" url ="file:samples/data/countries.data.xml" idPath ="/countries/country/@key" namePath ="/countries/country/@name" /> </Autoexpand>

Form4j 0.5 56 06/10/2004

Page 57: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.1 Autoexpand

Examples with dependent fields

The next examples bases on city data atfile:samples/data/cities.data.xml that looks like:

<cities> <bean><Id>2</Id><ZIP>1000</ZIP><Name>Lausanne</Name></bean> <!-- .. --> <bean><Id>200</Id><ZIP>1063</ZIP><Name>Moudon</Name></bean> </cities>

The goal is to have an autoexpanding ZIP Field that expands into acomplete ZIP but also fills the corresponding city name field, whileshowing a combo box when the ZIP field relates to more than onecorresponding city names:

<AutoexpandField constraints="4,15" key="/autoexpand/ambi0/zip/text()" lookupBy="code" ambivalenceOn="CityNameField" > <EnumDescriptor name="cityEnum" url ="file:samples/data/cities.data.xml" idPath ="/cities/bean/Id/text()" codePath ="/cities/bean/ZIP/text()" namePath ="/cities/bean/Name/text()" /> <Dependent lookupBy="name" key="/autoexpand/ambi0/city/text()"/> </AutoexpandField> <TextField name="CityNameField" constraints="6,15,l,t" key="/autoexpand/ambi0/city/text()" enabledWhen="false" />

More Examples with Autoexpand (Source Distro) Form Data Description• autoexpand data Several Autocompletion Situations

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 57 06/10/2004

Page 58: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.2 Datefield

5.16.2 Datefield

Basic Attributes

More Attributes: Basic Formatting (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

Attribute Description Req. Inher.

columns

The visible width of the date field in columns.Column width depends on the selected font and isnot a very accurate measure.This attribute does not limit the maximum textlength, that may be entered. Default is 20

No No

maxLength

The maximum text length for text fields.This limits the length of the text that may be en-tered into this field. Default is 72

No No

align

Horizontal alignment for the text within this textfield.Possible values are left|center|right. Default is right

No No

Formatting Attributes

Datefields have two distinct format specifications:

• the visual format, that controls the date format for user inputand presentation.

• the invisible dataFormat, that controls what format isexpected in the data.

Attribute Description Req. Inher.

dataFormat

This attribute controls the date representationwithin the XML Model data and has no visual ef-fect.When the model data consist of a number (withthe seconds since 01.01.1970) just specify long When your date representation within the Modeldata is represented by the SimpleDateFormat-Pattern yyyy.MM.dd HH:mm:ss, you would directlyspecify this pattern.Any correct pattern as specified in SimpleDateFor-mat is a possible value for this attribute. Default is long

No No

format

The parametrisation of the JFormattedTextFieldformatting capabilities.(For deeper insight of these formatting capabili-ties, see: How to Use Formatted Text Fields)

Date FormattersTo select a date formatter, prepend the Simple-DateFormat pattern by date:.

No No

Form4j 0.5 58 06/10/2004

Page 59: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.2 Datefield

Examples

To create a right aligned DateField based on long datarepresentation with a visual date pattern of yyyy.MM.dd referencingdata at /data/date@value at cell 3,3 (left,top aligned) use:

<DateField constraints="3,3,l,t" key="/data/date@value" format="date:yyyy.MM.dd" />

To create a right aligned DateField based on data representationyyyy.MM.dd HH:mm:ss with a visual date pattern of yyyy.MM.ddreferencing data at /data/date@value at cell 3,3 (left,top aligned)use:

<DateField constraints="3,3,l,t" key="/data/date@value" format="date:yyyy.MM.dd" dataFormat="yyyy.MM.dd HH:mm:ss" />

Defaults for Date

1. Constant Defaults When a constant date is to be used asdefault, then it must have the same dataFormat as specified inthe dataFormat attribute.

2. Relative Defaults A small arithmetic evaluation allowsspecification of dates relative to the current time;

$NOW+

-n

HOUR

DAY

WEEK

MONTH

YEAR

To have a constant default of '2004.03.03 17:52:48' use (dependingon dataFormat):

<DateField constraints="3,3,l,t" key="/data/date@value" format="date:yyyy.MM.dd" default="1078246368828" /> <DateField constraints="3,3,l,t" key="/data/date@value" format="date:yyyy.MM.dd" dataFormat="yyyy.MM.dd HH:mm:ss" default="2004.03.03 17:52:48" />

Examples with relative date defaults:

Form4j 0.5 59 06/10/2004

Page 60: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.2 Datefield

<DateField constraints="3,3,l,t" key="/data/date@value" dataFormat="yyyy.MM.dd HH:mm:ss" default="$NOW" /> <DateField constraints="3,3,l,t" key="/data/date@value" dataFormat="yyyy.MM.dd HH:mm:ss" default="$NOW + 2 HOUR" /> <DateField constraints="3,3,l,t" key="/data/date@value" dataFormat="yyyy.MM.dd HH:mm:ss" default="$NOW - 1 YEAR" />

Complaint Attributes

Here we have a couple of (optional) additional attributes for thecomplaint popup, that shows up whenever the user entersimpossible values. If these attributes are not set, then some formwide defaults are taken.

More Attributes: Basic Formatting (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

Attribute Description Req. Inher.

complaintThe text in the complaint popup. Multiline textlinefeeds are done with \n. Default is InvalidData

No Yes

complaintTitle The window title for the complaint window. Default is WrongInput

No Yes

editOptionThe button label for the re-edit button. Default is Edit

No Yes

revertOption The button label for the revert button. Default is Revert

No Yes

Form4j 0.5 60 06/10/2004

Page 61: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.2 Datefield

Calendar Popup

Doubleclicking a date field brings up a calendar popup:

The text on the buttons and the title of this popup are customizablethrough the following optional attributes: Attribute Description Req. Inher.

applyTitleThe text for the label on the frame of the popup Default is Select

No Yes

applyOptionThe button text for the apply button on the popup Default is Apply

No Yes

closeOptionThe button text for the close button on the popup Default is Close

No Yes

More Examples with DateField (Source Distro) Form Data Description• date data Date Fields

• troubletracker data Date Fields within Appl.Context

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 61 06/10/2004

Page 62: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.3 FileDialog

5.16.3 FileDialog

An TextField without formatting with file dialog popup action.(See TextField for all nonspecific attributes). Doubleclicking on this field will open a file dialog .

Basic Attributes

Attribute Description Req. Inher.

filterComma separated file extension to filter. The filedia-log will show all directories but only files with thegive extensions.

No No

Examples

A textfield with an associated file dialog on the data /data/fileName/text():

<FileDialog constraints="3,3,l,t" key ="/data/fileName/text()" />

It's possible to use a delegated Action to wire the file dialoglaunching to a separate action button:

<FileDialog constraints="3,3,l,t" name="fileName" key ="/data/fileName/text()" /> <ActionButton constraints="4,3,l,t" name="fileDialogButton" image ="/images/bulb.png" > <DelegateAction delegates="fileName"/> </ActionButton>

Form4j 0.5 62 06/10/2004

Page 63: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.3 FileDialog

A textfield with an associated file dialog /data/imageFileName/text() displaying only file with ajpg,gif,png suffix:

<FileDialog constraints="3,3,l,t" key ="/data/imageFileName/text()" filter ="gif,png,jpg" />

More Examples with FileDialog (Source Distro) Form Data Description• filedialog data Elementary FileDialog

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 63 06/10/2004

Page 64: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.4 Link

5.16.4 Link

A TextField without formatting with browser popup action. (SeeTextField for all nonspecific attributes). Doubleclicking on this field will open a browser using urlPrefix +fieldData as URL.

Basic Attributes

Attribute Description Req. Inher.

urlPrefix A string constant that gets prepended to the fieldsdata to assemble the URL for browser launching

No No

Examples

To launch a HTML-browser onto an url at /data/projectUrl/text():

<Link constraints="3,3,l,t" key ="/data/projectUrl/text()" />

To launch a mailer using the field content as the recipients mailaddress:

<Link constraints="3,3,l,t" key ="/data/email/text()" urlPrefix ="mailTo:" />

It's possible to use a delegated Action to wire the browserlaunching to a separate action button:

<Link constraints="3,3,l,t" name="mailer" key ="/data/email/text()" urlPrefix ="mailTo:" /> <ActionButton constraints="4,3,l,t" name="mailerButton" image ="/images/bulb.png" > <DelegateAction delegates="mailer"/> </ActionButton>

Form4j 0.5 64 06/10/2004

Page 65: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.5 Password

5.16.5 Password

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 )

Attribute Description Req. Inher.

echoChar

The echo character for this field. Instead of visually echoing the typed charactersand thus give away secret passwords, a specificecho character is used instead. Default is *

No No

columns

The visible width of the password field in columns.Column width depends on the selected font and isnot a very accurate measure.This attribute does not limit the maximum textlength, that may be entered. Default is 8

No No

maxLength

The maximum text length for password fields.This limits the length of the text that may be en-tered into this field. Default is 20

No No

Examples

To create a Password Field with a echo character of # at cell 3,3(left,top aligned) use:

<Password constraints="3,3,l,t" key="/data/password/text()" echoChar="#" />

More Examples with Password (Source Distro) Form Data Description• register0 data Registration Form with Password Fields

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 65 06/10/2004

Page 66: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.6 Picture

5.16.6 Picture

In contrast to the display only Image Field, this field allowspresentation and manipulation of a picture which is representedwithin the form's xml data too. When the picture is enabled, doubleclicking will popup a filedialogto assign another picture.

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.

asBase64

When set to true, the picture is represented asbase64 encoded data directly within the forms xmldata. Assigning a new picture will replace its base64representation within the form's data. Default is false

No No

borderControls border painting around the picturePossible values are true|false. Default is true

No No

maxWidththe maximum displayable width of the picture.If the image exceeds this size, a horizontal scroll-bar will become visible.

No No

maxHeightthe maximum displayable height of the picture.If the image exceeds this size, a vertical scrollbarwill become visible.

No No

Examples

To create an editable Picture Field at cell 3,3 (left,top aligned) use:

<Picture constraints="3,3,l,t" key="/data/picture/text()"/>

More Examples with Picture (Source Distro) Form Data Description• picture picture Elementary Picture Fields

• register0 data Registration Form with Picture Field

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 66 06/10/2004

Page 67: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.7 Textarea

5.16.7 Textarea

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.

rows

The visible height of the text field in rows.Row height depends on the selected font and isnot a very accurate measure.This attribute does not limit the maximum textlength, that may be entered. Default is 4

No No

columns

The visible width of the text field in columns.Column width depends on the selected font and isnot a very accurate measure.This attribute does not limit the maximum textlength, that may be entered. Default is 40

No No

maxLength

The maximum text length for text fields.This limits the length of the text that may be en-tered into this field. Default is 255

No No

wrapping

Word wrapping. If set to true, then lines longerthan columns are wrapped.Possible values are true|false. Default is false

No No

Examples

To create a Textarea referencing data at /data/textField/text()with three rows use:

<TextArea constraints="3,3" key="/data/textField/text()" rows="3" />

More Examples with TextArea (Source Distro) Form Data Description• textarea data Elementary TextArea Fields

• troubletracker data TextArea Fields within Appl.Context

• modelDemo data TextArea Fields within Model Demo Form

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 67 06/10/2004

Page 68: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.8 Textfield

5.16.8 Textfield

The textfield is the real workhorse among all the different fields.In form4j we use textfields for input of both - plain strings andnumbers. Validation is possible and done with masks or decimalpatterns (See: Formatting). A specialisation of textfields to enterdates in all conceivable formats is the DateField.

Basic Attributes

More Attributes: Formatting (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

columns

The visible width of the text field in columns.Column width depends on the selected font and isnot a very accurate measure.This attribute does not limit the maximum textlength, that may be entered. Default is 20

No No

maxLength

The maximum text length for text fields.This limits the length of the text that may be en-tered into this field. Default is 72

No No

align

Horizontal alignment for the text within this textfield.Possible values are left|center|right. Default is left

No No

Examples

To create a Textfield referencing data at /data/textField@value atcell 3,3 (left,top aligned) use:

<TextField constraints="3,3,l,t" key="/data/textField@value"/>

Form4j 0.5 68 06/10/2004

Page 69: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.8 Textfield

Formatting Attributes

More Attributes: Basic (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

format

The parametrisation of the JFormatted-TextField formatting capabilities.(For deeper insight of these formatting ca-pabilities, see: How to Use Formatted TextFields)

Mask FormattersTo select a mask formatter, prepend thestandard mask pattern by mask:.

Number FormattersTo select a number formatter, prepend thestandard decimal format pattern by deci-mal:.Formatted numbers are transferredto/from the model without any format-ting.

No No

grouping

Used with decimal:-formats. Controls thegrouping symbol used for formatting.Default is the national language specificsetting for the grouping symbol.

No No

decPoint

Used with decimal:-formats. Controls thedecimal point used for formatting.Default is the national language specificsetting for decimal point.

No No

lessEqualThan Used with decimal:-formats. Establish anupper limit for for entered values.

No No

greaterEqualThanUsed with decimal:-formats. Establish alower limit for for entered values.

No No

Examples

To create a right aligned Textfield with a character mask of #####(allowing max 5 digits) referencing data at /data/numberWith5Digits@value at cell 3,3 (left,top aligned) use:

<TextField constraints="3,3,l,t" key="/data/numberWith5Digits@value" align="right" format="mask:#####" />

To create a right aligned Textfield with a decimal pattern of#,##0.00 referencing data at /data/decimal@value at cell 3,3(left,top aligned) use:

<TextField constraints="3,3,l,t" key="/data/decimal@value"

Form4j 0.5 69 06/10/2004

Page 70: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.16.8 Textfield

align="right" format="decimal:#,##0.00" />

(The grouping and decimal point symbols are taken from thenational language setting of the current platform).To force certain grouping and decimal point symbols, the previousexample may be extended by the resp. attributes:

<TextField constraints="3,3,l,t" key="/data/decimal@value" align="right" format="decimal:#,##0.00" grouping="'" decPoint="." />

Complaint Attributes

Here we have a couple of (optional) additional attributes for thecomplaint popup, that shows up whenever the user entersimpossible values. If these attributes are not set, then some formwide defaults are taken.

More Attributes: Basic Formatting (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

complaintThe text in the complaint popup. Multiline textlinefeeds are done with \n. Default is InvalidData

No Yes

complaintTitle The window title for the complaint window. Default is WrongInput

No Yes

editOptionThe button label for the re-edit button. Default is Edit

No Yes

revertOption The button label for the revert button. Default is Revert

No Yes

More Examples with TextField (Source Distro) Form Data Description• formatting data Several formatting examples

• troubletracker data TextFields within Appl.Context

• modelDemo data TextFields within Model Demo Form

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 70 06/10/2004

Page 71: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.17 Display Fields

5.17 Display Fields

The field from this section are display only and not (directly)connected to the forms xml data.

5.17.1 Calculated

A field whose contents get calculated from other form data.Very similiar to the TextField, but of course non-editable. (SeeTextField for all nonspecific attributes).

Basic Attributes

(For additional attributes to control text formatting see FormattingAttributes) More Attributes: (See: 5.6 Common Attributes, page: 27 ) Attribute Description Req. Inher.

expr An arithmetical XPath expression on the forms xml-data

No No

Examples

To create a calculated field multiplying data at /data/textField@value by 2 at cell 3,3 (left,top aligned) use:

<Calculated constraints="3,3,l,t" expr="/data/textField@value * 2" />

The calculated field looks like any normal (but of course read only)Text Field and the same formatting attributes apply here as well.

More Examples with Calculated (Source Distro) Form Data Description• calculated data Elementary TextArea Fields

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 71 06/10/2004

Page 72: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.17.2 Filler

5.17.2 Filler

Fillers are invisible elements to fiddle with the form geometry.The main application for Fillers is in conditional subforms toenforce constant geometries. The sizes of conditional form areasmay change when the sizes of the components are different. Byadding filler components, this behavior may out-tricked.Fillers are somewhat similar to the old HTML-trick to have atransparent images with specific size to influence HTML tablelayouts.

Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 ) Attribute Description Req. Inher.

widththe maximum displayable width of the image.If the image exceeds this size, a horizontal scrollbarwill become visible.

No No

heightthe maximum displayable height of the image.If the image exceeds this size, a vertical scrollbarwill become visible.

No No

Examples

To create a Filler field consuming 500x1 pixels, spanning therectangular area from cell 3,3 to cell 9,3 use:

<Filler constraints="3,3,9,3" width="500" height="1" />

More Examples with Filler (Source Distro) Form Data Description• box data Exhaustive Example with boxed buttons

• enum data Enumeration Examples

• tab data Tab Widget Examples

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 72 06/10/2004

Page 73: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.17.3 Label

5.17.3 Label

Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.constraints The TableLayout constraints for this field. Yes No

icon an image filename or url for the label's icon No No

textThe text of the label.Multiline labels are possible using \n as linefeed.

No No

borderControls border painting around the label.Possible values are true|false. Default is true.

No No

Examples

To create a Label form field with the text yyyy.MM.dd\nlong on twolines, at cell 3,3 (left,top aligned) use:

<Label constraints="3,3,l,t" text="yyyy.MM.dd\nlong"/>

Form4j 0.5 73 06/10/2004

Page 74: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.17.4 Image

5.17.4 Image

Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.image an image filename or url for the label's icon Yes No

maxWidththe maximum displayable width of the image.If the image exceeds this size, a horizontal scroll-bar will become visible.

No No

maxHeightthe maximum displayable height of the image.If the image exceeds this size, a vertical scrollbarwill become visible.

No No

borderControls border painting around the image.Possible values are true|false. Default is false.

No No

Examples

To create an image field an let the size of the image govern thefields size use:

<Image constraints="3,3" image="/images/bulb.gif" maxWidth="750" maxHeight="450" />

To create a Image form field with a maximum visible image size of750x450 pixels, spanning the rectangular area from cell 3,3 to cell9,9 use:

<Image constraints="3,3,9,9" image="doc/uml/ClassDiag_FieldsTopLayer.gif" maxWidth="750" maxHeight="450" />

Form4j 0.5 74 06/10/2004

Page 75: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18 Node Data Fields

5.18 Node Data Fields

Besides being regular data fields with key and model connection -node data fields operate on several nodes of the form's xml dataat once.

Here we clearly leave the realm of standard forms where one formcontrol usually relates to one particle (attribute or text node) of thexml data. The task to shoulder to allow form controls to operate ongeneral xml nodes is much bigger and harder to describe in adeclarative way than the ordinary 'flat' form field behavior. Not only content but structure must be manipulated by node datafields. The potential magnitude of declarative elements becomes visible,when one considers all the possible varieties of a tree control withits models,listeners,renderers and editors. The present release (form4j 0.5) only offers a preliminary collectionof node data fields and enhancements are clearly to be expectedhere.

5.18.1 HTML Area

One evident way to give structural access to xml data is to presentthe xml as editable text: A HTML Area is a text area capable to render HTML data. If theHTML Area is editable (enabled) then focusing the area with themouse will show the unrendered HTML code for editing. Loosing focus will trigger the necessary model changes and rendersthe modified HTML content again.

Syntax errors

The downside of so much flexibility are the potential syntacticerrors when editing html content as text. Before data is transferred back to the model, it is parsed. Wheneversyntactic errors are found, the transfer is cancelled, the erroneoustext is marked and the syntax error message from the xml parser isshown as tooltip:

Probably this field type should be used in its non-editableincarnation (enabledWhen="false"), because there are better

Form4j 0.5 75 06/10/2004

Page 76: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.1 HTML Area

alternatives for heavy duty HTML Editing. But the possibility torender HTML fragments within a form might be useful.

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.

widththe maximum displayable width of the html areaIf the html content exceeds this size, the lines arewrapped.

No No

heightthe maximum displayable height of the html areaIf the html area vertically exceeds this size, a verti-cal scrollbar will become visible.

No No

borderControls border painting around the html area.Possible values are true|false. Default is true

No No

Examples

To create a HTMLArea referencing data at /data/htmlNodes/* atcell 3,3 (left,top aligned) use:

<HTMLArea constraints="3,3" key="/data/htmlNodes/*"/>

The illustration shows both faces of a HTMLArea: focused: editableon left side, out of focus: rendered HTML on the right side.

More Examples with HTMLArea (Source Distro) Form Data Description• htmlAreas data Elementary HTML Areas

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 76 06/10/2004

Page 77: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.2 MultiChoice

5.18.2 MultiChoice

The multi choice field operates on a set of structurally equal xmlnodes and is able to add and remove nodes.

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.

keyPathpoints to the primary key text/attribute relative tonodes as described in the key attribute.

No No

rows

The visible height of the text field in rows.Row height depends on the selected font and is not avery accurate measure.

Default is 6

No No

columns

The visible width of the text field in columns.Column width depends on the selected font and isnot a very accurate measure.This attribute does not limit the maximum textlength, that may be entered. Default is 10

No No

Examples

The goal for this example a field capable of selecting multiplecountries out of an external xml based list of available countries. The form's xml data element should contain the nodes of theselected countries:

<multichoice"> <country iso3="ARE" name="Abu Dhabi"/> <country iso3="PNG" name="Admiralty Islands"/> <!-- ... --> </multichoice>

The list of available countries looks different:

<countries> <country key='1' iso3='ARE' name='Abu Dhabi' active='true'/> <!-- ... --> <country key='257' iso3='ZWE' name='Zimbabwe' active='true'/> </countries>

Form4j 0.5 77 06/10/2004

Page 78: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.2 MultiChoice

The potential set of nodes is declared by an Enumeration in muchthe same way as the Choice Data Fields were declared. Spoken in database terminology, we have a foreign key relationship between the fields xml-data and the potential set of nodes. Forthe insertion of new nodes we must describe how both xmlfragments are to be connected. This is done using a data adapterdescriptor:

<DataAdapterDescriptor url ="file:samples/data/countries.data.xml" foreignKeyTemplate="/countries/country[@iso3={0}]" localKeyTemplate ="/multichoice/country[@iso3={0}]" />

This example establishes a foreign key relation using some iso3attribute of country nodes. When the unselected country 'Antarctica' with ISO-Code ATA isselected then the key templates {0} are resolved by ATA and theforeign key becomes:

/multichoice/country[@iso3='ATA']

The data adapter then retrieves the node using this key and insertsit into the form's xml data.

This richness of functionality needs some more declarative effortthan a simple text formfield and is expressed within a formdefinition:

<MultiChoice constraints="1, 1, l, t" key="/multichoice" keyPath="country/@iso3" rows="20" columns="20" > <EnumDescriptor url="file:samples/data/countries.data.xml" idPath ="/countries/country/@iso3" namePath ="/countries/country/@name" activePath="/countries/country/@active" /> <DataAdapterDescriptor url ="file:samples/data/countries.data.xml" foreignKeyTemplate="/countries/country[@iso3={0}]" localKeyTemplate ="/multichoice/country[@iso3={0}]" /> </MultiChoice>

Form4j 0.5 78 06/10/2004

Page 79: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.2 MultiChoice

More Examples with MultiChoice (Source Distro) Form Data Description• multichoice data Elementary MultiChoice Fields

• troubletracker data MultiChoice Field within Appl.Context

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 79 06/10/2004

Page 80: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.2 MultiChoice

Form4j 0.5 80 06/10/2004

Page 81: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

5.18.3 Table

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.

width

the maximum displayable width of the ta-ble If the table horizontally exceeds thissize and autoResize='false', a horizon-tal scrollbar will become visible.

No No

height

the maximum displayable height of thetableIf the table vertically exceeds this size, avertical scrollbar will become visible.

No No

sort

When set to true the table columns be-come sortable.This table wide attribute may be overri-den for individual columns in thecolumns definition. Default is true

No No

autoResize

When set to true the table columns areautosized and the table will fit within thewidth/height area.Otherwise a scrollbar will appear when-ever the width of the table exceedes thespecified width. Default is false

No No

border

Controls border painting around the ta-ble area.Possible values are true|false. Default is true

No No

defaultThe default value for this field.Should be an xpath pointing to a nodewith table rows.

No No

headerBackground

The background color for the table head-ers.(See the colors section) Default is the background of the table.

No Yes

headerForeground

The foreground color for the table head-ers.(See the colors section) Default is the foreground of the table.

No Yes

headerFontThe font for the table headers.(See the fonts section) Default is the font of the table.

No Yes

Form4j 0.5 81 06/10/2004

Page 82: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

Simple example

For the following examples we use the following XML data:

<table1> <row> <Decimal0>12.0</Decimal0> <Date0>2001.12.03 18:22:33</Date0> <Date1>1076245368828<Date1> <Bool0>Yes</Bool0> <Bool1>true</Bool1> </row> <row> ... more rows </table1>

To create a Table referencing the rows for the above data at cell 3,3use:

<Table constraints="3, 3, l, t" key="/table1/*"> <columns> <column label="Decimal0" path ="Decimal0/text()"/> <column label="Date0" path ="Date0/text()"/> <column label="Date1" path ="Date1/text()"/> <column label="Bool0" path ="Bool0/text()"/> <column label="Bool1" path ="Bool1/text()"/> </columns< </Table>

Column Attributes

For each table column declaration the following attributes arepossible Attribute Description Req. Inher.

label The TableLayout constraints for this field. Default is created from path

No No

pathThe XPath for this column.relative to the table data obtained by the table's keyattribute.

Yes No

widthrelative (%) or absolute width (pixels) for this tablecolumn By default all columns have the same width

No No

tip The tooltip for this column header.Multiline tooltips are possible using \n as linefeed.

No No

Form4j 0.5 82 06/10/2004

Page 83: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

Cell Renderers

Unfortunately each and every column may have different cellrenderers and editors. The first example doesnt uses thatcomplexity and all columns are just rendered as they were plainstrings. To refine cell appearance, a different Cell Renderer may beassigned to each column declaration.

Checkbox Cell Renderers Similar to the checkbox field, the check box renderer allowsspecification of true/false values, to control what data value makesthe checkbox selected.

<cellRenderer class="org.form4j.form.field.nodedata.table.CheckBoxCellRenderer" > <cellParms trueValue="Yes" falseValue="No"/> </cellRenderer>

Date Cell Renderer

<cellRenderer class="org.form4j.form.field.nodedata.table.DateCellRenderer" > <cellParms format="date:yyyy.MM.dd HH:mm:ss" dataFormat="yyyy.MM.dd HH:mm:ss" align="right" /> </cellRenderer>

(The format options are the same as for the date field).

Decimal Cell Renderer

<cellRenderer class="org.form4j.form.field.nodedata.table.DecimalCellRenderer" > <cellParms format="decimal:#,##0.00" align="right" grouping="'" decPoint="." /> </cellRenderer>

(The format options are the same as for the text field).However, you must only declare such a cell renderer once and giveit a unique name attribute. Afterwards you may re-use the same

Form4j 0.5 83 06/10/2004

Page 84: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

renderer by just referencing its name:

<cellRenderer name="decimal"/>

Enumeration Cell Renderer Sometimes you don't want to display the plain value in the table cell- but rather the result of table look. (Code -> Name). Such enumerations were also used for choice fields and a cellrenderer becomes an enumeration cell renderer just by adding theEnumDescriptor to its declaration:

<cellRenderer name="countryCellRenderer"> <cellParms align="right"/> <EnumDescriptor url="file:samples/data/countries.data.xml" idPath ="/countries/country/@iso3" namePath ="/countries/country/@name" activePath="/countries/country/@active" /> </cellRenderer>

Conditional Cell Renderer When you need to select specific renderers for each row -depending on some row data - you might consider conditional cellrendering. The idea is to express your conditions as XPath expression on therow data and assign a specific renderer declaration for each of yourconditions.

<conditionalCellRenderer>

<!-- for @sex = 'female' use a female checkbox --> <rendererCondition xpathExpr="@sex = 'female'"> <cellRenderer name="femaleCheckbox"/> </rendererCondition>

<!-- for @sex = 'male' use a male checkbox --> <rendererCondition xpathExpr="@sex = 'male'"> <cellRenderer name="maleCheckbox"/> </rendererCondition>

</conditionalCellRenderer>

While the example is not really serious - be sure: you will encountersituations where your data representation and business necessitiesjust call for conditional table cell rendering. At last this one wasn'tinvented out of pure joy! Custom Cell Renderer

Form4j 0.5 84 06/10/2004

Page 85: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

When all above fails, you may build your own cell renderers,implementing of course the swingjavax.swing.table.TableCellRenderer interface. Theorg.form4j.form.field.nodedata.table.DefaultTextFieldCellRenderermay serve as example, to see how the form definition parametersare passed to cell renderers.

<cellRenderer name="myCustomRenderer" class="myForm4j.renderers.MyCustomRenderer" > <cellParms ......../> </cellRenderer>

Cell Editors

A Cell Editor may be assigned to a column declaration for editablecolumns. It's very similar to the declaration of cell renderers.

Date Cell Editor

<cellEditor name="date0" class="org.form4j.form.field.nodedata.table.DateCellEditor" > <cellParms format="date:yyyy.MM.dd HH:mm:ss" dataFormat="yyyy.MM.dd HH:mm:ss" align="right" /> </cellEditor>

(The format options are the same as for the date field).

Decimal Cell Editor

<cellEditor name="decimal" class="org.form4j.form.field.nodedata.table.DecimalCellEditor" > <cellParms format="decimal:#,##0.00" align="right" grouping="'" decPoint="." complaint="The value must... complaintTitle="Invalid Entry" editOption="Edit" revertOption="Revert" /> </cellEditor>

(The format options are the same as for the text field).But here we have a couple of (optional) additional attributes for thecomplaint popup, that shows up whenever the user enters

Form4j 0.5 85 06/10/2004

Page 86: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

impossible values. If these attributes are neither set then some formwide defaults are taken.However, you must only declare such a cell renderer once and giveit a unique name attribute. Afterwards you may re-use the samerenderer by just referencing its name:

<cellEditor name="decimal"/>

Custom Cell Editors When all above fails, you may build your own cell editors, extendingof course the swing javax.swing.table.DefaultCellEditor interface. The org.form4j.form.field.nodedata.table.DefaultCellEditor mayserve as example, to see how the form definition parameters arepassed to cell editors

<cellEditor name="myCustomEditor" class="myForm4j.renderers.MyCustomEditor" > <cellParms ......../> </cellEditor>

Re-Use of Renderers/Editors

When you need a specific renderer/editor several times within thesame form definition, it may be named just once:

<cellRenderer name="myDecimal" class="org.form4j.form.field.nodedata.table.DecimalCellRenderer" > <!-- full declaration --> </cellRenderer>

Afterwards you may re-use the same renderer by just referencingits name:

<cellRenderer name="myDecimal"/>

Form4j 0.5 86 06/10/2004

Page 87: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

Refined Example with Renderers/Editors

Formdefinition-wise the first example refined with renderers andeditors becomes rather huge:

<Table constraints="3,3" key="/data/table1" width="300" height="100" > <columns> <column label="Dec0" width="150" path ="Decimal0/text()"> <cellRenderer name="decimal" class="org.form4j.form.field.nodedata.table.DecimalCellRenderer" > <cellParms format="decimal:#,##0.00" align="right" grouping="'" decPoint="." /> </cellRenderer> <cellEditor name="decimal" class="org.form4j.form.field.nodedata.table.DecimalCellEditor" > <cellParms format="decimal:#,##0.00" align="right" grouping="'" decPoint="." /> </cellEditor> </column> <column label="Date0" width="150" path ="Date0/text()"> <cellRenderer name="date0" class="org.form4j.form.field.nodedata.table.DateCellRenderer"> <cellParms format="date:yyyy.MM.dd HH:mm:ss" dataFormat="yyyy.MM.dd HH:mm:ss" align="right" grouping="'" decPoint="." /> </cellRenderer> <cellEditor name="date0" class="org.form4j.form.field.nodedata.table.DateCellEditor"> <cellParms format="date:yyyy.MM.dd HH:mm:ss" dataFormat="yyyy.MM.dd HH:mm:ss" align="right" grouping="'" decPoint="." /> </cellEditor> </column> <column label="Date1" width="150" path ="Date1/text()"> <cellRenderer name="date1" class="org.form4j.form.field.nodedata.table.DateCellRenderer"> <cellParms format="date:yyyy.MM.dd HH:mm:ss" dataFormat="long" align="right"/> </cellRenderer> <cellEditor name="date1" class="org.form4j.form.field.nodedata.table.DateCellEditor"> <cellParms format="date:yyyy.MM.dd HH:mm:ss" dataFormat="long" align="right" /> </cellEditor> </column>

Form4j 0.5 87 06/10/2004

Page 88: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

<column label="Bool0" width="50" path ="Bool0/text()"> <cellRenderer name="bool0" class="org.form4j.form.field.nodedata.table.CheckBoxCellRenderer"> <cellParms trueValue="Yes" falseValue="No"/> </cellRenderer> <cellEditor name="bool0" class="org.form4j.form.field.nodedata.table.CheckBoxCellEditor"> <cellParms trueValue="Yes" falseValue="No"/> </cellEditor> </column> <column label="Bool1" width="50" path ="Bool1/text()"> <cellRenderer name="bool1" class="org.form4j.form.field.nodedata.table.CheckBoxCellRenderer"> <cellParms trueValue="true" falseValue="false"/> </cellRenderer> <cellEditor name="bool1" class="org.form4j.form.field.nodedata.table.CheckBoxCellEditor"> <cellParms trueValue="true" falseValue="false"/> </cellEditor> </column> </columns> </Table>

Insert/Remove/Edit: Row level table operations

Whereas the above renderers/editors operate on table cell level, weneed row level operations too:

• Insert Either insert a new row with empty cells or retrieve a rowfrom external data through a DataAdapter.

• Remove Remove selected row(s) locally within the form's xml data.Eventually simultaneous remote removal may be achievedwith a a DataAdapter.

• Edit Popup an external editor (which may be another form4j in amodal window) to edit in more detail. This again needs aDataAdapter plus an external editor class.

Within the Table definition element, row level operations are(optionally) declared using the TableOpRestrictions element:

<TableOpRestrictions> <tableRemovable srcExpr="*" confirmInfoXPath="concat(@key,' ',Field0/text())"/> <tableEditable srcExpr="*" editor="org.form4j.form.field.nodedata.table.external.DefaultEditor" /> <tableInsertable keyProvider="org.form4j.form.field.nodedata.table.external.DefaultKeyProvider"/> </TableOpRestrictions>

Triggering Row Level Operations Row level operations are not always enabled but depend on some

Form4j 0.5 88 06/10/2004

Page 89: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

condition. They may triggered in several ways. The following tableshows these condition and triggering fashions: Operation Condition Triggering

Insert<tableInsertable.../> is de-clared

• Enter Key(KeyEvent.VK_INSERT)

• Selecting Insert from Pop-up Menu

• Action Button with Dele-gated Action and action-Command='insert'.

Edit<tableEditable.../> is de-clared and Single Row is Select-ed

• DoubleClick on Row • Enter Key

(KeyEvent.VK_ENTER) • Selecting Edit from Popup

Menu • Action Button with Dele-

gated Action and action-Command='edit'.

Remove<tableRemovable.../> is de-clared and One or Several Rowsare Selected

• Enter Key(KeyEvent.VK_DELETE)

• Selecting Edit from PopupMenu

• Action Button with Dele-gated Action and action-Command='remove'.

Remove Row To describe row removal, use the tableRemovable element withinthe TableOpRestrictions element. It has the following attributes: Attribute Description Req. Inher.

srcExpr

an XPath expression on a row. When theexpression holds, the specific row is re-movable. Default is *, meaning all rows are remov-able.

No No

confirmInfoXPath

When removing rows, the user is promptedwith a confirmation over the rows todelete. Within this confirmation the victimrows may be described using an XPath ex-pression over this row's data. Typically an XPath concat takes valuefrom the row to build a string to describethe row. Default is to show the selected keys in theprompt.

No No

Form4j 0.5 89 06/10/2004

Page 90: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.3 Table

Edit Row In constrast to cell level editing, editing whole rows means to popupanother (modal) form for externally editing the current row in fullepic details. To describe row editing use the tableEditable element within theTableOpRestrictions element. It has the following attributes: Attribute Description Req. Inher.

srcExpr

an XPath expression on a row. When the expres-sion holds, the specific row is externally editable.

Default is *, meaning all rows are externally ed-itable.

No No

editor

The class of the editor to pop up for row editing. Default is org.form4j.form.field.nodedata.ta-ble.external.DefaultEditor, which is just ahook for the implementation of specific row leveleditors.

No No

Insert Row To describe row insertion, use the tableInsertable element withinthe TableOpRestrictions element. It has the following attributes: Attribute Description Req. Inher.

keyProvider

A popup that delivers the foreign row key to beinserted. When the keyprovider popup closes,the key is handed over to the data adapter forexternal data retrieval. Default is org.form4j.form.field.nodeda-ta.table.external.DefaultKeyProvider

Yes No

More Examples with Table (Source Distro) Form Data Description• table data Elementary Tables

(Launch example with: ant -Dname=Form launch)

5.18.4

Form4j 0.5 90 06/10/2004

Page 91: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

5.18.5 Tree

The tree is a frequently used element in user interfaces. Besidesbeing a selector for hierarchically structured data, it allows alsothe modification of the data structure by insert/delete and evendrag/drop operations. This much versatility comes at the price of a plethora ofconfiguration options. Therefore we start in this section with asimple tree and add more and more functionality. In parallel thesame example gets incrementally refined.

Example Data

The ongoing example always uses this XML data: <?xml version="1.0" encoding="ISO-8859-1"?><data> <tree selected=""> <node name="Colors"> <leaf name="Blue">blue</leaf> <leaf name="Violet">violet</leaf> <leaf name="Red">red</leaf> <leaf name="Yellow">yellow</leaf> </node> <node name="MoreColors"> <leaf name="Green">green</leaf> </node> <node name="sports"> <leaf name="Basketball">basketball</leaf> <leaf name="Soccer">soccer</leaf> <leaf name="Football">football</leaf> <leaf name="Hockey">hockey</leaf> </node> <node name="food"> <leaf name="Hot Dogs">hot dogs</leaf> <leaf name="Pizza">pizza</leaf> <leaf name="Ravioli">ravioli</leaf> <leaf name="Bananas">bananas</leaf> </node> </tree> <templates> <leaf name="NewColor">NewColor</leaf> </templates></data>

Form4j 0.5 91 06/10/2004

Page 92: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Basic Attributes

More Attributes: (See: 5.6 Common Attributes, page: 27 and 5.7 Data At - tributes, page: 28 ) Attribute Description Req. Inher.

dragDrop

The tree allows unrestricted drag/drop of tree nodeswhen this attribute is set to true. In most case the drag/drop must be restricted usingDrag/Drop restrictions. Default is false

No No

width

the maximum displayable width of the tree If thetree horizontally exceeds this size andautoResize='false', a horizontal scrollbar will be-come visible.

No No

heightthe maximum displayable height of the treeIf the tree vertically exceeds this size, a verticalscrollbar will become visible.

No No

borderControls border painting around the tree area.Possible values are true|false. Default is true

No No

defaultThe default value for this field.Should be an xpath pointing to a node with treerows.

No No

Simple example

To create a Tree referencing the above data at cell 3,3 use:

<Tree constraints="3, 3, l, t" key="/data/tree"> background="white" width="150" height="150" name ="Tree_Name" />

Everything is in default fashion: no special icons, no drag/dropfunctionality - just a plain tree. The labels of the tree cells are created also in a default mode: Whenthe corresponding tree node in the data has an attribute name, thanthe value of this attribute is used as tree cell label. Otherwise theXML element name is taken.

Form4j 0.5 92 06/10/2004

Page 93: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Cell Renderers

Using Cell Renderers it is possible to assign specific icons to treecells. Using an enclosing <cellRenderer> element, for each different cell-icon an <cellIcon> element is declared. An XPath expression thenselects which icon is used for which tree node. In a similary fashion <cellName> Elements may be used to influencethe way how tree nodes are labelled.

Cell Renderer Attributes

More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req Inher.

classcellRenderer

The cell renderer class to render the tree cell. Use either org.form4j.form.field.nodeda-ta.tree.DOMTreeNodeRenderer or your ownsubclass of that.

Yes No

namecellRenderer

A renderer may be named and re-used in othertree definitions with the same form definition. Declare the cell renderer once fully. Later useonly: <cellRenderer name="MyName"/>!

No No

xpathExprcellIcon,cell-Name

Selects this cell icon using an XPath Expres-sion.

Yes No

imagecellIcon

The icon image to be used when the xpath ex-pression holds for a given tree node.

Yes No

nameXPathExprcellName

A XPath expression to label the tree cell withdata found in the node's data. This is usually an XPath concat() function like:

nameXPathExpr="concat(FirstName/text(),'',LastName/text())"

Yes No

Form4j 0.5 93 06/10/2004

Page 94: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Example enriched with Cell Renderers

To create our example tree - further enriched with specific cell icons- use:

<Tree constraints="3, 3, l, t" key="/data/tree"> background="white" width="150" height="150" name ="Tree_Name" > <cellRenderer name="renderer0" class="org.form4j.form.field.nodedata.tree.DOMTreeNodeRenderer" > <cellIcon image="samples/images/tree.colors.gif" xpathExpr="@name = 'Colors' or @name = 'MoreColors'" /> <cellIcon image="samples/images/tree.blue.gif" xpathExpr="name() = 'leaf' and text() = 'blue'" /> <!-- more cellIcon for the other colors --> </cellRenderer> <Tree/>

Form4j 0.5 94 06/10/2004

Page 95: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Drag/Drop Restrictions

To allow drag/drop operations on your tree you need first to set thedragDrop attribute to true. Doing so you'll get unrestricteddrag/drop possibilities. Our example tree has several flavours of nodes and folders and ismust be possible to suppress drop of 'sports' into 'color' folders. Using an enclosing <dragDropRestrictions> element, for eachdifferent drag/drop restriction a <dragable> element is declared. Itdefines valid drag sources and drop targets. Furthermore it controlswhether a drop is done asChild of the target node. Two XPath expressions are used here to select among possible dragsources and drop targets.

Dragable Attributes

More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

srcExpr

Declares a valid drag source node using an XPathexpression on the tree's data. Its perfectly OK to have several dragable elementswith the same srcExpr, but with different dstExpr'sto express drag/drop's from the same source to dif-ferent targets.

Yes No

dstExpr

Declares a valid drop target node using an XPathexpression on the tree's data. Its perfectly OK to have several dragable elementswith the same srcExpr, but with different dstExpr'sto express drag/drop's from the same source to dif-ferent targets.

Yes No

asChildWhen true, the dragged element is dropped into thedrag target as child node. Other wise it is droppedas sibling (same tree level) of the drag target.

Yes No

Form4j 0.5 95 06/10/2004

Page 96: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Example enriched with Drag/Drop

To create our example tree - further enriched with meaningfuldrag/drop restrictions - use:

<Tree constraints="3, 3, l, t" key="/data/tree"> background="white" width="150" height="150" name ="Tree_Name" dragDrop="true" > <cellRenderer name="renderer0"/> <dragDropRestrictions> <dragable srcExpr="../@name = 'Colors'" dstExpr="@name = 'MoreColors'" asChild="true" /> <dragable srcExpr="../@name = 'Colors'" dstExpr="../@name = 'MoreColors'" asChild="false" /> <dragable srcExpr="../@name = 'Colors'" dstExpr="@name = 'Colors'" asChild="true" /> <dragable srcExpr="../@name = 'Colors'" dstExpr="../@name = 'Colors'" asChild="false" /> <!-- more dragable's --> </dragDropRestrictions> <Tree/>

Form4j 0.5 96 06/10/2004

Page 97: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Insert/Remove/Copy/Paste

A further group of tree operations are usually wired to a popupmenu: Insert, Remove, Copy, Paste, etc. We use a insertRemoveRestrictions inside a Tree Fielddeclaration to enable and configure such operations on tree fieldstoo.

Remove Attributes To allow tree nodes to be removed, add one or several removableElement(s) inside insertRemoveRestrictions. Its attributes are: More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

srcExpr

Declares removable nodes using an XPathexpression on the tree's data. Its perfectly OK to have several removableelements with different srcExpr's to ex-press many different sets of removablenodes.

Yes No

remove1Message

The message to appear in the remove con-firm popup for removal of a single treenode. This message attribute is processedthrough MessageFormat with the name(s)of the tree nodes as single argument. Soyou may specify something like Reallyremove {0}? here.Default is RemoveElement

No Yes

removeNMessage

The message to appear in the remove con-firm popup for removal of a multiple treenodes. This message attribute is processedthrough MessageFormat with the name(s)of the tree nodes as single argument. Soyou may specify something like Reallyremove {0}? here.Default is RemoveElements

No Yes

removeTitleThe title of the confirm popup when re-moval needs to be ackknowledged. Default is RemoveConfirmation

No Yes

removeOption

The button lable of the confirm popupwhen removal needs to be ackknowledged.

Default is Remove

No Yes

Form4j 0.5 97 06/10/2004

Page 98: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 )

confirmInfoXPath

When removing node, the user is promptedwith a confirmation over the nodes todelete. Within this confirmation the victimnodes may be described using an XPathexpression over this nodes's data. Typically an XPath concat takes valuefrom the node to build a string to describethe row. Default is to show the selected keys in theprompt.

Yes No

Insert Attributes To allow tree nodes to be inserted, add one or several insertableElement(s) inside insertRemoveRestrictions. Its attributes are: More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

srcExpr Declares by an XPath expression what target nodeswill accept node inserts. data.

Yes No

template

A template node to clone for insertion. The idea is that you have a template node some-where in your xml form data for inserts. Pointing tothis template and issueing an insert operation willcause a clone of the template node to be inserted atthe target node.

Yes No

Copy Attributes To allow tree nodes to be copied, add one or several copyableElement(s) inside insertRemoveRestrictions. Its attributes are: More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

srcExprDeclares by an XPath expression what source nodesmay be copied.

Yes No

Form4j 0.5 98 06/10/2004

Page 99: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Paste Attributes To allow copied tree nodes to be pasted onto some target node, addone or several pasteable Element(s) inside ainsertRemoveRestrictions. Its attributes are: More Attributes: Base (See: 5.6 Common Attributes, page: 27 and 5.7 Data Attributes, page: 28 ) Attribute Description Req. Inher.

srcExpr

Declares a valid paste source node using an XPathexpression on the tree's data. Its perfectly OK to have several pasteable elementswith the same srcExpr, but with different dstExpr'sto express copy/paste's from the same source to dif-ferent targets.

Yes No

dstExpr

Declares a valid paste target node using an XPathexpression on the tree's data. Its perfectly OK to have several pasteable elementswith the same srcExpr, but with different dstExpr'sto express copy/paste's from the same source to dif-ferent targets.

Yes No

asChildWhen true, the copied element is pasted into thetarget node as child node. Other wise it is pasted assibling (same tree level) of the target node.

Yes No

Form4j 0.5 99 06/10/2004

Page 100: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

5 Form Definition 5.18.5 Tree

Example enriched with Insert/Remove

To create our example tree - further enriched insert / remove /copy / paste operations - use:

<Tree constraints="3, 3, l, t" key="/data/tree"> background="white" width="150" height="150" name ="Tree_Name" dragDrop="true" > <cellRenderer name="renderer0"/>

<insertRemoveRestrictions> <removable srcExpr="name() = 'leaf'" confirmInfoXPath="text()" remove1Message="Really remove {0}?" removeNMessage="Really remove {0}?" /> <insertable srcExpr="@name = 'Colors'" template="/data/templates/leaf[@name = 'NewColor']" />

<copyable srcExpr="../@name = 'Colors'"/> <pasteable srcExpr="../@name = 'Colors'" dstExpr="../@name = 'Colors'" asChild="false" /> <pasteable srcExpr="../@name = 'Colors'" dstExpr="@name = 'Colors'" asChild="true" /> </insertRemoveRestrictions> <Tree/>

More Examples with Tree (Source Distro) Form Data Description• tree data Elementary Trees

• treeRegister0 data Trees and Tables in Tandem

(Launch example with: ant -Dname=Form launch)

Form4j 0.5 100 06/10/2004

Page 101: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

6 Roadmap 6 Roadmap

6 RoadmapPlanned Activ-ity

Description Resp. ReleaseDate

Keystroke As-signment

For all data fields allow keystroke assign-ments. Keystrokes may trigger same ac-tions as ActionButtons.

cjuon 2004.07

Pre/Post FieldScripting

All data fields may trigger pre/postscripts together with the already existingpre/post mappings. BSFActionListeners may be refactored togeneralize scripting.

cjuon 2004.07

Field Traversal Completion of partial traversal imple-mentation

cjuon 2004.07

Field State Vi-sualisation

Improve Field State Visualisation. Atleast the following states must be visual-izable: empty/nonempty, focused/unfo-cused, error, mandatory/optional Difficulty: Find significant yet unobtru-sive ways to visualize that many statesfor all data fields!

Tab-Field Reim-plementation

Improved Tab Implementation. Eliminateformatting troubles with current TabField.

Form Checker Refinements:

• border title layout check • scripting: syntax and availability

of per-language necessary exter-nal jars

cjuon 2004.07

form4j as Applet

Additional FieldControls

• Extensible Choice • Shifter • ColorPicker

FormDef Gener-ators

Generators to generate standard formdefinitions automatically:

• from XMLEncoded Java Beans • from JDBC Resultset Metadata • from EJB Entity Beans (either

through reflection or from the de-ployment descriptor)

MasterDetailApplication

Implementation of the MasterDetail func-tionality with JTable and form4j What as-sumptions on the data sources?JDBC,JDO,J2EE backends?

Form Painter As swing application or as Eclipse plugin

Form4j 0.5 101 06/10/2004

Page 102: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

7 License 7 License

7 License GNU LESSER GENERAL PUBLIC LICENSE

Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.

59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Everyone is permitted to copy and distribute verbatim copies

of this license document, but changing it is not allowed.

Form4j 0.5 102 06/10/2004

Page 103: form4j 0.5 form4j Manualform4j.sourceforge.net/doc/manual/form4jManual.pdf · 2004-06-06 · 1 Intro 1 Intro 1 Intro 1.1 Purpose form4j is a java package to provide easy interactive

8 Credits 8 Credits

8 Creditsby

• Christian Juon ([email protected]) • Hansueli Bosshard ([email protected]) • Julian Kaeser ([email protected])

Form4j 0.5 103 06/10/2004