I have a class that extends DropDownChoice, called TCOChooser.  It is for some 
very minor things (overriding wantOnSelectionChanged, the choice renderer, etc 
).  I have a page that uses TCOChooser to allow the user to select a TCO that 
changes the data displayed in a table lower on the page.
 
When the user selects a new TCO the table updates as expected. When I use the 
back button on the browser the table reverts as expected.  However, the 
TCOChooser does not revert, and stays with the last user selected value.
 
My question is, am I doing something wrong or unexpected here or is this a 
problem with Wicket's modelChanged and versioning strategy or perhaps even a 
limitation of the browser or the html select element?
 
Below is TCOChooser:
 
public class TCOChooser extends DropDownChoice{
    
    private OrderPage orderPage;
    
    public TCOChooser(String id, IModel model, List choices, OrderPage 
orderPage){
        super(id, model, choices, new TCOChoiceRenderer());
        
        this.orderPage = orderPage;
    }
    
    protected boolean wantOnSelectionChangedNotifications() {
        return true;
    }
    
    protected void onSelectionChanged(final Object newSelection) {
        orderPage.updateOrderTable((TCO)newSelection);
    }
}
 
 
 
Below is my page ( OrderPage ):
 
 
public class OrderPage extends WebPage {
    
    DataTable orderTable;
    
    DropDownChoice tcoChooser;
    
    TCO TCO;
    
    /**
     * Creates a new instance of OrderPage.  TCO will be null and the entire
     * list of AbstractOrder(s) will be returned.
     */
    public OrderPage() {
        
    }
    
    /**
     * Creates a new instance of OrderPage.  The AbstractOrder(s) that match
     * the TCO will be returned.
     *
     * @param TCO The TCO to filter the list of AbstractOrder(s) by.
     */
    public OrderPage(TCO TCO){
        this.TCO = TCO;
    }
    
    private void initTCOChooser(){
        List tcos = new TCODAO().getTCOs();
        
        /* If the TCO was not supplied through the constructor, default to the 
first item in the TCO drop down */
        if( TCO == null ){
            TCO = (TCO)tcos.get(0);
        }
        
        tcoChooser = new TCOChooser("tcoChoices", new Model(TCO), tcos, this);
        add(tcoChooser);
    }
    
    private void initOrderTable(){
        List columns = new ArrayList();
        columns.add(new PropertyColumn(new Model("TSR Number"), 
"TSRNumber.number", "TSRNumber.number"));
        columns.add(new PropertyColumn(new Model("TSO Number"), 
"TSONumber.number", "TSONumber.number"));
        columns.add(new PropertyColumn(new Model("CCSD"), "CCSD.number", 
"CCSD.number"));
        orderTable = new DefaultDataTable("orders", columns, new 
OrderDataProvider(TCO), 25);
        add(orderTable);
    }
    
    @Override
    protected void onAttach() {
        
        if(tcoChooser==null){
            initTCOChooser();
        }
       
        
        if( orderTable == null ){
            initOrderTable();
        }
    }
    
    /*
     * A public callback to allow the TCOChooser component to update the order 
table when a new TCO selection is made.
     *
     * @param TCO The TCO to limit the orders in the table to.
     */
    public void updateOrderTable(TCO TCO){
        this.TCO = TCO;
     
        remove(orderTable);
        initOrderTable();
    }
}
 
Thanks much,
Andy Strickland

<<winmail.dat>>

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to