You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ying <do...@gmail.com> on 2009/04/07 13:51:27 UTC

retrieve value at mouse click in palette

Hi,
  I try to retrieve the value of  highlighted choice in palette by
single click. Is there any sample code to do that anywhere? I cannot
find anything from google or wicket book.

Ying

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


Re: retrieve value at mouse click in palette

Posted by yxd0018 <yi...@ml.com>.
This doesn't work. super.newChoiceComponent() cannot have impl. 
I tried this:

 this.palette = new Palette<Serializable>( "palette", new
CompoundPropertyModel( (Serializable)selectedChoice )
                , new CompoundPropertyModel( (Serializable)choiceList ),
renderer, 10, false ) {
            @Override
            protected Component newChoicesComponent() {
                Component choices = new Choices<Serializable>("choices",
this){
                    private static final long serialVersionUID = 1L;
                       @Override
                        protected void onComponentTag( ComponentTag tag ) {
                            super.onComponentTag( tag );
                            tag.getAttributes().remove("ondblclick");

                            CharSequence url = urlFor(
IOnChangeListener.INTERFACE);
                            // NOTE: do not encode the url as that would
give invalid JavaScript
                            tag.put("onchange", "window.location.href='" +
url + "&amp;" + getPath()
                                                     + "=' +
this.options[this.selectedIndex].value;");            
                        }
//                    @Override
//                    protected Map<String, String>
getAdditionalAttributes(Object choice)
//                    {
//                        return
super.this.getAdditionalAttributesForChoices(choice);
//                    }
                };

                choices.add( new AjaxEventBehavior( "onclick" ) {
                    @Override
                    protected void onEvent( AjaxRequestTarget target ) {
                        System.out.println("onclick");
                    }

                } );

                return choices;
            }

But get an error, 

WicketMessage: Method onSelectionChanged of interface
org.apache.wicket.markup.html.form.IOnChangeListener targeted at component
[MarkupContainer [Component id = choices]] threw an exception

Root cause:

java.lang.IllegalArgumentException: object is not an instance of declaring
class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
at
org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
at
org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at
org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1236)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1315)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1414)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:542)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456)
at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)


igor.vaynberg wrote:
> 
> component choices=super.newchoicescomponent() {
>   oncomponenttag(tag) {
>       super.oncomponenttag(tag);
>       tag.getattributes().remove("ondblclick");
>   }
> }
> 
> -igor
> 
> On Tue, Apr 7, 2009 at 3:10 PM, yxd0018 <yi...@ml.com> wrote:
>>
>> Also, how could I disable default double click action in palette?
>>
>>
>> Thanks for your code. Appreciate a little more help. How do I get the
>> highlighted object from palette? I have this
>> List<ScenarioDefinition> choiceList = getAllScenarios();
>> List<ScenarioDefinition> selectedChoice =
>> scenarioService.getScenarioByReportId( );
>>  this.palette = new Palette<Serializable>( "palette", new Model(
>> (Serializable)selectedChoice )
>>                , new Model( (Serializable)choiceList ), renderer, 10,
>> false
>> ) ;
>> In Method onEvent(), however getParent().getDefaultModelObject() throw
>> exception.
>>
>>
>> igor.vaynberg wrote:
>>>
>>> add(new palette(.....) {
>>>   protected component newchoicescomponent() {
>>>     component choices=super.newchoicescomponent();
>>>     choices.add(new ajaxeventbehavior("click") {
>>>        protected void onevent(ajaxrequettarget t) {
>>>            // do whatever you need
>>>        }});}});
>>>
>>> -igor
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22939330.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
>>
>>
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22957051.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: retrieve value at mouse click in palette

Posted by Igor Vaynberg <ig...@gmail.com>.
component choices=super.newchoicescomponent() {
  oncomponenttag(tag) {
      super.oncomponenttag(tag);
      tag.getattributes().remove("ondblclick");
  }
}

-igor

On Tue, Apr 7, 2009 at 3:10 PM, yxd0018 <yi...@ml.com> wrote:
>
> Also, how could I disable default double click action in palette?
>
>
> Thanks for your code. Appreciate a little more help. How do I get the
> highlighted object from palette? I have this
> List<ScenarioDefinition> choiceList = getAllScenarios();
> List<ScenarioDefinition> selectedChoice =
> scenarioService.getScenarioByReportId( );
>  this.palette = new Palette<Serializable>( "palette", new Model(
> (Serializable)selectedChoice )
>                , new Model( (Serializable)choiceList ), renderer, 10, false
> ) ;
> In Method onEvent(), however getParent().getDefaultModelObject() throw
> exception.
>
>
> igor.vaynberg wrote:
>>
>> add(new palette(.....) {
>>   protected component newchoicescomponent() {
>>     component choices=super.newchoicescomponent();
>>     choices.add(new ajaxeventbehavior("click") {
>>        protected void onevent(ajaxrequettarget t) {
>>            // do whatever you need
>>        }});}});
>>
>> -igor
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22939330.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
>
>

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


Re: retrieve value at mouse click in palette

Posted by yxd0018 <yi...@ml.com>.
Also, how could I disable default double click action in palette?


Thanks for your code. Appreciate a little more help. How do I get the
highlighted object from palette? I have this
List<ScenarioDefinition> choiceList = getAllScenarios();
List<ScenarioDefinition> selectedChoice =
scenarioService.getScenarioByReportId( );
 this.palette = new Palette<Serializable>( "palette", new Model(
(Serializable)selectedChoice )
                , new Model( (Serializable)choiceList ), renderer, 10, false
) ;
In Method onEvent(), however getParent().getDefaultModelObject() throw
exception.


igor.vaynberg wrote:
> 
> add(new palette(.....) {
>   protected component newchoicescomponent() {
>     component choices=super.newchoicescomponent();
>     choices.add(new ajaxeventbehavior("click") {
>        protected void onevent(ajaxrequettarget t) {
>            // do whatever you need
>        }});}});
> 
> -igor
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22939330.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: retrieve value at mouse click in palette

Posted by yxd0018 <yi...@ml.com>.
I have no idea about JS, where is the generated url? Could U post some sample
code pls? Appreciate very much. 



igor.vaynberg wrote:
> 
> with a bit of javascript: this.options[this.selectedIndex] which you
> then append to the generated url.
> 
> -igor
> 
> On Tue, Apr 7, 2009 at 2:55 PM, yxd0018 <yi...@ml.com> wrote:
>>
>> Thanks for your code. Appreciate a little more help. How do I get the
>> highlighted object from palette? I have this
>> List<ScenarioDefinition> choiceList = getAllScenarios();
>> List<ScenarioDefinition> selectedChoice =
>> scenarioService.getScenarioByReportId( );
>>  this.palette = new Palette<Serializable>( "palette", new Model(
>> (Serializable)selectedChoice )
>>                , new Model( (Serializable)choiceList ), renderer, 10,
>> false
>> ) ;
>> In Method onEvent(), however getParent().getDefaultModelObject() throw
>> exception.
>>
>>
>> add(new palette(.....) {
>>  protected component newchoicescomponent() {
>>    component choices=super.newchoicescomponent();
>>    choices.add(new ajaxeventbehavior("click") {
>>       protected void onevent(ajaxrequettarget t) {
>>           // do whatever you need
>>       }});}});
>>
>> -igor
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22939123.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
>>
>>
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22941590.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: retrieve value at mouse click in palette

Posted by Igor Vaynberg <ig...@gmail.com>.
with a bit of javascript: this.options[this.selectedIndex] which you
then append to the generated url.

-igor

On Tue, Apr 7, 2009 at 2:55 PM, yxd0018 <yi...@ml.com> wrote:
>
> Thanks for your code. Appreciate a little more help. How do I get the
> highlighted object from palette? I have this
> List<ScenarioDefinition> choiceList = getAllScenarios();
> List<ScenarioDefinition> selectedChoice =
> scenarioService.getScenarioByReportId( );
>  this.palette = new Palette<Serializable>( "palette", new Model(
> (Serializable)selectedChoice )
>                , new Model( (Serializable)choiceList ), renderer, 10, false
> ) ;
> In Method onEvent(), however getParent().getDefaultModelObject() throw
> exception.
>
>
> add(new palette(.....) {
>  protected component newchoicescomponent() {
>    component choices=super.newchoicescomponent();
>    choices.add(new ajaxeventbehavior("click") {
>       protected void onevent(ajaxrequettarget t) {
>           // do whatever you need
>       }});}});
>
> -igor
>
>
> --
> View this message in context: http://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22939123.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
>
>

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


Re: retrieve value at mouse click in palette

Posted by yxd0018 <yi...@ml.com>.
Thanks for your code. Appreciate a little more help. How do I get the
highlighted object from palette? I have this
List<ScenarioDefinition> choiceList = getAllScenarios();
List<ScenarioDefinition> selectedChoice =
scenarioService.getScenarioByReportId( );
 this.palette = new Palette<Serializable>( "palette", new Model(
(Serializable)selectedChoice )
                , new Model( (Serializable)choiceList ), renderer, 10, false
) ;
In Method onEvent(), however getParent().getDefaultModelObject() throw
exception.


add(new palette(.....) {
  protected component newchoicescomponent() {
    component choices=super.newchoicescomponent();
    choices.add(new ajaxeventbehavior("click") {
       protected void onevent(ajaxrequettarget t) {
           // do whatever you need
       }});}});

-igor


-- 
View this message in context: http://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22939123.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: retrieve value at mouse click in palette

Posted by Igor Vaynberg <ig...@gmail.com>.
add(new palette(.....) {
  protected component newchoicescomponent() {
    component choices=super.newchoicescomponent();
    choices.add(new ajaxeventbehavior("click") {
       protected void onevent(ajaxrequettarget t) {
           // do whatever you need
       }});}});

-igor

On Tue, Apr 7, 2009 at 11:58 AM, yxd0018 <yi...@ml.com> wrote:
>
> Don't know whether my previous email was successful or not. Apology if this
> is duplicate.
> I want to do same thing as
> http://www.nabble.com/How-can-I-get-hold-of-a-palette's-selected-item--td2001571
> 4.html
>
> Basically want to use palette and capture value user clicks in the choice
> list, which hasn't been transferred to selected list yet. I can use the
> value to query db and pull details over and display details in a form so
> that user can see what underlying he is choosing. Appreciate if there is any
> code sample to do that.
>
>
>
>
> Sean W wrote:
>>
>> Ying, is an HTML color picker perhaps what you are looking for? Try
>> http://cpicker.com/, I found it to be a good one.
>>
>>
>> Ying-9 wrote:
>>>
>>> Hi,
>>>   I try to retrieve the value of  highlighted choice in palette by
>>> single click. Is there any sample code to do that anywhere? I cannot
>>> find anything from google or wicket book.
>>>
>>> Ying
>>>
>>> ---------------------------------------------------------------------
>>> 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://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22935377.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
>
>

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


Re: retrieve value at mouse click in palette

Posted by yxd0018 <yi...@ml.com>.
Don't know whether my previous email was successful or not. Apology if this
is duplicate.
I want to do same thing as 
http://www.nabble.com/How-can-I-get-hold-of-a-palette's-selected-item--td2001571
4.html

Basically want to use palette and capture value user clicks in the choice
list, which hasn't been transferred to selected list yet. I can use the
value to query db and pull details over and display details in a form so
that user can see what underlying he is choosing. Appreciate if there is any
code sample to do that. 




Sean W wrote:
> 
> Ying, is an HTML color picker perhaps what you are looking for? Try
> http://cpicker.com/, I found it to be a good one.
> 
> 
> Ying-9 wrote:
>> 
>> Hi,
>>   I try to retrieve the value of  highlighted choice in palette by
>> single click. Is there any sample code to do that anywhere? I cannot
>> find anything from google or wicket book.
>> 
>> Ying
>> 
>> ---------------------------------------------------------------------
>> 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://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22935377.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: retrieve value at mouse click in palette

Posted by Sean W <se...@bibliofiche.com>.
Ying, is an HTML color picker perhaps what you are looking for? Try
http://cpicker.com/, I found it to be a good one.


Ying-9 wrote:
> 
> Hi,
>   I try to retrieve the value of  highlighted choice in palette by
> single click. Is there any sample code to do that anywhere? I cannot
> find anything from google or wicket book.
> 
> Ying
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/retrieve-value-at-mouse-click-in-palette-tp22927443p22934528.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: retrieve value at mouse click in palette

Posted by Igor Vaynberg <ig...@gmail.com>.
why do you think its such a good idea to post the same question more then once?

-igor

On Tue, Apr 7, 2009 at 4:51 AM, Ying <do...@gmail.com> wrote:
> Hi,
>   I try to retrieve the value of  highlighted choice in palette by
> single click. Is there any sample code to do that anywhere? I cannot
> find anything from google or wicket book.
>
> Ying
>
> ---------------------------------------------------------------------
> 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