Key: MR-448
URL: http://support.castleproject.org//browse/MR-448
Project: MonoRail
Issue Type: Patch
Components: Ajax Support
Affects Versions: Future
Reporter: Victor Kornov
Priority: Minor
Attachments: Monorail_JSONReturnBinder_MakeMoreOpen.patch
I'm using jQuery Form plugin to post file uploads "async" (it uses iframes here). My controller action responds with some JSON data. Accorging to http://www.malsup.com/jquery/form/#code-samples (look Files tab) returned server data should look like <textarea>JSON respons goes here</textarea> because it's being put into iframe's innerHtml.
So, I looked at existing JSONReturnBinderAttribute and modified it a bit to be able to use it's logic (inherit and override) and wrap JSON in textarea. Attaching a patch created from ..\Castle\MonoRail\
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://support.castleproject.org//secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
Hello Victor.
From your description, I'm unsure to see an exact match with JSON, you want to render HTML or raw text, so IMHO, it doesn't relate anymore to JSONBinder.
I think it will be more accurate to tweak actual JSONBinder to allow extension in derived classes, by making some logic refactoring and render some members virtual.
Also, did you took a look at the IReturnBinder interface and extension hooks for custom implementation (if extending JSONBinder doesn't do it)?
Thanks you for considering theses alternate ways
Hi, Gauthier.
I refactored JSONReturnBinderAttribute.Bind into 2 methods and made them virtual, so my UploadJSONReturnBinder looks like:
class UploadJSONReturnBinderAttribute: JSONReturnBinderAttribute {
protected override string GetRawValue(...) {
return "<textarea>" + base.GetRawValue(...) + "</textarea>";
}
}
It's semantics and usage warrant "inherit and override" strategy. Other ways just lead to duplication, i.e. I'm forced to copy-paste JSONReturnBinderAttribute implementation.
hamilton verissimo resolved MR-448.
-----------------------------------
Resolution: Applied
Applied, thanks
> Make JSONReturnBinderAttribute open for extension
> -------------------------------------------------
>
> Key: MR-448
> URL: http://support.castleproject.org//browse/MR-448
> Project: MonoRail
> Issue Type: Patch
> Components: Ajax Support
> Affects Versions: Future
> Reporter: Victor Kornov
> Assigned To: hamilton verissimo