JavaScript form submit
I am having trouble figuring out how to submit a form that is dynamically created via JavaScript. The page uses JavaScript to create a list of commands inside a form element like so: form input type=hidden name=ActionCd value=Move / input type=hidden name=Origination value=Person1 / input type=hidden name=Destination value=Person2 / input type=hidden name=ActionCd value=Copy / input type=hidden name=Origination value=Person3 / input type=hidden name=Destination value=Person5 / /form I need to be able to complete each command in my Wicket code like so: public void onSubmit() { ListCommands data = getAndParseFormDataIntoCommands(); for (Command com : data) { if( com.getAction() == Action.MOVE) do this; if( com.getAction() == Action.COPY) do that; } } For now, I am taking an empty Wicket Form and copying in the innerHTML of my dynamic form and then submitting the Wicket Form. This gets me into the onSubmit of the Wicket Form Java code. When I Form.toString(true) the Wicket Form inside the onSubmit(), it does not contain my newly copied over input elements. I think this is a client/server issue, but I am not sure. Does anybody know of a good way to do something like this? I have two problems. First, I need to get the dynamic form data to the server side of the code. Second, I need to know how to parse the data as I expect raw HTML. I tried using MarkupStream for the parsing, but I don't know if that is the correct tool. I want to do this inside a Panel, so I don't want to post the form to another page if I don't have to do so. Thanks for any help! -- Jered Myers - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: JavaScript form submit
Using the Request object seems to work here. I am not sure if this is a good idea. Here is an example from in the form onSubmit(): Request request = RequestCycle.get().getRequest(); String[] actions = request.getParameters(ActionCd); String[] orginations = request.getParameters(Origination); ... On 5/26/2011 4:07 PM, Jered Myers wrote: I am having trouble figuring out how to submit a form that is dynamically created via JavaScript. The page uses JavaScript to create a list of commands inside a form element like so: form input type=hidden name=ActionCd value=Move / input type=hidden name=Origination value=Person1 / input type=hidden name=Destination value=Person2 / input type=hidden name=ActionCd value=Copy / input type=hidden name=Origination value=Person3 / input type=hidden name=Destination value=Person5 / /form I need to be able to complete each command in my Wicket code like so: public void onSubmit() { ListCommands data = getAndParseFormDataIntoCommands(); for (Command com : data) { if( com.getAction() == Action.MOVE) do this; if( com.getAction() == Action.COPY) do that; } } For now, I am taking an empty Wicket Form and copying in the innerHTML of my dynamic form and then submitting the Wicket Form. This gets me into the onSubmit of the Wicket Form Java code. When I Form.toString(true) the Wicket Form inside the onSubmit(), it does not contain my newly copied over input elements. I think this is a client/server issue, but I am not sure. Does anybody know of a good way to do something like this? I have two problems. First, I need to get the dynamic form data to the server side of the code. Second, I need to know how to parse the data as I expect raw HTML. I tried using MarkupStream for the parsing, but I don't know if that is the correct tool. I want to do this inside a Panel, so I don't want to post the form to another page if I don't have to do so. Thanks for any help! - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Inline JavaScript form submit
Hi All, I have an added Behaviour on button to prevent double submitting . i have added inline script button.setOnClickScript(this.disabled = true; this.className = this.className + ' disabled'; ); which is working fine for me and disabling my button on first click , but the issue is after disabling submit button it should called my perform method. which is not getting called . it just refresh my page. i have even tried couple of things like return true , this.form.submit , even use onComponentTag like onComponentTag(Component component, ComponentTag tag) { if(!(component instanceof MButton)) return; super.onComponentTag(component, tag); tag.put(onClick,this.disabled = true; this.className = this.className + ' disabled'; return true;); } nothing workign for me . Please suggest Thanks Rits -- View this message in context: http://www.nabble.com/Inline-JavaScript-form-submit-tp18385509p18385509.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Inline JavaScript form submit
On Thu, 10 Jul 2008, rit wrote: which is working fine for me and disabling my button on first click , but the issue is after disabling submit button it should called my perform method. which is not getting called . it just refresh my page. Have you checked if there are validation errors? Best wishes, Timo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]