Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Lets look to a code sample that we find on most of the wicket examples. Which as other newbie developer gave me the idea that, perhaps that's the best way to do it. But more I moved on, more I disagreed with that concept. (this code was taken from the post //cwiki.apache.org/WICKET/dropdownchoice-examples.html DropDownExample

Code Block
class MyPage extends WebPage {       
   .....       
   public MyPage() {       
      .......           
      DropDownChoice dropDownChoice=new DropDownChoice("phoneVendor", phoneVendors) {               
         protected boolean wantOnSelectionChangedNotifications() {
            return true;           
         }           
         protected void onSelectionChanged(final Object newSelection) {               
            String phoneVendor = (String) newSelection;
            myModel.setPhoneModel(null);                 
            phoneModelDDC.setChoices(getTerminalsByVendor(phoneVendor));          
         }       
      };       
      add(dropDownChoice);       
      ......    
   }    
   ..... 
}

...

Now some people might say, how we set a response page and get hold of the page that was having the drop down choice. The suggestion is, still we can use the earlier way to get hold of everything if we want. But if you liked my suggested approach, then you can get lots of things out from factory method of Application (Application.get()), and using the application you can do lots of things.

--Jahid Shohel