Am 11.11.2009 um 15:59 schrieb Ernesto Reinaldo Barreiro: > If you reload the page when selecting the element, instead of using AJAX, I > guess the same will work because you have a selected article... I think AJAX > is just a detail here, maybe you can use > > protected boolean wantOnSelectionChangedNotifications() > { > return false; > } > > on DropDownChoice? >
From my understanding, I need wantOnSelectionChangedNotifications() returning TRUE, otherwise onSelectionChanged() is never triggered. My current approach as follows. That's working but it doesn't feel right. To clumsy. Any ideas? (and I beg your pardon for mixing german with english in the code ;) ) package view; ..some imports... public class AddArticlePage extends StorePage { private AddArticlePanel addArticlePanel; @SuppressWarnings("unchecked") public AddArticlePage() { addArticlePanel = new AddArticlePanel("addArticlePanel"); addArticlePanel.setVisible(false); DropDownChoice dropDownType = new DropDownChoice("dropDownType", new PropertyModel(this, "selected"), Artikel.TYPELIST) { protected boolean wantOnSelectionChangedNotifications() { return true; } @Override protected void onSelectionChanged(final Object newSelection) { System.out.println("SELECTION CHANGED!"); System.out.println("new Selection = " + (String) newSelection); addArticlePanel.setVisibleFields((String) newSelection); addArticlePanel.setVisible(true); } }; Form formAdd = new Form("addArticleForm") { @Override protected void onSubmit() { System.out.println("Added Article..."); } }; add(dropDownType); add(addArticlePanel); add(formAdd); } } /***** THE PANEL CLASS ******/ public class AddArticlePanel extends Panel { private TextField artikelNummer; private TextField preis; private TextField erscheinungsJahr; private TextField beschreibung; private TextField titel; //fields for BOOK private TextField isbn; private TextField autor; private TextField verlag; //fields for CD private TextField label; private TextField artist; public AddArticlePanel(String id) { super(id); artikelNummer = new TextField("artikelNummer", new Model()); preis = new TextField("preis", new Model()); erscheinungsJahr = new TextField("erscheinungsJahr", new Model()); beschreibung = new TextField("beschreibung", new Model()); titel = new TextField("titel", new Model()); isbn = new TextField("isbn", new Model()); autor = new TextField("autor", new Model()); verlag = new TextField("verlag", new Model()); label = new TextField("label", new Model()); artist = new TextField("artist", new Model()); add(artikelNummer); add(preis); add(erscheinungsJahr); add(beschreibung); add(titel); add(isbn); add(autor); add(verlag); add(label); add(artist); // THIS WHOLE THING WOULD HAVE TO BE DONE FOR EACH ITEM AGAIN TO // DISPLAY A LABEL IN FRONT OF EACH TEXTFIELD, HOLDING A DESCRIPTION // SOUNDS AWFULL! } //could probably be optimised public void setVisibleFields(String type) { if (type.equals("BOOK")) { isbn.setVisible(true); autor.setVisible(true); verlag.setVisible(true); label.setVisible(false); artist.setVisible(false); } else { isbn.setVisible(false); autor.setVisible(false); verlag.setVisible(false); label.setVisible(true); artist.setVisible(true); } } } Comments please :) > Best, > > Ernesto > > On Wed, Nov 11, 2009 at 3:45 PM, srm <s...@schokokeks.org> wrote: > >> >> Am 11.11.2009 um 15:25 schrieb Ernesto Reinaldo Barreiro: >> >>> I have used something similar to >> [snip] >> [snap] >>> >>> for such situations... I delegate creation to a factory class (so that >> new >>> products can be plugged in). >>> >>> Best, >>> >>> Ernesto >>> >> >> >> Thank you for this example. >> But I'm bound to not use Ajax/JavaScript...and now I'm stuck. >> >> Regards, >> Stephan >> >> >> >>> On Wed, Nov 11, 2009 at 2:53 PM, srm <s...@schokokeks.org> wrote: >>> >>>> How would you approach the following: >>>> PageA is used to insert an article. At first, the user chooses what kind >> of >>>> article to insert (DropDownChoice). >>>> When the User made his choice, a coresponding form should be >> loaded/visible >>>> underneath the >>>> DropDownChoice. That's all to be solved without JavaScript. >>>> My current idea is currently to add an Panel (AddArticlePanel) which >> holds >>>> all fields for any kind of article >>>> and make them visible depending on what the user has chosen (using >>>> onSelectionChanged). >>>> But that seems like a brute approach so I wanted to get your opinions on >>>> this. >>>> >>>> Further information will be happily provided. >>>> >>>> Regards, >>>> Stephan >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>>> For additional commands, e-mail: users-h...@wicket.apache.org >>>> >>>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org