Cantiga Project
Fourth step: Customizing the appearance
In this step, we are going to customize the view of the different parts of the application
Show/hyde listed attributes
Different ways to [render lists] are provided by Romulus. This facilities are defined in http://...
In the Cantiga Project some information are showed in lists such as the different forms of a composition. In this case has been used the class java.util.ArrayList with the following annotation:
@ViewField(render = ViewConstants.RENDER_SELECT, visible=AnnotationConstants.
FALSE, selectionField = "form")
private List<String> forms = new ArrayList<String>();
And the concrete form of the composition in the attribute:
@ViewField(visible=AnnotationConstants.FALSE)
private String form;
the 'render = ViewConstants.RENDER_SELECT' indicates that the content of the list will be rendered as a drop down list
the 'visible=AnnotationConstants.FALSE' indicates that this attribute is not showed by default
the 'selectionField = "form"' means that the selected item of the list will be mapped to the attribute form (the concrete form of the composition)
After [adding persistence] to Composition, the classes CompositionListable, CompositionFilter, CompositionInstance, CompositionSelect and CompositionMain are generated under the view.Composition package
When the user is uploading a composition we want him to select the form from a list of possible forms instead typing it so in the CompositionInstance we must hide the attribute form and show the attribute forms. The class CompositionInstance is the visual representation of Composition instances on CRUD reading, creation and updating. It contains the annotation @ViewClass(entity = Composition.class) so the object entity can be used to access the Composition methods.
By default all the attributes of the entity class are rendered except those that has been hyden with the annotation visible=AnnotationConstants.FALSE. To show those hidden attributes simply add get methods for them. In this case it must be added the getForms():
@ViewField(render = ViewConstants.RENDER_SELECT, selectionField = "entity.form")
public List<String> getForms(){
return entity.getForms();
}
If we render the CompositionInstance class in a browser a drop down list with the forms is showed and the selected form of this list will be mapped to the hidden form attribute.
When listing concrete Compositions we want to show the specific form instead a list of forms so we must perform the same operation in CompositionMain showing the form attribute and hiding the forms attribute. We add the getForm() method in CompositionListable class:
public String getForm() {
return entity.getForm();
}
Last Update: 2008-08-11