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() {
List<Commands> 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: [email protected]
For additional commands, e-mail: [email protected]