You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vitor Granzinoli Vellozo <vi...@cpmbraxis.com> on 2011/06/14 16:51:08 UTC

Doubt about Pallete component

 

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

 


Re: Doubt about Pallete component

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
/**
 * @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 <vi...@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.makundi@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 <vi...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Doubt about Pallete component

Posted by James Carman <ja...@carmanconsulting.com>.
Try reading the Palette javadocs.

On Tue, Jun 14, 2011 at 11:38 AM, Vitor Granzinoli Vellozo
<vi...@cpmbraxis.com> wrote:
>
> 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.makundi@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 <vi...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RES: Doubt about Pallete component

Posted by Vitor Granzinoli Vellozo <vi...@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.makundi@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 <vi...@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Doubt about Pallete component

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Do you attach ajax to palette recorder?

**
Martin

2011/6/14 Vitor Granzinoli Vellozo <vi...@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org