0

Using the metawidget to build some flexible UI in Java: https://sourceforge.net/projects/metawidget/

public class Cohort  {

    private int id;
    private Project project;
    private Member teamLead;

    public Cohort() {   }

    @UiHidden
    public int getId() { return id; }
    public void setId(int id) { this.id = id; }

    public Project getProject() { return project;   }
    public void setProject(Project project) { this.project = project; }

    public Member getTeamLead() { return teamLead; }
    public void setTeamLead(Member teamLead) { this.teamLead = teamLead; }

}

Cohort is the class inspected. However as is desirable it recursively inspects both the Project and Member classes.

When displayed on the UI, it will display all the fields for each of the classes. However I would only like to display the "Name" field of the Project and firstName + last Name of the Member.

kyleED
  • 2,327
  • 2
  • 18
  • 23

1 Answers1

0

There are a number of ways to achieve this. I'll start with one and let me know if it's sufficient for your needs:

a) mark the fields of Project/Member that you don't want to see as UiHidden (you don't say what those fields are, but you seem to have gotten the idea because you are already hiding 'Cohort.getId'). Note you can also reuse existing annotations (like JPA annotations) for this purpose.

b) mark 'Cohort.getProject' and 'Cohort.getTeamLead' as UiLabel( "" ). This will suppress the sub-label for the sub-object, and make its fields appear as if part of the original object.

Richard Kennard
  • 1,325
  • 11
  • 20
  • I came across the second option in the URL: http://blog.kennardconsulting.com/2008/02/suppressing-label-generation-in.html as part of the wiki already. I was considering creating a separate UML for displaying the information needed for this use of the project and member, as I didnt want to affect the definition for other parts of the UI. However to repeat this for every case (as with other models) seems laborious. Is there any better possibilities. – kyleED Oct 26 '13 at 00:52
  • Another possibility: write a small Inspector that will look at the type of the attribute. If the type's package belongs to one of your model packages, add label="" into the inspection-result.xml. This will suppress labels for all nested objects across your whole app. – Richard Kennard Oct 26 '13 at 03:00
  • Another possibility: extend whatever layout you are using and override its layoutLabel method. This method is usually passed the metadata of the property, including its type. If type is one of your model packages, do not render a label. – Richard Kennard Oct 26 '13 at 03:02
  • I actually end up using your first recommendation. I went through the application again and realized there wasnt any other sections that needed to render the objects differently. I must confessed I ran from the Inspector method, didn't find much examples and the little i tried didn't work out too well. – kyleED Nov 24 '13 at 04:02