At this point we can define the classes defining our domain. We can import the project from Eclipse following these steps:
In the File menu select import...
Select “General/Existing Projects into Workspace” and click next
In “select root directory” click browse and select the root directory of the project where the file build.xml is located. In this case /home/romaapps/software-risks
Click in “finish” button
In the workspace of Eclipse a project called “software-risks” will appear and inside it a set of packages containing different aspects of the application. Inside the gesfor.roma.swrisks.domain package create the following classes:
Attack
public class Attack {
private Company company;
private String description;
private Date date;
private Risk attackType;
public String toString(){
String attack =date.toString()+""+description;
return attack;
}
}
Company
public class Company {
public String name;
private String CIF;
public String toString(){
return name;
}
}
Risk
public class Risk {
private String name;
private String type;
@ViewField(render="textarea")
private String description;
private int dangerous;
private double cost;
}
Dont forget to include the correct imports in the classes. In Eclipse it can be done automatically clicking the source with the right button and selecting “Source/Organice Imports”.
With the toString() method we redefine the way that the components will be shown when they appear in lists or other visual elements. In the Echo2 view the fields and methods are rendered as defined in the applicationContext-echo2.xml file under the directory software-risks/WebContent/WEB-INF that contains the mapping between types and rendering mode. By default methods are showed as links:
<entry key="action" value="link" />
and fields, depending on types, are mapped with entries like this
<entry key="java.lang.String" value="text" />
So if we visualize the Risk class, for example, it would look like this:
Roma only shows those fields that have a get method so we must generate get methods for he desired fields. In Eclipse all you have to do is click in the source editor with the right button and select “Source/Generate getters and setter...”.
Last Update: 2008-08-18
| << Prev | Roma Users module | Next>> |
0 Ficheros adjuntos