Hi, I created TabbedPanel inside a form. The form has just one field which is the name of the client. The TabbedPanel stores different information about the client. At the top of the page I have DropDownChoice with the list of clients. When the client is choose from the DropDownChoice I'm changing the model object of the form and model object of the tabbedpanel in the onSelectionChanged method. I can see the change in the field on the form but to see the changes in the TabbedPanel I have to click on a tab. The thing is I want to see the TabbedPanel with the new info straight away after choosing the client. Can someone advice me something. Here are the code snippets:
public class HomePage extends QuickStartPage{ private static final long serialVersionUID = 1L; SortedSet<String> clientsSet; ClientForm clientForm; ClientsDropDownChoice clients; /** * Constructor */ @SuppressWarnings("unchecked") public HomePage() { // String permit = this.getWebRequestCycle().getWebRequest().getParameter("profileID"); setModel(new Model("tabpanel")); try { clientsSet = dataPersistenceService.findAllNames(); List<String> clientsList = new LinkedList<String>(clientsSet); clients = new ClientsDropDownChoice("clients",clientsList); add(clients); Client client = new Client(); clientForm = new ClientForm("clientForm",client); add(clientForm); } catch (Exception e) { error("Unable to find clients: "+e.getMessage()); e.printStackTrace(); } } public void setDataPersistenceService( DataPersistenceService dataPersistenceService) { this.dataPersistenceService = dataPersistenceService; } void saveClient(Client client) throws DataPersistenceException{ if(clients.contains(client)){ client = dataPersistenceService.updateClient(client); clients.remove(client); clients.add(client); clientForm.setModelObject(client); }else{ client.setId(DataObject.DEFAULT_ID_VALUE); dataPersistenceService.insertClient(client); clients.add(client); } } private final class ClientForm extends Form{ private static final long serialVersionUID = 1L; TabbedPanel panel; Client profile ; TabbedPanel tabbedPanel; @SuppressWarnings("synthetic-access") public ClientForm(String name, Client client) { super(name, new CompoundPropertyModel(client)); final FeedbackPanel feedback = new FeedbackPanel("feedback"); add(feedback); add(new TextField("clientName").add(new AjaxFormComponentUpdatingBehavior("onchange"))); // add the new tabbed panel, attribute modifier only used to switch // between different css variations profile = client; tabbedPanel = createTabsPanel((Client)this.getModelObject()); add(tabbedPanel); } public void updateTabs(Client client){ profile = client; } public TabbedPanel createTabsPanel(final Client client){ List<AbstractTab> tabs = new ArrayList<AbstractTab>(); tabs.add(new AbstractTab(new Model("Profile")) { private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") @Override public Panel getPanel(String panelId) { ProfilePanel panel = new ProfilePanel(panelId, profile); panel.setDataPersistenceService(dataPersistenceService); return panel; } }); panel = new TabbedPanel("tabs", tabs); panel.add(new AttributeModifier("class", true,HomePage.this.getModel())); return panel; } } private final class ClientsDropDownChoice extends DropDownChoice{ private static final long serialVersionUID = 1L; @SuppressWarnings("synthetic-access") public ClientsDropDownChoice(String arg0, List<String> choices) { super(arg0, new Model(), choices, new ChoiceRenderer()); } /** * @see wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotificatio ns() */ @Override public boolean wantOnSelectionChangedNotifications() { // we want roundtrips when a the user selects another item return true; } @SuppressWarnings("synthetic-access") @Override public void onSelectionChanged(Object newSelection){ Client clientOld = (Client)clientForm.getModelObject(); if(clientOld.getClientName()!=null){ try{ saveClient(clientOld); } catch (Exception e) { e.printStackTrace(); error("Attempt to save the client "+clientOld.getClientName()+ " failed because: "+e.getMessage()); return; } } String name = (String)newSelection; Client client = null; try{ client = dataPersistenceService.findByName(name); } catch (Exception e){ e.printStackTrace(); error("Unable to find a client with a name:"+name+"\n"+e.getMessage()); return; } clientForm.updateTabs(client); clientForm.setModelObject(client); } public boolean contains(Client dObject){ return this.getChoices().contains(dObject.getClientName()); } @SuppressWarnings("unchecked") public void add(Client dObject){ getChoices().add(dObject.getClientName()); } public void remove(Client dObject){ getChoices().remove(dObject.getClientName()); } } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user