You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great work on the module. However I have a big problem that's preventing me from upgrading to the latest 0.9.4.3.
Inside my controller, I'm making some final checks on the request parameters trying to see if I need to return a jsonp response. If so, I would've simply done something like:
JapidResult jR = new JapidResult(getRenderResultWith(template(), stuffToRender));
StringBuilder res = jR.getRenderResult().getContent();
res.insert(0, "(").insert(0, callback).append(")");
throw jR;
But now, the RenderResultPartial sends back a new StringBuilder upon every access so my method obviously fails.
It would be optimal to always return the original StringBuilder, and not just enhance a new one every time getContent() is called.
The text was updated successfully, but these errors were encountered:
The reason that a new instance of StringBuilder is returned is due to the
fact the StringBuilder buried inside of the RenderResultPartial is only
part of the text output of the result. It's immutable.
Solutions:
Put the additional checking in the template or in a Java method can be
in invoked in the template.
Or,
2. Compose a new instance of RenderResult using this constructor:
public RenderResult(Map<String, String> headers , StringBuilder content, *
long* renderTime)
and throw a new instance of JapidResult that wraps the above RenderResult.
Something like this:
RenderResult rr = getRenderResultWith(template(), stuffToRender);
StringBuilder res = rr.getContent();
res.insert(0, "(").insert(0, callback).append(")");
throw new JapidResult(new RenderResult(rr.getHeaders(), res, 0));
Great work on the module. However I have a big problem that's preventing
me from upgrading to the latest 0.9.4.3.
Inside my controller, I'm making some final checks on the request
parameters trying to see if I need to return a jsonp response. If so, I
would've simply done something like:
JapidResult jR = new JapidResult(getRenderResultWith(template(),
stuffToRender));
StringBuilder res = jR.getRenderResult().getContent();
res.insert(0, "(").insert(0, callback).append(")");
throw jR;
But now, the RenderResultPartial sends back a new StringBuilder upon every
access so my method obviously fails.
It would be optimal to always return the original StringBuilder, and not
just enhance a new one every time getContent() is called.
Reply to this email directly or view it on GitHub: #51
Hi,
Great work on the module. However I have a big problem that's preventing me from upgrading to the latest 0.9.4.3.
Inside my controller, I'm making some final checks on the request parameters trying to see if I need to return a jsonp response. If so, I would've simply done something like:
JapidResult jR = new JapidResult(getRenderResultWith(template(), stuffToRender));
StringBuilder res = jR.getRenderResult().getContent();
res.insert(0, "(").insert(0, callback).append(")");
throw jR;
But now, the RenderResultPartial sends back a new StringBuilder upon every access so my method obviously fails.
It would be optimal to always return the original StringBuilder, and not just enhance a new one every time getContent() is called.
The text was updated successfully, but these errors were encountered: