As mentioned the code actually do what it was suppose to do, it is just
that it breaks ajax (some browser security concerns as it is sent from the
server, not too sure about specifics)

I would expected that either tapestry has a good way to solve this issue or
at least a nice workaround...

I will try to add javascript as you have suggested but the tricky part
would be to make it correct for each id, I guess mixin?


On Sun, Feb 16, 2014 at 1:24 AM, Christian Riedel
<cr.ml...@googlemail.com>wrote:

> Hi Boris,
>
> passing the whole function code as JSONLiteral could work, I guess:
>
>         params.put("onSubmit", new JSONLiteral("function () {
> showUploadProgress(); }"));
>
> But Thiago has a point. Passing more complex code around like this is not
> a good idea.
> Instead you can alter the fileuploader’s option object directly:
>
>         $('#uploader').data('fileuploader')._options.onSubmit =
> showUploadProgress;
>
> Didn’t test this, though. And of course this code works just as long as
> the fileuploader library isn’t replaced by a newer one.
>
> T5-jQuery’s AjaxUpload component should provide a better interface for
> this.
>
> Best
> Christian
>
>
> Am 16.02.2014 um 00:49 schrieb Boris Horvat <horvat.z.bo...@gmail.com>:
>
> > Sadly that doesnt really help. Same error, same issue.
> >
> > I have changed the JSONLiberal call to
> >
> >        params.put("onSubmit", new JSONLiteral("showUploadProgress"));
> >
> > My javascript that is generated at the end looks like this
> >
> >  "uploadable" : [
> >    {
> >      "elementId" : "imageUpload",
> >      "onSubmit" : showUploadProgress,
> >      "maxConnections" : 3,
> >      "action" : "/assets.assetdata.updateassetimage.imageupload:upload",
> >      "sizeLimit" : 0,
> >      "showMessagesDialog" : "uploadErrorMesages",
> >      "multiple" : false,
> >      "messages" : {
> >        "cancelLabel" : "Cancel",
> >        "failedLabel" : "Failed",
> >        "uploadLabel" : "Upload Image(s)",
> >        "typeError" : "{file} has an invalid extension. Only {extensions}
> > are allowed.",
> >        "sizeError" : "{file} is too large, maximum file size is
> > {sizeLimit}.",
> >        "onLeave" : "The files are being uploaded, if you leave now the
> > upload will be canceled.",
> >        "dropAreaLabel" : "Drag and drop images here.",
> >        "minSizeError" : "{file} is too small, minimum file size is
> > {minSizeLimit}.",
> >        "emptyError" : "{file} is empty, please select files again without
> > it."
> >      }
> >    }
> >
> > That's something to avoid as much as possible.
> >
> >
> > Any suggestion how to avoid this? I need to pass a function that I want
> to
> > call when a file is submitted, so how can I do that?
> >
> > Thanks for help
> >
> >
> > On Sat, Feb 15, 2014 at 9:37 PM, Thiago H de Paula Figueiredo <
> > thiag...@gmail.com> wrote:
> >
> >> On Sat, 15 Feb 2014 16:25:27 -0200, Boris Horvat <
> horvat.z.bo...@gmail.com>
> >> wrote:
> >>
> >> Hi everyone,
> >>>
> >>
> >> Hi!
> >>
> >>
> >> I have a tapestr5-jquery component that to which I need to pass a
> >>> function in the configuration.
> >>>
> >>
> >> That's something to avoid as much as possible.
> >
> >
> > Any suggestion to
> >
> >>
> >>
> >> The component is
> >>> http://tapestry5-jquery.com/components/docsajaxupload;jsessionid=
> >>> 2CD857F51B90113A175C5B10EE09B138.57B580630AEA
> >>>
> >>> My code looks like this
> >>>
> >>> java
> >>>
> >>> public JSONObject getUploadParams() {
> >>>        JSONObject params = new JSONObject();
> >>>        params.put("onSubmit", new
> >>> JSONLiteral(String.format("showUploadProgress()")));
> >>>        return params;
> >>>    }
> >>>
> >>
> >> Your code has an useless String.format() call. In addition, it's passing
> >> the value resulting of calling showUploadProgress(), not passing the
> >> function itself. It should have been new JSONLiteral("
> >> showUploadProgress").
> >>
> >> --
> >> Thiago H. de Paula Figueiredo
> >> Tapestry, Java and Hibernate consultant and developer
> >> http://machina.com.br
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Sincerely
> > *Boris Horvat*
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Sincerely
*Boris Horvat*

Reply via email to