7.1. What is X-component?
From compiled X-definitions, you can generate Java source code of
X-components. The classes of X-components contain getters and setters
so can this way access data declared in the model. Let's have a simple
X-definition:
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Test" root="Book" >
<Book ISBN="int(100000000, 9999999999);"
year = "gYear();"
title = "string();" >
<author xd:script="occurs *"> string(); </author>
</Book>
<xd:component>
%class test.book.Book %link Test#Book;
</xd:component>
</xd:def>
Note in the example was declared component "Book", which will be generated to
the package "test.book".
It contains the following getters and setters in the Java source code:
package test.book;
public class Book implements org.xdef.component.XComponent{
public String getISBN() {...}
public setISBN(String x) {...}
public org.xdef.sys.SDatetime getyear() {...}
public setyear(org.xdef.sys.SDatetime x) {...}
public String gettitle() {...}
public void settitle(String x) {...}
public java.util.List<Book.author> listOfauthor() {...}
public void addauthor(Book.author x) {...}
...