For some reason my form submission crashes in the the method isFormCancelled in Form.java.
The call to JSONArray(raw) crashes since raw is an empty string which is not allowed. I must have missed something with 5.3 and form handling that is incompatible with 5.2.6. Does anyone have a clue what has to be done ? Thanks in advance, Gunnar Eketrapp ---------------------------------------------------------------------------------------------------------------- request.getParameter(SUBMITTING_ELEMENT_ID); private boolean isFormCancelled() { // The "cancel" query parameter is reserved for this purpose; if it is present then the form was canceled on the // client side. For image submits, there will be two parameters: "cancel.x" and "cancel.y". if (request.getParameter(InternalConstants.CANCEL_NAME) != null || request.getParameter(InternalConstants.CANCEL_NAME + ".x") != null) { return true; } // When JavaScript is involved, it's more complicated. In fact, this is part of HLS's desire // to have all forms submit via XHR when JavaScript is present, since it would provide // an opportunity to get the submitting element's value into the request properly. String raw = request.getParameter(SUBMITTING_ELEMENT_ID); if (raw != null && new *JSONArray(raw)* .getString(1).equals(InternalConstants.CANCEL_NAME)) { return true; } return false; } 2011/12/4 Gunnar Eketrapp <gunnar.eketr...@gmail.com> > Did you solve this? I am getting the same right now. > > I just started my second attempt with 5.3 after Taha pointed out a > solution for my user type translators. > > But now I am looking at these JSONArray stack traces ... > > Perhaps there is a snapshot release of 5.3 that I can try with !? > > 2011/11/21 Serge Eby <sd...@hotmail.com> > >> Hi, >> >> I am using T 5.3-rc-3 and I am getting the following error message while >> submitting any forms in my app: >> >> --- >> A JSONArray text must start with '[' at character 1 of "[\"save\", >> \"save\"]" >> -- >> >> Stack trace: >> -- >> org.apache.tapestry5.json.JSONTokener.syntaxError(JSONTokener.java:384) >> org.apache.tapestry5.json.JSONArray.parse(JSONArray.java:126) >> org.apache.tapestry5.json.JSONArray.<init>(JSONArray.java:95) >> >> org.apache.tapestry5.corelib.components.Form.isFormCancelled(Form.java:590) >> >> org.apache.tapestry5.corelib.components.Form.advised$onAction_12585e84eba88bfd(Form.java:511) >> >> org.apache.tapestry5.corelib.components.Form$Invocation_onAction_12585e84eba88bfc.proceedToAdvisedMethod(Unknown >> Source) >> >> org.apache.tapestry5.internal.plastic.AbstractMethodInvocation.proceed(AbstractMethodInvocation.java: >> ... >> --- >> What's puzzling is that the form works in a dummy app but fails in the >> core >> (complex) app. This makes me believe that there is something else that is >> interfering with tapestry. I've also noticed that if I disable Javascript >> in >> the browser, the submission is successful. >> >> It looks as if: >> String raw = request.getParameter(SUBMITTING_ELEMENT_ID); >> >> in Form.isCancelled() is returning a String in double quotes (in my case) >> but I can't figure out where this is created. >> >> Has anybody else seen this? >> >> >> Below is an excerpt: >> >> java class: >> >> .... >> void onSuccess() { >> >> String uploadDir = context.getRealFile("/").getAbsolutePath() + >> "/resources"; >> File dirPath = new File(uploadDir); >> >> if (!dirPath.exists()) { >> dirPath.mkdirs(); >> } >> >> File copied = new File(uploadDir , file.getFileName()); >> file.write(copied); >> >> } >> >> tml: >> >> .... >> <form t:type="form" t:id="upload" clientValidation="none"> >> <ul> >> <li> >> <label t:type="label" for="name"/> >> <input t:type="textfield" t:id="name" validate="required"/> >> </li> >> <li> >> <label t:type="label" for="file"/> >> <input t:type="upload" t:id="file" validate="required"/> >> </li> >> <li> >> <input t:type="submit" value="Upload" t:id="save" /> >> >> <input type="button" value="Cancel"/> >> >> </li> >> </ul> >> </form> >> ... >> >> >> -- >> Thanks, >> >> /Serge >> >> >> -- >> View this message in context: >> http://tapestry-users.832.n2.nabble.com/5-3-JSONArray-Error-while-submitting-forms-tp7018161p7018161.html >> Sent from the Tapestry Users mailing list archive at Nabble.com. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > > -- > [Hem: 08-715 59 57, Mobil: 070-991 86 42] > Allévägen 2A, 132 42 Saltsjö-Boo > -- [Hem: 08-715 59 57, Mobil: 070-991 86 42] Allévägen 2A, 132 42 Saltsjö-Boo