/** * @author Martin */ public class AjaxifiedPalette extends Palette<DimensionView> { /** * */ private static final long serialVersionUID = 1L;
/** * @author Martin */ public static class FriendlyAjaxFormSubmitBehavior extends AjaxFormSubmitBehavior { /** * */ private static final long serialVersionUID = 1L; private final WebMarkupContainer treeContainer; /** * @param event * @param treeContainer */ public FriendlyAjaxFormSubmitBehavior(String event, WebMarkupContainer treeContainer) { super(event); this.treeContainer =treeContainer; } @Override public CharSequence getEventHandler() { return super.getEventHandler(); } @Override protected void onError(AjaxRequestTarget target) { // } @Override protected void onSubmit(AjaxRequestTarget target) { target.addComponent(treeContainer); } } /** * */ private FriendlyAjaxFormSubmitBehavior ajaxFormSubmitBehavior; private final WebMarkupContainer treeContainer; public AjaxifiedPalette(WebMarkupContainer treeContainer, String id, IModel<List<DimensionView>> model, IModel<? extends Collection<? extends DimensionView>> choicesModel, IChoiceRenderer<DimensionView> choiceRenderer, int rows, boolean allowOrder) { super(id, model, choicesModel, choiceRenderer, rows, allowOrder); this.treeContainer = treeContainer; } @Override public String getDownOnClickJS() { return super.getDownOnClickJS() + getAjaxFormSubmitBehavior().getEventHandler(); } @Override public String getAddOnClickJS() { return super.getAddOnClickJS() + getAjaxFormSubmitBehavior().getEventHandler(); } @Override public String getRemoveOnClickJS() { return super.getRemoveOnClickJS() + getAjaxFormSubmitBehavior().getEventHandler(); } @Override public String getUpOnClickJS() { return super.getUpOnClickJS() + getAjaxFormSubmitBehavior().getEventHandler(); } @Override protected void onBeforeRender() { if (ajaxFormSubmitBehavior == null) { // Just bind it to anything within the form so that we get the needed paths add(ajaxFormSubmitBehavior = new FriendlyAjaxFormSubmitBehavior("weactuallyjustwantthescript", treeContainer)); // ajaxFormSubmitBehavior.bind(palette); } super.onBeforeRender(); } public FriendlyAjaxFormSubmitBehavior getAjaxFormSubmitBehavior() { return ajaxFormSubmitBehavior; } } 2011/6/14 Vitor Granzinoli Vellozo <vitor.vell...@cpmbraxis.com>: > > Martin, > > You mentioned Palette Recorder, so I tried to use that, but it not works like > I need. > > Imagine I have an Object called Contact (with name, age..), and a palette > with a list of > not-selected contacts at left side, and a list of selected contacts at right > side. > > I just need an Ajax behavior ("onclick") that return me the Selected Contact > Object. > > Is it possible? How can I do that? > > > Thanks a lot > Vitor > > > -----Mensagem original----- > De: Martin Makundi [mailto:martin.maku...@koodaripalvelut.com] > Enviada em: terça-feira, 14 de junho de 2011 12:02 > Para: users@wicket.apache.org > Assunto: Re: Doubt about Pallete component > > Do you attach ajax to palette recorder? > > ** > Martin > > 2011/6/14 Vitor Granzinoli Vellozo <vitor.vell...@cpmbraxis.com>: >> >> >> Wicketers, >> >> >> >> To use the Pallete component, I need use two models, first to list >> not-selected items, and the second to list the selected items. >> >> >> >> I need add an ajax behavior in the pallete to get the value of a certain >> item when it is clicked. When I use Ajax, I can get the modelObject >> >> but this object is a List (the list of selected items) and it is not a >> unique object. >> >> >> >> So, my doubt is, how can I get a unique object from a list used in the >> pallete? >> >> >> >> Is it possible? >> >> >> >> Any help will be apreciated! >> >> >> >> Thanks all!! >> >> Vitor >> >> >> >> > > --------------------------------------------------------------------- > 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