You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2014/04/21 15:01:51 UTC

AjaxButton does not respect return false on client side

I have an ajax button that launches a modal form.  It binds to:

<input type="button" wicket:id="btnCopy" onclick='return false;' value="Copy
To">

I've replace the javascript call that checks the condition with a flat
return false to simplify things.  This still launches the event, and renders
the modal window.  

The button code itself:

		AjaxButton btnCopy = (AjaxButton) new AjaxButton("btnCopy") {
			private static final long serialVersionUID = 1L;
			@Override
			public void onSubmit(AjaxRequestTarget target, Form<?> arg1) {
				onSRTabCopy(target);
			}
			
			@Override
			public boolean isEnabled() {
				return true;
			}
		}.setDefaultFormProcessing(false); 

Is wicket doing something to get in front of my return false?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-does-not-respect-return-false-on-client-side-tp4665497.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: AjaxButton does not respect return false on client side

Posted by Martin Grigorov <mg...@apache.org>.
hi,

On Apr 21, 2014 6:30 PM, "Entropy" <bl...@gmail.com> wrote:
>
> Nevermind.  This secondary issue was caused by one of my many experiments
to
> solve the original issue.  Further, I also found that if I had needed to
do
> this, the method to override is getOnClickScript().
>
> I will say, that I am a little uncertain if this new style is a good
thing.
> Traditionally, Wicket has seemed to work pretty hard to make HTML things
> stay in HTML and Java things stay in Java.  I now seem forced to put
> javascript code that controls buttons in Java.
>
> I've put javascript in my java before of course, but usually only when the
> javascript needed dynamic elements from the server.  Now this seemingly
> client-side behavior is pulled into the server.

no one stops you to use plain non obtrusive JavaScript for this requirement

>
> But my problems is resolved.
>
> --
> View this message in context:
http://apache-wicket.1842946.n4.nabble.com/AjaxButton-does-not-respect-return-false-on-client-side-tp4665497p4665499.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: AjaxButton does not respect return false on client side

Posted by Entropy <bl...@gmail.com>.
Nevermind.  This secondary issue was caused by one of my many experiments to
solve the original issue.  Further, I also found that if I had needed to do
this, the method to override is getOnClickScript().

I will say, that I am a little uncertain if this new style is a good thing. 
Traditionally, Wicket has seemed to work pretty hard to make HTML things
stay in HTML and Java things stay in Java.  I now seem forced to put
javascript code that controls buttons in Java.  

I've put javascript in my java before of course, but usually only when the
javascript needed dynamic elements from the server.  Now this seemingly
client-side behavior is pulled into the server.

But my problems is resolved.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-does-not-respect-return-false-on-client-side-tp4665497p4665499.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: AjaxButton does not respect return false on client side

Posted by Entropy <bl...@gmail.com>.
So I figured out that what's happening is that evidently wicket 6 doesn't put
the javascript inline, but uses event listener registration or whatever. 
And it seems like this overwrites my inline event in an AjaxButton.  The
solution:

			@Override
			protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
				super.updateAjaxAttributes(attributes);
				AjaxCallListener listener = new AjaxCallListener();
				listener.onPrecondition("return copyClick();");
				attributes.getAjaxCallListeners().add(listener);
			}

However, no sooner do I solve this, then I find that one of my submit
buttons (which is just a new Button, not AjaxButton) is having a similar
problem.  But the above method does not exist on mere Button.  How can I do
something similar?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxButton-does-not-respect-return-false-on-client-side-tp4665497p4665498.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