You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Dietze <di...@fh-wedel.de> on 2010/01/05 16:30:14 UTC

Solved: Track selected entries in either of a Palette's Choices components?

On Fri, December 25, 2009, Martin Dietze wrote:

> I desperately need to find out which entries in a Palette's two
> Choices components are selected, e.g. to allow additional
> operations on them using Ajax.

I solved this issue. First of all: currently the AbstractOptions
class used by Palette does not support accessing this
information via Ajax because of these lines:

|  // A piece of javascript to avoid serializing the options during AJAX
|  // serialization.
|  getResponse().write(
|          JavascriptUtils.SCRIPT_OPEN_TAG +
|                  "if (typeof(Wicket) != \"undefined\" && typeof(Wicket.Form) != \"undefined\")" +
|                  "    Wicket.Form.excludeFromAjaxSerialization." + getMarkupId() + "='true';" +
|                  JavascriptUtils.SCRIPT_CLOSE_TAG);

Thus, in order to get this working at all, we'll have to patch
Wicket. The patch is very simple, we move this code into a 
separate method which can be overridden by derived classes.
I created an issue for this and attached the patch [1].

Now having applied the patch we proceed as follows. 
First, we need to derive our own Choices and Selection
components in which we override the above code by an empty 
method, so that we get the selection POSTed at all. Now
we can override various methods as needed; in my case 
implementing a custom convertInput() method was sufficient,
so that I could access the currently selected entries in
the two SELECTs by calling their getConvertedInput() methods
which seemed the least invasive change and least likely to
cause any trouble with the Palette's core functionality.

Next, I derived my own custom class from Palette in which
I needed to override the factory methods for creating the 
Choices and Selection components. Pretty easy in the end.

Cheers,

M'bert

[1] https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12444712

-- 
----------- / http://herbert.the-little-red-haired-girl.org / -------------
=+= 
Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
machen.  -- Lutz Donnerhacke in dasr

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


Re: Disable selected choices on palette load

Posted by nino martinez wael <ni...@gmail.com>.
Hi "sardana"

I did:
- build a patch
- put a veil over palette
- roll out your own "palette", it's pretty simple actually if you

The easiest thing would probably be the latter for you. Just make a palette
(Panel) consisting of 2 buttons, 2 listboxes. And then you should be able to
customise as much as you want.

2010/2/3 dhirajs <sa...@rediffmail.com>

>
> Hi,
>
> thanks 'nino' for ur reply.
>
> Actually the thing i want is like :-
> for say, there are 5 available users(a,b,c,d,e) and of these users a and b
> are already selected.
> So, a and b should come as disabled in palette's selected list when palette
> is being displayed to user.
> After that client can move (to and fro )other users(c,d, e) from available
> to selected lists.
>
> Please suggest some solution for above scenario.
>
> I have tried 'getSelectionComponent() ' and than set disable all its
> childern by overriding onBeforeRender method.But that solution does not
> works as children list is null, although there are entries in selection
> list.
>
>
>
>
> nino martinez wael wrote:
> >
> > three solutions:
> >
> >
> >    - build a patch
> >    - put a veil over palette
> >    - roll out your own "palette", it's pretty simple actually if you
> > accept
> >    a server side solution (can be done with ajax as well)
> >
> >
> > 2010/2/3 dhirajs <sa...@rediffmail.com>
> >
> >>
> >> Hi,
> >>
> >> I want to disable all preselected enteries in 'selected' choice box(so
> >> that
> >> user can't move those choices to available list). Please suggest some
> >> solution.
> >>
> >> I have tried one solution, by overriding inBeforeRender method and in
> >> that
> >> method i've get 'selectedChoicesComponent' and disable all childs, but i
> >> am
> >> getting null for selectedChoicesComponent.
> >>
> >>        @Override
> >>        protected void onBeforeRender() {
> >>                super.onBeforeRender();
> >>                Selection<T> selectedChoicesComponent =
> >> (Selection<T>)getSelectionComponent();
> >>
> >>        //Just to check, i have disabled 1st child,if it works we can
> >> easliy
> >> disable other childs
> >>        selectedChoicesComponent.get(0).setEnabled(false);
> >>
> >>        }
> >> getSelectionComponent() - returns null.
> >>
> >>
> >> Thanks,
> >> Dhiraj
> >>
> >> Martin Dietze wrote:
> >> >
> >> > On Fri, December 25, 2009, Martin Dietze wrote:
> >> >
> >> >> I desperately need to find out which entries in a Palette's two
> >> >> Choices components are selected, e.g. to allow additional
> >> >> operations on them using Ajax.
> >> >
> >> > I solved this issue. First of all: currently the AbstractOptions
> >> > class used by Palette does not support accessing this
> >> > information via Ajax because of these lines:
> >> >
> >> > |  // A piece of javascript to avoid serializing the options during
> >> AJAX
> >> > |  // serialization.
> >> > |  getResponse().write(
> >> > |          JavascriptUtils.SCRIPT_OPEN_TAG +
> >> > |                  "if (typeof(Wicket) != \"undefined\" &&
> >> > typeof(Wicket.Form) != \"undefined\")" +
> >> > |                  "    Wicket.Form.excludeFromAjaxSerialization." +
> >> > getMarkupId() + "='true';" +
> >> > |                  JavascriptUtils.SCRIPT_CLOSE_TAG);
> >> >
> >> > Thus, in order to get this working at all, we'll have to patch
> >> > Wicket. The patch is very simple, we move this code into a
> >> > separate method which can be overridden by derived classes.
> >> > I created an issue for this and attached the patch [1].
> >> >
> >> > Now having applied the patch we proceed as follows.
> >> > First, we need to derive our own Choices and Selection
> >> > components in which we override the above code by an empty
> >> > method, so that we get the selection POSTed at all. Now
> >> > we can override various methods as needed; in my case
> >> > implementing a custom convertInput() method was sufficient,
> >> > so that I could access the currently selected entries in
> >> > the two SELECTs by calling their getConvertedInput() methods
> >> > which seemed the least invasive change and least likely to
> >> > cause any trouble with the Palette's core functionality.
> >> >
> >> > Next, I derived my own custom class from Palette in which
> >> > I needed to override the factory methods for creating the
> >> > Choices and Selection components. Pretty easy in the end.
> >> >
> >> > Cheers,
> >> >
> >> > M'bert
> >> >
> >> > [1]
> >> >
> >>
> https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12444712
> >> >
> >> > --
> >> > ----------- / http://herbert.the-little-red-haired-girl.org /
> >> > -------------
> >> > =+=
> >> > Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
> >> > machen.  -- Lutz Donnerhacke in dasr
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> > For additional commands, e-mail: users-help@wicket.apache.org
> >> >
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/Repost%3A-Track-selected-entries-in-either-of-a-Palette%27s-Choices-components--tp26922651p27432901.html
> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Repost%3A-Track-selected-entries-in-either-of-a-Palette%27s-Choices-components--tp26922651p27434694.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Disable selected choices on palette load

Posted by dhirajs <sa...@rediffmail.com>.
Hi,

thanks 'nino' for ur reply.

Actually the thing i want is like :-
for say, there are 5 available users(a,b,c,d,e) and of these users a and b
are already selected.
So, a and b should come as disabled in palette's selected list when palette
is being displayed to user.
After that client can move (to and fro )other users(c,d, e) from available
to selected lists.

Please suggest some solution for above scenario. 

I have tried 'getSelectionComponent() ' and than set disable all its
childern by overriding onBeforeRender method.But that solution does not
works as children list is null, although there are entries in selection
list.




nino martinez wael wrote:
> 
> three solutions:
> 
> 
>    - build a patch
>    - put a veil over palette
>    - roll out your own "palette", it's pretty simple actually if you
> accept
>    a server side solution (can be done with ajax as well)
> 
> 
> 2010/2/3 dhirajs <sa...@rediffmail.com>
> 
>>
>> Hi,
>>
>> I want to disable all preselected enteries in 'selected' choice box(so
>> that
>> user can't move those choices to available list). Please suggest some
>> solution.
>>
>> I have tried one solution, by overriding inBeforeRender method and in
>> that
>> method i've get 'selectedChoicesComponent' and disable all childs, but i
>> am
>> getting null for selectedChoicesComponent.
>>
>>        @Override
>>        protected void onBeforeRender() {
>>                super.onBeforeRender();
>>                Selection<T> selectedChoicesComponent =
>> (Selection<T>)getSelectionComponent();
>>
>>        //Just to check, i have disabled 1st child,if it works we can
>> easliy
>> disable other childs
>>        selectedChoicesComponent.get(0).setEnabled(false);
>>
>>        }
>> getSelectionComponent() - returns null.
>>
>>
>> Thanks,
>> Dhiraj
>>
>> Martin Dietze wrote:
>> >
>> > On Fri, December 25, 2009, Martin Dietze wrote:
>> >
>> >> I desperately need to find out which entries in a Palette's two
>> >> Choices components are selected, e.g. to allow additional
>> >> operations on them using Ajax.
>> >
>> > I solved this issue. First of all: currently the AbstractOptions
>> > class used by Palette does not support accessing this
>> > information via Ajax because of these lines:
>> >
>> > |  // A piece of javascript to avoid serializing the options during
>> AJAX
>> > |  // serialization.
>> > |  getResponse().write(
>> > |          JavascriptUtils.SCRIPT_OPEN_TAG +
>> > |                  "if (typeof(Wicket) != \"undefined\" &&
>> > typeof(Wicket.Form) != \"undefined\")" +
>> > |                  "    Wicket.Form.excludeFromAjaxSerialization." +
>> > getMarkupId() + "='true';" +
>> > |                  JavascriptUtils.SCRIPT_CLOSE_TAG);
>> >
>> > Thus, in order to get this working at all, we'll have to patch
>> > Wicket. The patch is very simple, we move this code into a
>> > separate method which can be overridden by derived classes.
>> > I created an issue for this and attached the patch [1].
>> >
>> > Now having applied the patch we proceed as follows.
>> > First, we need to derive our own Choices and Selection
>> > components in which we override the above code by an empty
>> > method, so that we get the selection POSTed at all. Now
>> > we can override various methods as needed; in my case
>> > implementing a custom convertInput() method was sufficient,
>> > so that I could access the currently selected entries in
>> > the two SELECTs by calling their getConvertedInput() methods
>> > which seemed the least invasive change and least likely to
>> > cause any trouble with the Palette's core functionality.
>> >
>> > Next, I derived my own custom class from Palette in which
>> > I needed to override the factory methods for creating the
>> > Choices and Selection components. Pretty easy in the end.
>> >
>> > Cheers,
>> >
>> > M'bert
>> >
>> > [1]
>> >
>> https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12444712
>> >
>> > --
>> > ----------- / http://herbert.the-little-red-haired-girl.org /
>> > -------------
>> > =+=
>> > Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
>> > machen.  -- Lutz Donnerhacke in dasr
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Repost%3A-Track-selected-entries-in-either-of-a-Palette%27s-Choices-components--tp26922651p27432901.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Repost%3A-Track-selected-entries-in-either-of-a-Palette%27s-Choices-components--tp26922651p27434694.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Disable selected choices on palette load

Posted by nino martinez wael <ni...@gmail.com>.
three solutions:


   - build a patch
   - put a veil over palette
   - roll out your own "palette", it's pretty simple actually if you accept
   a server side solution (can be done with ajax as well)


2010/2/3 dhirajs <sa...@rediffmail.com>

>
> Hi,
>
> I want to disable all preselected enteries in 'selected' choice box(so that
> user can't move those choices to available list). Please suggest some
> solution.
>
> I have tried one solution, by overriding inBeforeRender method and in that
> method i've get 'selectedChoicesComponent' and disable all childs, but i am
> getting null for selectedChoicesComponent.
>
>        @Override
>        protected void onBeforeRender() {
>                super.onBeforeRender();
>                Selection<T> selectedChoicesComponent =
> (Selection<T>)getSelectionComponent();
>
>        //Just to check, i have disabled 1st child,if it works we can easliy
> disable other childs
>        selectedChoicesComponent.get(0).setEnabled(false);
>
>        }
> getSelectionComponent() - returns null.
>
>
> Thanks,
> Dhiraj
>
> Martin Dietze wrote:
> >
> > On Fri, December 25, 2009, Martin Dietze wrote:
> >
> >> I desperately need to find out which entries in a Palette's two
> >> Choices components are selected, e.g. to allow additional
> >> operations on them using Ajax.
> >
> > I solved this issue. First of all: currently the AbstractOptions
> > class used by Palette does not support accessing this
> > information via Ajax because of these lines:
> >
> > |  // A piece of javascript to avoid serializing the options during AJAX
> > |  // serialization.
> > |  getResponse().write(
> > |          JavascriptUtils.SCRIPT_OPEN_TAG +
> > |                  "if (typeof(Wicket) != \"undefined\" &&
> > typeof(Wicket.Form) != \"undefined\")" +
> > |                  "    Wicket.Form.excludeFromAjaxSerialization." +
> > getMarkupId() + "='true';" +
> > |                  JavascriptUtils.SCRIPT_CLOSE_TAG);
> >
> > Thus, in order to get this working at all, we'll have to patch
> > Wicket. The patch is very simple, we move this code into a
> > separate method which can be overridden by derived classes.
> > I created an issue for this and attached the patch [1].
> >
> > Now having applied the patch we proceed as follows.
> > First, we need to derive our own Choices and Selection
> > components in which we override the above code by an empty
> > method, so that we get the selection POSTed at all. Now
> > we can override various methods as needed; in my case
> > implementing a custom convertInput() method was sufficient,
> > so that I could access the currently selected entries in
> > the two SELECTs by calling their getConvertedInput() methods
> > which seemed the least invasive change and least likely to
> > cause any trouble with the Palette's core functionality.
> >
> > Next, I derived my own custom class from Palette in which
> > I needed to override the factory methods for creating the
> > Choices and Selection components. Pretty easy in the end.
> >
> > Cheers,
> >
> > M'bert
> >
> > [1]
> > https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12444712
> >
> > --
> > ----------- / http://herbert.the-little-red-haired-girl.org /
> > -------------
> > =+=
> > Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
> > machen.  -- Lutz Donnerhacke in dasr
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Repost%3A-Track-selected-entries-in-either-of-a-Palette%27s-Choices-components--tp26922651p27432901.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Disable selected choices on palette load

Posted by dhirajs <sa...@rediffmail.com>.
Hi,

I want to disable all preselected enteries in 'selected' choice box(so that
user can't move those choices to available list). Please suggest some
solution.

I have tried one solution, by overriding inBeforeRender method and in that
method i've get 'selectedChoicesComponent' and disable all childs, but i am
getting null for selectedChoicesComponent.

	@Override
	protected void onBeforeRender() {
		super.onBeforeRender();
         	Selection<T> selectedChoicesComponent =
(Selection<T>)getSelectionComponent();

	//Just to check, i have disabled 1st child,if it works we can easliy
disable other childs	
	selectedChoicesComponent.get(0).setEnabled(false);
  
	}
getSelectionComponent() - returns null.


Thanks,
Dhiraj

Martin Dietze wrote:
> 
> On Fri, December 25, 2009, Martin Dietze wrote:
> 
>> I desperately need to find out which entries in a Palette's two
>> Choices components are selected, e.g. to allow additional
>> operations on them using Ajax.
> 
> I solved this issue. First of all: currently the AbstractOptions
> class used by Palette does not support accessing this
> information via Ajax because of these lines:
> 
> |  // A piece of javascript to avoid serializing the options during AJAX
> |  // serialization.
> |  getResponse().write(
> |          JavascriptUtils.SCRIPT_OPEN_TAG +
> |                  "if (typeof(Wicket) != \"undefined\" &&
> typeof(Wicket.Form) != \"undefined\")" +
> |                  "    Wicket.Form.excludeFromAjaxSerialization." +
> getMarkupId() + "='true';" +
> |                  JavascriptUtils.SCRIPT_CLOSE_TAG);
> 
> Thus, in order to get this working at all, we'll have to patch
> Wicket. The patch is very simple, we move this code into a 
> separate method which can be overridden by derived classes.
> I created an issue for this and attached the patch [1].
> 
> Now having applied the patch we proceed as follows. 
> First, we need to derive our own Choices and Selection
> components in which we override the above code by an empty 
> method, so that we get the selection POSTed at all. Now
> we can override various methods as needed; in my case 
> implementing a custom convertInput() method was sufficient,
> so that I could access the currently selected entries in
> the two SELECTs by calling their getConvertedInput() methods
> which seemed the least invasive change and least likely to
> cause any trouble with the Palette's core functionality.
> 
> Next, I derived my own custom class from Palette in which
> I needed to override the factory methods for creating the 
> Choices and Selection components. Pretty easy in the end.
> 
> Cheers,
> 
> M'bert
> 
> [1]
> https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12444712
> 
> -- 
> ----------- / http://herbert.the-little-red-haired-girl.org /
> -------------
> =+= 
> Perl ist der gegl�ckte Versuch, einen braindump direkt ausf�hrbar zu
> machen.  -- Lutz Donnerhacke in dasr
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Repost%3A-Track-selected-entries-in-either-of-a-Palette%27s-Choices-components--tp26922651p27432901.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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