You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by raybristol <ra...@gmail.com> on 2007/11/15 16:23:47 UTC

how to call a javascript function?

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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: how to call a javascript function?

Posted by Clay Lehman <cl...@medfusion.net>.
Or you can just use an attribute modifier:

yourform.add(new AttributeModifier("onsubmit", true, new Model("return
youCoolFunction()")));

-----Original Message-----
From: Dipu Seminlal [mailto:dipu.wkt@googlemail.com] 
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 <ra...@gmail.com> 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: 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: how to call a javascript function?

Posted by Dipu Seminlal <di...@googlemail.com>.
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 <ra...@gmail.com> 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: 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