You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by avchavan <av...@yahoo.co.in> on 2015/02/11 07:51:37 UTC

Wicket 6 onmouseover and onclick event misbehavior

Hi,

I am having a component with both onmouseover and onclick behavior.
onmouseover behavior works but the onclick event never gets triggered.
If i just keep the onclick event then it works.

Code:

firstContainer2.add(new AjaxEventBehavior("onclick") {
					@SuppressWarnings({ "unchecked", "rawtypes" })
					@Override
					protected void onEvent(final AjaxRequestTarget target) {
		            	for(Component acc:
(ListView<String>)mainContainer.get("list2")){
		            		final Component accord = (Component)
acc.get("descriptionContainer2");
		            		if(accord.isVisible()){
		            			accord.setVisible(false);
		            			target.add(accord);
		            		}
		            		Component firstCont2 = acc.get("firstContainer2");
		            		firstCont2.add(new AttributeModifier("class", ""));
		            		Component lArrow2 = firstCont2.get("leftArrow2");
		            		lArrow2.add(new AttributeModifier("class",
"tableIconArrowLeft"));
		            		target.add(firstCont2);
		            	}
		            	descriptionContainer2.setVisible(true);
		            	firstContainer2.add(new AttributeModifier("class", "info
table-hover"));
		            	leftArrow2.add(new AttributeModifier("class",
"tableIconArrowDown"));
		            	target.add(firstContainer2);
		            	target.add(descriptionContainer2);
					}
				});
				
				firstContainer2.add(new AjaxEventBehavior("mouseover"){

					@Override
					protected void onEvent(AjaxRequestTarget target) {
						if(firstContainer2.getStyle() == null ||
!firstContainer2.getStyle().equalsIgnoreCase("ex")){
							firstContainer2.add(new AttributeModifier("class", "ex"));
							target.add(firstContainer2);
						}
					}
					
				});

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-onmouseover-and-onclick-event-misbehavior-tp4669442.html
Sent from the Users forum 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: Wicket 6 onmouseover and onclick event misbehavior

Posted by Tobias Soloschenko <to...@googlemail.com>.
Thanks a lot Sven - I didn't took a closer look to see that the component itself has been replaced. 

kind regards

Tobias

> Am 11.02.2015 um 10:12 schrieb Sven Meier <sv...@meiers.net>:
> 
> Hi,
> 
> >I didnt get the "Why don't you use a ":hover" pseudo class?"
> 
> you just seem to change firstContainer2's class attribute. It's more efficient to use a pseudo class instead:
> 
>    https://developer.mozilla.org/en-US/docs/Web/CSS/:hover
> 
> Regards
> Sven
> 
> 
>> On 11.02.2015 09:50, avchavan wrote:
>> @Sven Meier
>> I didnt get the "Why don't you use a ":hover" pseudo class?"
>> 
>> Also, i had one more question regarding the onmouseover event, it gets
>> called up the whole time i have the cursor over that component. Is there a
>> way to use it properly so that it doesnt get called everytime...as in it
>> should be called only once (i.e initially).
>> 
>> --
>> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-onmouseover-and-onclick-event-misbehavior-tp4669442p4669450.html
>> Sent from the Users forum 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
> 

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


Re: Wicket 6 onmouseover and onclick event misbehavior

Posted by Sven Meier <sv...@meiers.net>.
Hi,

 >I didnt get the "Why don't you use a ":hover" pseudo class?"

you just seem to change firstContainer2's class attribute. It's more 
efficient to use a pseudo class instead:

     https://developer.mozilla.org/en-US/docs/Web/CSS/:hover

Regards
Sven


On 11.02.2015 09:50, avchavan wrote:
> @Sven Meier
> I didnt get the "Why don't you use a ":hover" pseudo class?"
>
> Also, i had one more question regarding the onmouseover event, it gets
> called up the whole time i have the cursor over that component. Is there a
> way to use it properly so that it doesnt get called everytime...as in it
> should be called only once (i.e initially).
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-onmouseover-and-onclick-event-misbehavior-tp4669442p4669450.html
> Sent from the Users forum 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: Wicket 6 onmouseover and onclick event misbehavior

Posted by avchavan <av...@yahoo.co.in>.
@Sven Meier
I didnt get the "Why don't you use a ":hover" pseudo class?"

Also, i had one more question regarding the onmouseover event, it gets
called up the whole time i have the cursor over that component. Is there a
way to use it properly so that it doesnt get called everytime...as in it
should be called only once (i.e initially).

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-onmouseover-and-onclick-event-misbehavior-tp4669442p4669450.html
Sent from the Users forum 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: Wicket 6 onmouseover and onclick event misbehavior

Posted by Sven Meier <sv...@meiers.net>.
Hi,

 > firstContainer2.add(new AjaxEventBehavior("mouseover") {
 >   @Override
 >   protected void onEvent(AjaxRequestTarget target) {
 >      target.add(firstContainer2);
 >   }
 >});

the "click" never has a chance to get through:
You're updating firstContainer2 on "mouseover", replacing the DOM 
element under the mouse. Thus on the next mouse movement the "mouseover" 
event will be triggered again.

Why don't you use a ":hover" pseudo class?

Regards
Sven


On 11.02.2015 07:51, avchavan wrote:
> Hi,
>
> I am having a component with both onmouseover and onclick behavior.
> onmouseover behavior works but the onclick event never gets triggered.
> If i just keep the onclick event then it works.
>
> Code:
>
> firstContainer2.add(new AjaxEventBehavior("onclick") {
> 					@SuppressWarnings({ "unchecked", "rawtypes" })
> 					@Override
> 					protected void onEvent(final AjaxRequestTarget target) {
> 		            	for(Component acc:
> (ListView<String>)mainContainer.get("list2")){
> 		            		final Component accord = (Component)
> acc.get("descriptionContainer2");
> 		            		if(accord.isVisible()){
> 		            			accord.setVisible(false);
> 		            			target.add(accord);
> 		            		}
> 		            		Component firstCont2 = acc.get("firstContainer2");
> 		            		firstCont2.add(new AttributeModifier("class", ""));
> 		            		Component lArrow2 = firstCont2.get("leftArrow2");
> 		            		lArrow2.add(new AttributeModifier("class",
> "tableIconArrowLeft"));
> 		            		target.add(firstCont2);
> 		            	}
> 		            	descriptionContainer2.setVisible(true);
> 		            	firstContainer2.add(new AttributeModifier("class", "info
> table-hover"));
> 		            	leftArrow2.add(new AttributeModifier("class",
> "tableIconArrowDown"));
> 		            	target.add(firstContainer2);
> 		            	target.add(descriptionContainer2);
> 					}
> 				});
> 				
> 				firstContainer2.add(new AjaxEventBehavior("mouseover"){
>
> 					@Override
> 					protected void onEvent(AjaxRequestTarget target) {
> 						if(firstContainer2.getStyle() == null ||
> !firstContainer2.getStyle().equalsIgnoreCase("ex")){
> 							firstContainer2.add(new AttributeModifier("class", "ex"));
> 							target.add(firstContainer2);
> 						}
> 					}
> 					
> 				});
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-onmouseover-and-onclick-event-misbehavior-tp4669442.html
> Sent from the Users forum 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: Wicket 6 onmouseover and onclick event misbehavior

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi,

try to add them both at once.

component.add(clickbehavior,mousebehavior);

kind regards

Tobias

> Am 11.02.2015 um 07:51 schrieb avchavan <av...@yahoo.co.in>:
> 
> Hi,
> 
> I am having a component with both onmouseover and onclick behavior.
> onmouseover behavior works but the onclick event never gets triggered.
> If i just keep the onclick event then it works.
> 
> Code:
> 
> firstContainer2.add(new AjaxEventBehavior("onclick") {
>                    @SuppressWarnings({ "unchecked", "rawtypes" })
>                    @Override
>                    protected void onEvent(final AjaxRequestTarget target) {
>                        for(Component acc:
> (ListView<String>)mainContainer.get("list2")){
>                            final Component accord = (Component)
> acc.get("descriptionContainer2");
>                            if(accord.isVisible()){
>                                accord.setVisible(false);
>                                target.add(accord);
>                            }
>                            Component firstCont2 = acc.get("firstContainer2");
>                            firstCont2.add(new AttributeModifier("class", ""));
>                            Component lArrow2 = firstCont2.get("leftArrow2");
>                            lArrow2.add(new AttributeModifier("class",
> "tableIconArrowLeft"));
>                            target.add(firstCont2);
>                        }
>                        descriptionContainer2.setVisible(true);
>                        firstContainer2.add(new AttributeModifier("class", "info
> table-hover"));
>                        leftArrow2.add(new AttributeModifier("class",
> "tableIconArrowDown"));
>                        target.add(firstContainer2);
>                        target.add(descriptionContainer2);
>                    }
>                });
>                
>                firstContainer2.add(new AjaxEventBehavior("mouseover"){
> 
>                    @Override
>                    protected void onEvent(AjaxRequestTarget target) {
>                        if(firstContainer2.getStyle() == null ||
> !firstContainer2.getStyle().equalsIgnoreCase("ex")){
>                            firstContainer2.add(new AttributeModifier("class", "ex"));
>                            target.add(firstContainer2);
>                        }
>                    }
>                    
>                });
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wicket-6-onmouseover-and-onclick-event-misbehavior-tp4669442.html
> Sent from the Users forum 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