Re: Palette Update Behaviour Problem
OK, I changed the code as follows, and I'm getting a null on the patentsPalette.getRecorderComponent() method. PaletteCategory patentsPalette = new PaletteCategory (categoryPalette, selected, allCategories, renderer, 10, false); final Recorder recorder = patentsPalette.getRecorderComponent (); recorder.add( new AjaxFormComponentUpdatingBehavior ( onchange ) { @Override protected void onUpdate ( AjaxRequestTarget ajaxRequestTarget ) { selectedDocumentModel.getObject().addCategory ((Category)recorder.getSelectedChoices().next()); } }); All of this takes place in the constructor for my form. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Palette Update Behaviour Problem
Ok. I am sorry to bother you. I add the behavior at before render time: protected void onBeforeRender() { super.onBeforeRender(); final Recorder recorder=palette.getRecorderComponent(); palette.getRecorderComponent().add(new AjaxFormComponentUpdatingBehavior( onchange) { @SuppressWarnings(unchecked) @Override protected void onUpdate(AjaxRequestTarget target) { } }); } and I has been working right to me. But, if you would like to extend Pallete and overwrite newRecorderCompoent + adding the behavior, It seemed to be fine. On Fri, Sep 25, 2009 at 12:27 PM, Tim Hughes thug...@troglobyte.com wrote: OK, I changed the code as follows, and I'm getting a null on the patentsPalette.getRecorderComponent() method. PaletteCategory patentsPalette = new PaletteCategory(categoryPalette, selected, allCategories, renderer, 10, false); final Recorder recorder = patentsPalette.getRecorderComponent(); recorder.add( new AjaxFormComponentUpdatingBehavior( onchange ) { @Override protected void onUpdate ( AjaxRequestTarget ajaxRequestTarget ) { selectedDocumentModel.getObject().addCategory((Category)recorder.getSelectedChoices().next()); } }); All of this takes place in the constructor for my form. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Fernando Wermus. www.linkedin.com/in/fernandowermus
Re: Palette Update Behaviour Problem
Fernando: I thought that's what I was doing by overriding the newRecorderComponent method. Is that not correct? I made a change to the code (see below) and now it's storing Categories in Documents, but: 1) it's always the first Cat in the list of choices that gets set into a Doc no matter which Cat I choose 2) when reselecting a given Doc, it still has Cats but they don't reflect in the Palette choices @Override protected void onUpdate( AjaxRequestTarget ajaxRequestTarget) { selectedDocumentModel.getObject().addCategory((Category) recorder.getSelectedChoices().next()); } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Palette Update Behaviour Problem
On Thu, Sep 24, 2009 at 5:19 PM, Tim Hughes thug...@troglobyte.com wrote: Fernando: I thought that's what I was doing by overriding the newRecorderComponent method. Is that not correct? I didn't mean to say that. According to your piece of code, I thought you had created a new Recorder. You have the getter to ask for the Recorder. I made a change to the code (see below) and now it's storing Categories in Documents, but: 1) it's always the first Cat in the list of choices that gets set into a Doc no matter which Cat I choose 2) when reselecting a given Doc, it still has Cats but they don't reflect in the Palette choices @Override protected void onUpdate( AjaxRequestTarget ajaxRequestTarget) { selectedDocumentModel.getObject().addCategory((Category)recorder.getSelectedChoices().next()); } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Fernando Wermus. www.linkedin.com/in/fernandowermus
Palette Update Behaviour Problem
I am using a Palette to assign multiple Category objects to a Document object. When I select a Category, the Palette seems to operate correctly on-screen, but I'm having two issues: 1) debugging the code, the selected choice (in the onUpdate below) is ALWAYS the first item in the allCategories list 2) this (incorrect) Category is added to the Document, but does not seem to stay that way. If I switch to another Document and then come back to the original, there are no longer any Categories I've scoured this list but haven't managed to find something directly applicable to this situation. Can anyone assist? What am I doing wrong here? IChoiceRendererCategory renderer = new ChoiceRendererCategory ( name ); final IModel selected = new Model((Serializable) selectedDocument.getCategories()); IModel allCategories = new Model((Serializable)categories); final PaletteCategory documentsPalette = new PaletteCategory(categoryPalette, selected, allCategories, renderer, 10, true) { @Override protected Recorder newRecorderComponent() { final Recorder recorder = new Recorder(recorder, this); recorder.setOutputMarkupId( true ); recorder.add(new AjaxFormComponentUpdatingBehavior (onchange) { @Override protected void onUpdate( AjaxRequestTarget ajaxRequestTarget) { selectedCategory.addCategory((Category) recorder.getSelectedChoices().next()); } }); return recorder; } }; Thanks! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Palette Update Behaviour Problem
Tim, Just to know. Have you implemented your own Recorder? ps: You can get it with palette.getRecorderComponent(). Then add the behavior. On Wed, Sep 23, 2009 at 4:30 PM, Tim Hughes thug...@troglobyte.com wrote: I am using a Palette to assign multiple Category objects to a Document object. When I select a Category, the Palette seems to operate correctly on-screen, but I'm having two issues: 1) debugging the code, the selected choice (in the onUpdate below) is ALWAYS the first item in the allCategories list 2) this (incorrect) Category is added to the Document, but does not seem to stay that way. If I switch to another Document and then come back to the original, there are no longer any Categories I've scoured this list but haven't managed to find something directly applicable to this situation. Can anyone assist? What am I doing wrong here? IChoiceRendererCategory renderer = new ChoiceRendererCategory( name ); final IModel selected = new Model((Serializable)selectedDocument.getCategories()); IModel allCategories = new Model((Serializable)categories); final PaletteCategory documentsPalette = new PaletteCategory(categoryPalette, selected, allCategories, renderer, 10, true) { @Override protected Recorder newRecorderComponent() { final Recorder recorder = new Recorder(recorder, this); recorder.setOutputMarkupId( true ); recorder.add(new AjaxFormComponentUpdatingBehavior(onchange) { @Override protected void onUpdate( AjaxRequestTarget ajaxRequestTarget) { selectedCategory.addCategory((Category)recorder.getSelectedChoices().next()); } }); return recorder; } }; Thanks! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Fernando Wermus. www.linkedin.com/in/fernandowermus