Back Forum Reply New

How do I refresh an AbstractTable I just built?

mand.ActionCommand;
import org..richclient.command.CommandGroup;
import org..richclient.command.ToggleCommand;
import org..richclient.dialog.MessageDialog;
import org..util.Assert;

import com.harris.ITrafficType;

public class ATroubleTicketView extends AbstractView implements InitializingBean {

private TicketTable ticketTable;
private ObjectFactory ticketTableFactory = null;

/* (non-Javadoc)* @see org..beans.factory.InitializingBean#afterPropertiesSet()*/
public void afterPropertiesSet() throws Exception {       Assert.state(getTicketTableFactory() != null, quot;ticketTableFactory must be setquot;);
}

protected JComponent createControl() {
prepareTable();
       ActionCommand refreshCommand = new ActionCommand(quot;refreshCommandquot;) {
protected void doExecuteCommand() {
logger.debug(quot;Executing commandquot;);
// THIS is where I would like to rebuild the window!!!
}       };       getCommandConfigurer().configure(refreshCommand);                 CommandGroup myMenu = new CommandGroup(quot;myMenuquot;);       getActiveWindow().getMenuBar().add(myMenu);       myMenu.add(refreshCommand);               getCommandConfigurer().configure(myMenu);
       JPanel view = new JPanel(new BorderLayout());              JPanel buttonPanel = getComponentFactory().createPanel();       buttonPanel.setName(quot;filterRadioButtonGroupquot;);       String tip = getMessage(quot;filterRadioButtonGroup.tipquot;);       buttonPanel.setToolTipText(tip);       buttonPanel.add(refreshCommand.createButton());              JScrollPane sp = getComponentFactory().createScrollPane(ticketTable.getTable());
       view.add(buttonPanel, BorderLayout.BEFORE_FIRST_LINE);       view.add(sp, BorderLayout.CENTER);       return view;
}

private void prepareTable() {       try {ticketTable = (TicketTable)getTicketTableFactory().getObject();       } catch( Exception e ) {logger.error(quot;Failed to generate new contactTablequot;, e);throw new RuntimeException(quot;Failed to generate new contactTablequot;, e);       }
}

/*** @return Returns the ticketTableFactory.*/
public ObjectFactory getTicketTableFactory() {
return ticketTableFactory;
}

/*** @param ticketTableFactory The ticketTableFactory to set.*/
public void setTicketTableFactory(ObjectFactory ticketTableFactory) {
this.ticketTableFactory = ticketTableFactory;
}

}
There are other buttons, but I trimmed them out of this snapshot of my code.

I just don't see where to get this AbstractObjectTable to refresh itself! I have a hidden filter option embedded in my SecurityContext, and I need to re-run the database query after changing filter criteria through radio button commands (not shown in my samples), and re-generate the list of tickets.

I suggest you to implement a refresh method in your TicketTable which is called by the refreshCommand. This method uses the List returned by getBaseEventList() of AbstractObjectTable to refresh the elements in the list.

You can do it this way in your refresh method:

List list = getBaseEventList();
list.clear();
list.addAll(dataAccess.getOpenActiveTroubleTickets  ());

Thanks. That does the trick.
¥
Back Forum Reply New