Architecture of Application

I am evaluating Vaadin for a product I am working on. I am quite familiar with Swing so as I have been running through prototypes I’ve been finding myself doing things in a Swing like manner. For example, I’ve been playing around with creating a Master/Detail type page where I have a master table and when I click on a row I show another table with a bit more details about the parent row. Here is how I approached it.

I created a class that extends Panel to place my tables on. I then used a VerticalLayout to hold the tables. I created the master table and had it immediate=true so it displayed the data right away. I also created the detail table in this class but turned immediate=false and visibility=false.

I then created a new class that is the Table Listener which implements Property.ValueChangeListener. I used a new class for this for 2 reasons; 1) I’m writing all my code in Groovy and groovy doesn’t like inner classes and 2) I just think it’s a better pattern to go this route. This class looks like this:


class GenTypeAttributeTableListener implements Property.ValueChangeListener {

  def attTable
  def valueTable

  public GenTypeAttributeTableListener(attTable, valueTable) {
    this.attTable = attTable
    this.valueTable = valueTable
  }

  void valueChange(ValueChangeEvent valueChangeEvent) {
    if (attTable.value) {
      def container = new BeanItemContainer<GenAttributeValue>(GenAttributeValue.class)
      def values = GenAttributeValue.findAllByGenAttribute(attTable.value)
      values.each {
        container.addBean it
      }
      valueTable.containerDataSource = container
      valueTable.visibleColumns = ["value", "sequenceNo"]

      valueTable.visible = true
    }
  }
}

Note that I have to pass both the master and detail tables into this listener constructor. This works great. But I’m wondering if this is really how I should be dealing with this scenario. Any advice is much appreciated.

Gregg

Thought I’d bump this in case it got overlooked. Eagerly awaiting replies.

Thanks

Gregg

This works fine for smaller data sets. For larger datasets you might want to consider using containers that load data lazily (and does not store all beans in memory).

Right, thanks Joonas. Aside from the datasets, however, is this appropriate design for managing the detail table? Is it appropriate to use the Listener in this fasion? Is there a more “Vaadin” way or something more appropriate?