You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by burnt99 <be...@hpi.uni-potsdam.de> on 2008/06/20 11:35:08 UTC

Combine custom component with Button

Hi,

I am still a newbie in Wicket. After having read a lot of examples and
blogs, I still did not achieve to create a custom component. I want to
create a wrapper for the GoogleVisualization API. The diagrams shall be
redrawn when someone clicks on a button.
I wrote a class, that creates the JavaScript for the Google Visualization
Diagram by a header contribution. After that I created a sample page, that
contains the button. As I understood I have to attach a behavior (e.g.
subclass of AbstractDefaultAjaxBehavior) to the button, in order to make
complex responses to the click. How can I add the behavior?
Just button.add(new MyBehavior()) did not work. The code in MyBehavior's
respond method is not executed.
Secondly, if I succeed to call the callback function, the diagram should be
redrawn by executin a JavaScript function. Can I append any JavaScript
statement to the AjaxRequestTarget object of the respond() method, and it
will be executed automatically?

Best regards, and thanks a lot!
-- 
View this message in context: http://www.nabble.com/Combine-custom-component-with-Button-tp18026191p18026191.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: Combine custom component with Button

Posted by Igor Vaynberg <ig...@gmail.com>.
dont use button since you are not submitting the form, instead use a
webmarkupcontainer and attach it to the html button tag of
type="button";

then wmc.add(new ajaxeventbehavior("onclick") {
onevent(ajaxrequesttarget t) { t.appendJavascript("alert('hi');");
}});

if you dont need a roundtrip to the server then you can simply do

add(new webmarkupcontainer("button") {
  oncomponenttag(tag) {
    tag.put("onclick", "alert('hi');");
  }
}

-igor

On Fri, Jun 20, 2008 at 2:35 AM, burnt99
<be...@hpi.uni-potsdam.de> wrote:
>
> Hi,
>
> I am still a newbie in Wicket. After having read a lot of examples and
> blogs, I still did not achieve to create a custom component. I want to
> create a wrapper for the GoogleVisualization API. The diagrams shall be
> redrawn when someone clicks on a button.
> I wrote a class, that creates the JavaScript for the Google Visualization
> Diagram by a header contribution. After that I created a sample page, that
> contains the button. As I understood I have to attach a behavior (e.g.
> subclass of AbstractDefaultAjaxBehavior) to the button, in order to make
> complex responses to the click. How can I add the behavior?
> Just button.add(new MyBehavior()) did not work. The code in MyBehavior's
> respond method is not executed.
> Secondly, if I succeed to call the callback function, the diagram should be
> redrawn by executin a JavaScript function. Can I append any JavaScript
> statement to the AjaxRequestTarget object of the respond() method, and it
> will be executed automatically?
>
> Best regards, and thanks a lot!
> --
> View this message in context: http://www.nabble.com/Combine-custom-component-with-Button-tp18026191p18026191.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