You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by drf <da...@gmail.com> on 2011/03/01 08:22:01 UTC

Re: Getting Javascript function return value in Wicket

Thanks a lot, but there are no comments or notes in the code and we cannot
see how to apply the example provided to our use case.

Let's say we create a class like this (notes are my understanding of what
each method is doing):

public class JSTest extends AbstractDefaultAjaxBehavior {

        // Used to add Javacript to page ????
	@Override
	public void renderHead(IHeaderResponse response) {
                response.renderOnDomReadyJavascript(
	        "function test() {return 'abcd' };");

	}

        // Used to call javascript and then return result ????
	@Override
	public final CharSequence getCallbackUrl(final boolean
onlyTargetActivePage) {
		return super.getCallbackUrl(onlyTargetActivePage)
		+ "&x='test()'";
	}

        // Used to get return value from request ????
	@Override
	protected void respond(AjaxRequestTarget target) {
	    Request request = RequestCycle.get().getRequest();
	    String x = request.getParameter("x");
	    System.out.println("value:"+x);
	}
}

How would we then instantiate and call this class ???
Adding this in the constructor:
add( new JSTest())
Does nothing - would expect the print statement in respond() to be called.



-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-Javascript-function-return-value-in-Wicket-tp3327794p3329321.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: Getting Javascript function return value in Wicket

Posted by drf <da...@gmail.com>.
Just want to add that the call to the class which would encapsulate the code
to call the javascript function and get the result would not be in the
constructor, rather in the onclick() of a button or the applyState() of the
wizard.


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Getting-Javascript-function-return-value-in-Wicket-tp3327794p3329641.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