Or you can just use an attribute modifier: yourform.add(new AttributeModifier("onsubmit", true, new Model("return youCoolFunction()")));
-----Original Message----- From: Dipu Seminlal [mailto:[EMAIL PROTECTED] Sent: Thursday, November 15, 2007 10:27 AM To: users@wicket.apache.org Subject: Re: how to call a javascript function? override the onComponentTag of the form object, hope this helps protected void onComponentTag(final ComponentTag tag) { super.onComponentTag(tag); tag.put("onSubmit", " return yourValidateFunction(); } cheers -dipu On Nov 15, 2007 3:23 PM, raybristol <[EMAIL PROTECTED]> wrote: > > Hi, I have a form in a page, after user fill some data in and press 'Save' I > want to call/or not to call a javascript function, in my code I was try to > do like: > > Form form = new Form("form", new CompoundPropertyModel(this)){ > protected void onSubmit(){ > activity.setReference(reference); > > (new ActivityManager()).storeActivity(activity); > //setResponsePage(new ActivityTypesMenu()); > }}; > > TextField activityDateTF = new TextField("activityDate", new > PropertyModel(this,"reference")); > activityDateTF.setRequired(true); > form.add(activityDateTF); > Button saveBtn = new Button("save"); > saveBtn.add( > new SimpleAttributeModifier( > "onclick", "something();")); > > > form.add(saveBtn); > > add(form); > > However I don't think I am doing it right, one thing that javascript > function not be called so I am asking help again here... > > Many thanks again. > -- > View this message in context: http://www.nabble.com/how-to-call-a-javascript-function--tf4813502.html# a13771231 > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]