|
In order to build an interface gui one
have to provide a java class that extends EOSwingInterface
and a xml file. In the nib base java client jargon you can think
at java class that extends EOSwingInterface as a controller class
but it is not the same thing.
The java class must override the initGUI()
method which is responsible to implement the swing gui
objects. initGUI() is the sole method that the user have to
override.
public class AdmissionJCSwingInterface extends EOSwingInterface {
private JFrame _mainFrame;
public AdmissionJCSwingInterface() {
super();
}
protected void initGUI() {
_mainFrame = new JFrame();
// some gui code here
}
}
The java swing interface file should be
declared in a package that include somewhere in its path the word client
(i.e. admission.client).
The xml file is responsible to
describe the bindings between the swing gui objects and the
eof model objects. Such xml file must have the same name of
the corresponding java class but with the xml extension (i.e. AdmissionJCSwingInterface.xml
for the AdmissionJCSwingInterface.java). The xml binding
file must be in WebServerResources
Here is a snippet of AdmissionJCSwingInterface.xml
<association type="text">
<widget>
nameTextField
</widget>
<displayGroup>
displayGroupStudent
</displayGroup>
<key>
name
</key>
</association>
In the code above will make a text
association between the widget nameTextField and the key name
of the displayGroupStudent displayGroup. The AdmissionJCSwingInterface.java
must have to define nameTextField as a public field or must
have to return it in a public get method
public JTextField nameTextField;
Obviously displayGroupStudent refers to
an instance of EODisplayGroup but no need to programmatically
create it. It will be create for you with the following xml snippet
<displayGroup>
<name>
displayGroupStudent
</name>
<entity>
Student
</entity>
</displayGroup>
The displayGroup over is a master
displayGroup. It is also possible to create a master-detail displayGroup,
that is the one associated to a to-may relationship. As an
example, in the AdmissionJC example, the entity Student as a
to-many relationship activities with the entity Activity
(see the image).
To create a displayGroup for the eo objects of type Activity,
subjects to that relationship, the xml code is
<displayGroup>
<name>
displayGroupActivities
</name>
<parent>
displayGroupStudent
</parent>
<parentAspect>
activities
</parentAspect>
</displayGroup>
If one want to programmatically obtain
it in order to customize the application, one can override the awakeFromConnect()
or the awakeFromBinding() method and to use the displayGroupsWithKey()
method to retrieve it
protected void awakeFromConnect() {
EODisplayGroup displayGroupStudent = displayGroupsWithKey("displayGroupStudent");
}
|