public static class Controller.Util
extends java.lang.Object
Provides utilities for controller action methods to emit rendering results
Modifier and Type | Field and Description |
---|---|
static org.osgl.mvc.result.Created |
CREATED |
static org.osgl.mvc.result.Result |
CREATED_JSON |
static org.osgl.mvc.result.Result |
CREATED_XML |
static org.osgl.mvc.result.NoContent |
NO_CONTENT |
static org.osgl.mvc.result.Ok |
OK |
static org.osgl.mvc.result.Result |
OK_JSON |
static org.osgl.mvc.result.Result |
OK_XML |
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static org.osgl.mvc.result.Result |
accepted(java.lang.String statusMonitorUrl)
Returns a
Accepted result |
static org.osgl.mvc.result.BadRequest |
badRequest() |
static org.osgl.mvc.result.BadRequest |
badRequest(java.lang.String msg,
java.lang.Object... args) |
static void |
badRequestIf(boolean test) |
static void |
badRequestIf(boolean test,
java.lang.String msg,
java.lang.Object... args) |
static void |
badRequestIfBlank(java.lang.String test) |
static void |
badRequestIfBlank(java.lang.String test,
java.lang.String msg,
java.lang.Object... args) |
static void |
badRequestIfNot(boolean test) |
static void |
badRequestIfNot(boolean test,
java.lang.String msg,
java.lang.Object... args) |
static void |
badRequestIfNull(java.lang.Object test) |
static void |
badRequestIfNull(java.lang.Object test,
java.lang.String msg,
java.lang.Object... args) |
static ZXingResult |
barcode(java.lang.String content)
Render barcode for given content
|
static org.osgl.mvc.result.RenderBinary |
binary(java.io.File file)
Returns a
RenderBinary result with a file. |
static org.osgl.mvc.result.RenderBinary |
binary(org.osgl.storage.ISObject sobj)
Returns a
RenderBinary result with an ISObject instance. |
static org.osgl.mvc.result.RenderBinary |
binary(org.osgl.Osgl.Function<java.io.OutputStream,?> outputStreamWriter)
Returns a
RenderBinary result with a delayed output stream writer. |
static org.osgl.mvc.result.Conflict |
conflict() |
static org.osgl.mvc.result.Conflict |
conflict(java.lang.String message,
java.lang.Object... args) |
static void |
conflictIf(boolean test) |
static void |
conflictIf(boolean test,
java.lang.String message,
java.lang.Object... args) |
static void |
conflictIfNot(boolean test) |
static void |
conflictIfNot(boolean test,
java.lang.String message,
java.lang.Object... args) |
static org.osgl.mvc.result.Created |
created()
Return a
Created result |
static org.osgl.mvc.result.Created |
created(java.lang.String resourceGetUrl)
Returns a
Created result |
static org.osgl.mvc.result.RenderBinary |
download(java.io.File file)
Returns a
RenderBinary result with a file. |
static org.osgl.mvc.result.RenderBinary |
download(java.io.File file,
java.lang.String attachmentName)
Returns a
RenderBinary result with a file. |
static org.osgl.mvc.result.RenderBinary |
download(java.io.InputStream inputStream,
java.lang.String attachmentName)
Returns a
RenderBinary result with an InputStream . |
static org.osgl.mvc.result.RenderBinary |
download(org.osgl.storage.ISObject sobj)
Returns a
RenderBinary result with an ISObject instance. |
static org.osgl.mvc.result.Forbidden |
forbidden()
Returns a
Forbidden result |
static org.osgl.mvc.result.Forbidden |
forbidden(java.lang.String msg,
java.lang.Object... args)
Returns a
Forbidden result with custom message template and arguments. |
static void |
forbiddenIf(boolean test)
Throws a
Forbidden result if the test condition is true |
static void |
forbiddenIf(boolean test,
java.lang.String msg,
java.lang.Object... args)
Throws a
Forbidden result if test condition is true |
static void |
forbiddenIfNot(boolean test)
Throws a
Forbidden result if the test condition is false |
static void |
forbiddenIfNot(boolean test,
java.lang.String msg,
java.lang.Object... args)
Throws a
Forbidden result if the test condition is false |
static org.osgl.mvc.result.Found |
found(java.lang.String url,
java.util.Map reverseRoutingArguments) |
static org.osgl.mvc.result.Found |
found(java.lang.String url,
java.lang.Object... args) |
static void |
foundIf(boolean test,
java.lang.String url,
java.lang.Object... args) |
static void |
foundIfNot(boolean test,
java.lang.String url,
java.lang.Object... args) |
static org.osgl.mvc.result.RenderHtml |
html(java.lang.String msg,
java.lang.Object... args)
Returns a
RenderText result with specified message template and args. |
static org.osgl.mvc.result.Result |
inferPrimitiveResult(java.lang.Object v,
ActionContext actionContext,
boolean requireJSON,
boolean requireXML,
boolean isArray) |
static org.osgl.mvc.result.Result |
inferResult(java.io.File file,
ActionContext actionContext)
Infer
Result from an File . |
static org.osgl.mvc.result.Result |
inferResult(HandlerMethodMetaInfo meta,
java.lang.Object v,
ActionContext context,
boolean hasTemplate)
Infer a
Result from a object value v: If v is null then null returned If v is instance of Result then it is returned directly to infer the Result If v is instance of InputStream then inferResult(InputStream, ActionContext) is used to infer the Result If v is instance of File then inferResult(File, ActionContext) is used to infer the Result If v is instance of Map then inferResult(Map, ActionContext) is used to infer the Result If v is an array of Object then inferResult(Object[], ActionContext) is used to infer the Result |
static org.osgl.mvc.result.Result |
inferResult(java.io.InputStream is,
ActionContext actionContext)
Infer
Result from an InputStream . |
static org.osgl.mvc.result.Result |
inferResult(org.osgl.storage.ISObject sobj,
ActionContext context) |
static org.osgl.mvc.result.Result |
inferResult(java.util.Map<java.lang.String,java.lang.Object> map,
ActionContext actionContext) |
static org.osgl.mvc.result.Result |
inferResult(java.lang.Object[] array,
ActionContext actionContext) |
static org.osgl.mvc.result.Result |
inferResult(org.osgl.mvc.result.Result r,
ActionContext actionContext) |
static org.osgl.mvc.result.RenderJSON |
json(java.lang.Object data)
Returns a
RenderJSON result with any object. |
static org.osgl.mvc.result.RenderJSON |
json(java.lang.String msg,
java.lang.Object... args)
Returns a
RenderJSON result with specified message template and args. |
static RenderJsonMap |
jsonMap(java.lang.Object... data)
Returns a
RenderJsonMap result with any object. |
static RenderJwt |
jwt() |
static org.osgl.mvc.result.MovedPermanently |
moved(java.lang.String url,
java.util.Map reverseRoutingArguments) |
static org.osgl.mvc.result.MovedPermanently |
moved(java.lang.String url,
java.lang.Object... args) |
static org.osgl.mvc.result.Result |
notAcceptable() |
static org.osgl.mvc.result.Result |
notAcceptable(java.lang.String msg,
java.lang.Object... args) |
static org.osgl.mvc.result.Result |
notFound()
Returns an
NotFound result |
static org.osgl.mvc.result.Result |
notFound(java.lang.String msg,
java.lang.Object... args)
Returns an
NotFound result with custom message template and arguments. |
static void |
notFoundIf(boolean test)
Throws out an
NotFound result if the boolean expression specified is true null |
static void |
notFoundIf(boolean test,
java.lang.String msg,
java.lang.Object... args)
Throws out an
NotFound result with custom message template and arguments if the expression specified is true . |
static void |
notFoundIfNot(boolean test)
Throws out an
NotFound result if the boolean expression specified is false null |
static void |
notFoundIfNot(boolean test,
java.lang.String msg,
java.lang.Object... args)
Throws out an
NotFound result with custom message template and arguments if the expression specified is false . |
static <T> T |
notFoundIfNull(T o)
Throws out an
NotFound result if the object specified is null |
static <T> T |
notFoundIfNull(T o,
java.lang.String msg,
java.lang.Object... args)
Throws out an
NotFound result with custom message template and arguments if the object specified is null . |
static org.osgl.mvc.result.NotModified |
notModified() |
static org.osgl.mvc.result.NotModified |
notModified(java.lang.String etag,
java.lang.Object... args) |
static org.osgl.mvc.result.Result |
ok()
Returns an
Ok result |
static ZXingResult |
qrcode(java.lang.String content)
Render QRCode for given content
|
static org.osgl.mvc.result.Redirect |
redirect(java.lang.String url,
java.util.Map reverseRoutingArguments) |
static org.osgl.mvc.result.Redirect |
redirect(java.lang.String url,
java.lang.Object... args) |
static void |
redirectIf(boolean test,
java.lang.String url,
java.util.Map reverseRoutingArguments) |
static void |
redirectIf(boolean test,
java.lang.String url,
java.lang.Object... args) |
static void |
redirectIfNot(boolean test,
java.lang.String url,
java.util.Map reverseRoutingArguments) |
static void |
redirectIfNot(boolean test,
java.lang.String url,
java.lang.Object... args) |
static RenderAny |
render(java.lang.Object... args)
The caller to this magic
render method is subject to byte code enhancement. |
static ZXingResult |
renderBarcode(java.lang.String content)
Alias of
barcode(String) |
static org.osgl.mvc.result.RenderBinary |
renderBinary(java.io.File file)
Alias of
binary(File) |
static org.osgl.mvc.result.RenderBinary |
renderBinary(org.osgl.storage.ISObject sobj)
Alias of
binary(ISObject) |
static org.osgl.mvc.result.RenderBinary |
renderBinary(org.osgl.Osgl.Function<java.io.OutputStream,?> outputStreamWriter)
Alias of
binary(Osgl.Function) |
static org.osgl.mvc.result.RenderHtml |
renderHtml(java.lang.String msg,
java.lang.Object args)
Alias of
html(String, Object...) |
static org.osgl.mvc.result.RenderJSON |
renderJson(java.lang.Object data)
Alias of
json(Object) |
static org.osgl.mvc.result.RenderJSON |
renderJson(java.lang.String msg,
java.lang.Object... args)
Alias of
json(String, Object...) |
static RenderJsonMap |
renderJsonMap(java.lang.Object... data)
Alias of
jsonMap(Object...) |
static RenderJwt |
renderJwt() |
static ZXingResult |
renderQrcode(java.lang.String content)
Alias of
qrcode(String) |
static RenderTemplate |
renderTemplate(java.util.Map<java.lang.String,java.lang.Object> args)
Alias of
template(Map) |
static RenderTemplate |
renderTemplate(java.lang.Object... args)
This method is deprecated, please use
template(Object...) instead |
static org.osgl.mvc.result.RenderText |
renderText(java.lang.String msg,
java.lang.Object... args)
Alias of
text(String, Object...) |
static org.osgl.mvc.result.RenderXML |
renderXml(java.lang.String msg,
java.lang.Object... args)
Alias of
xml(String, Object...) |
static org.osgl.mvc.result.SeeOther |
seeOther(java.lang.String url,
java.util.Map reverseRoutingArguments) |
static org.osgl.mvc.result.SeeOther |
seeOther(java.lang.String url,
java.lang.Object... args) |
static void |
seeOtherIf(boolean test,
java.lang.String url,
java.lang.Object... args) |
static void |
seeOtherIfNot(boolean test,
java.lang.String url,
java.lang.Object... args) |
static RenderTemplate |
template(java.util.Map<java.lang.String,java.lang.Object> args)
Returns a
RenderTemplate result with a render arguments map. |
static RenderTemplate |
template(java.lang.Object... args)
Kind of like
render(Object...) , the only differences is this method force to render a template without regarding to the request format |
static org.osgl.mvc.result.TemporaryRedirect |
temporaryRedirect(java.lang.String url,
java.util.Map reverseRoutingArguments) |
static org.osgl.mvc.result.TemporaryRedirect |
temporaryRedirect(java.lang.String url,
java.lang.Object... args) |
static org.osgl.mvc.result.RenderText |
text(java.lang.String msg,
java.lang.Object... args)
Returns a
RenderText result with specified message template and args. |
static org.osgl.mvc.result.Unauthorized |
unauthorized() |
static org.osgl.mvc.result.Unauthorized |
unauthorized(java.lang.String realm) |
static void |
unauthorizedIf(boolean test) |
static void |
unauthorizedIf(boolean test,
java.lang.String realm) |
static void |
unauthorizedIfNot(boolean test) |
static void |
unauthorizedIfNot(boolean test,
java.lang.String realm) |
static org.osgl.mvc.result.RenderXML |
xml(java.lang.String msg,
java.lang.Object... args)
Returns a
RenderXML result with specified message template and args. |
public static final org.osgl.mvc.result.Ok OK
public static final org.osgl.mvc.result.Created CREATED
public static final org.osgl.mvc.result.Result CREATED_JSON
public static final org.osgl.mvc.result.Result CREATED_XML
public static final org.osgl.mvc.result.Result OK_JSON
public static final org.osgl.mvc.result.Result OK_XML
public static final org.osgl.mvc.result.NoContent NO_CONTENT
public static org.osgl.mvc.result.Result ok()
Returns an Ok
result
public static org.osgl.mvc.result.Created created(java.lang.String resourceGetUrl)
Returns a Created
result
resourceGetUrl
- the URL to access the new resource been createdpublic static org.osgl.mvc.result.Created created()
Return a Created
result
public static org.osgl.mvc.result.NotModified notModified()
public static org.osgl.mvc.result.NotModified notModified(java.lang.String etag, java.lang.Object... args)
public static org.osgl.mvc.result.Result accepted(java.lang.String statusMonitorUrl)
Returns a Accepted
result
statusMonitorUrl
- the URL to check the request process statuspublic static org.osgl.mvc.result.Result notAcceptable()
public static org.osgl.mvc.result.Result notAcceptable(java.lang.String msg, java.lang.Object... args)
public static org.osgl.mvc.result.Result notFound()
Returns an NotFound
result
public static org.osgl.mvc.result.Result notFound(java.lang.String msg, java.lang.Object... args)
Returns an NotFound
result with custom message template and arguments. The final message is rendered with the template and arguments using String.format(String, Object...)
msg
- the message templateargs
- the message argumentpublic static <T> T notFoundIfNull(T o)
Throws out an NotFound
result if the object specified is null
o
- the object to be evaluatedpublic static <T> T notFoundIfNull(T o, java.lang.String msg, java.lang.Object... args)
Throws out an NotFound
result with custom message template and arguments if the object specified is null
. The final message is rendered with the template and arguments using String.format(String, Object...)
o
- the object to be evaluatedmsg
- the message templateargs
- the message argumentpublic static void notFoundIf(boolean test)
Throws out an NotFound
result if the boolean expression specified is true
null
test
- the boolean expression to be evaluatedpublic static void notFoundIf(boolean test, java.lang.String msg, java.lang.Object... args)
Throws out an NotFound
result with custom message template and arguments if the expression specified is true
. The final message is rendered with the template and arguments using String.format(String, Object...)
test
- the boolean expressionmsg
- the message templateargs
- the message argumentpublic static void notFoundIfNot(boolean test)
Throws out an NotFound
result if the boolean expression specified is false
null
test
- the boolean expression to be evaluatedpublic static void notFoundIfNot(boolean test, java.lang.String msg, java.lang.Object... args)
Throws out an NotFound
result with custom message template and arguments if the expression specified is false
. The final message is rendered with the template and arguments using String.format(String, Object...)
test
- the boolean expressionmsg
- the message templateargs
- the message argumentpublic static org.osgl.mvc.result.BadRequest badRequest()
public static org.osgl.mvc.result.BadRequest badRequest(java.lang.String msg, java.lang.Object... args)
public static void badRequestIf(boolean test)
public static void badRequestIf(boolean test, java.lang.String msg, java.lang.Object... args)
public static void badRequestIfBlank(java.lang.String test)
public static void badRequestIfBlank(java.lang.String test, java.lang.String msg, java.lang.Object... args)
public static void badRequestIfNull(java.lang.Object test)
public static void badRequestIfNull(java.lang.Object test, java.lang.String msg, java.lang.Object... args)
public static void badRequestIfNot(boolean test)
public static void badRequestIfNot(boolean test, java.lang.String msg, java.lang.Object... args)
public static org.osgl.mvc.result.Conflict conflict()
public static org.osgl.mvc.result.Conflict conflict(java.lang.String message, java.lang.Object... args)
public static void conflictIf(boolean test)
public static void conflictIf(boolean test, java.lang.String message, java.lang.Object... args)
public static void conflictIfNot(boolean test)
public static void conflictIfNot(boolean test, java.lang.String message, java.lang.Object... args)
public static org.osgl.mvc.result.Unauthorized unauthorized()
public static org.osgl.mvc.result.Unauthorized unauthorized(java.lang.String realm)
public static void unauthorizedIf(boolean test)
public static void unauthorizedIf(boolean test, java.lang.String realm)
public static void unauthorizedIfNot(boolean test)
public static void unauthorizedIfNot(boolean test, java.lang.String realm)
public static org.osgl.mvc.result.Forbidden forbidden()
Returns a Forbidden
result
public static org.osgl.mvc.result.Forbidden forbidden(java.lang.String msg, java.lang.Object... args)
Returns a Forbidden
result with custom message template and arguments. The final message is rendered with the template and arguments using String.format(String, Object...)
msg
- the message templateargs
- the message argumentpublic static void forbiddenIf(boolean test)
Throws a Forbidden
result if the test condition is true
test
- the test conditionpublic static void forbiddenIfNot(boolean test)
Throws a Forbidden
result if the test condition is false
test
- the test conditionpublic static void forbiddenIf(boolean test, java.lang.String msg, java.lang.Object... args)
Throws a Forbidden
result if test condition is true
test
- the test conditionmsg
- the message format templateargs
- the message format argumentspublic static void forbiddenIfNot(boolean test, java.lang.String msg, java.lang.Object... args)
Throws a Forbidden
result if the test condition is false
test
- the test conditionmsg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.Redirect redirect(java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.Redirect redirect(java.lang.String url, java.util.Map reverseRoutingArguments)
public static void redirectIf(boolean test, java.lang.String url, java.lang.Object... args)
public static void redirectIfNot(boolean test, java.lang.String url, java.lang.Object... args)
public static void redirectIf(boolean test, java.lang.String url, java.util.Map reverseRoutingArguments)
public static void redirectIfNot(boolean test, java.lang.String url, java.util.Map reverseRoutingArguments)
public static org.osgl.mvc.result.MovedPermanently moved(java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.MovedPermanently moved(java.lang.String url, java.util.Map reverseRoutingArguments)
public static org.osgl.mvc.result.Found found(java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.Found found(java.lang.String url, java.util.Map reverseRoutingArguments)
public static void foundIf(boolean test, java.lang.String url, java.lang.Object... args)
public static void foundIfNot(boolean test, java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.SeeOther seeOther(java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.SeeOther seeOther(java.lang.String url, java.util.Map reverseRoutingArguments)
public static void seeOtherIf(boolean test, java.lang.String url, java.lang.Object... args)
public static void seeOtherIfNot(boolean test, java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.TemporaryRedirect temporaryRedirect(java.lang.String url, java.lang.Object... args)
public static org.osgl.mvc.result.TemporaryRedirect temporaryRedirect(java.lang.String url, java.util.Map reverseRoutingArguments)
public static org.osgl.mvc.result.RenderText text(java.lang.String msg, java.lang.Object... args)
Returns a RenderText
result with specified message template and args. The final message is rendered with the template and arguments using String.format(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderText renderText(java.lang.String msg, java.lang.Object... args)
Alias of text(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderHtml html(java.lang.String msg, java.lang.Object... args)
Returns a RenderText
result with specified message template and args. The final message is rendered with the template and arguments using String.format(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderHtml renderHtml(java.lang.String msg, java.lang.Object args)
Alias of html(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderJSON json(java.lang.String msg, java.lang.Object... args)
Returns a RenderJSON
result with specified message template and args. The final message is rendered with the template and arguments using String.format(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderJSON renderJson(java.lang.String msg, java.lang.Object... args)
Alias of json(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderJSON json(java.lang.Object data)
Returns a RenderJSON
result with any object. This method will call underline JSON serializer to transform the object into a JSON string
data
- the data to be rendered as JSON stringpublic static org.osgl.mvc.result.RenderJSON renderJson(java.lang.Object data)
Alias of json(Object)
data
- the data to be rendered as JSON stringpublic static RenderJsonMap jsonMap(java.lang.Object... data)
Returns a RenderJsonMap
result with any object. This method will generate a JSON object out from the ActionContext.renderArgs()
. The response is always in JSON format and ignores the HTTP Accept
header setting
data
- the varargs of Object to be put into the JSON mappublic static RenderJsonMap renderJsonMap(java.lang.Object... data)
Alias of jsonMap(Object...)
data
- the data to be put into the JSON mappublic static RenderJwt renderJwt()
public static RenderJwt jwt()
public static org.osgl.mvc.result.RenderXML xml(java.lang.String msg, java.lang.Object... args)
Returns a RenderXML
result with specified message template and args. The final message is rendered with the template and arguments using String.format(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderXML renderXml(java.lang.String msg, java.lang.Object... args)
Alias of xml(String, Object...)
msg
- the message format templateargs
- the message format argumentspublic static org.osgl.mvc.result.RenderBinary binary(org.osgl.storage.ISObject sobj)
Returns a RenderBinary
result with an ISObject
instance. The result will render the binary using “inline” content disposition
sobj
- the ISObject
instancepublic static org.osgl.mvc.result.RenderBinary renderBinary(org.osgl.storage.ISObject sobj)
Alias of binary(ISObject)
sobj
- the ISObject
instancepublic static org.osgl.mvc.result.RenderBinary download(org.osgl.storage.ISObject sobj)
Returns a RenderBinary
result with an ISObject
instance. The result will render the binary using “attachment” content disposition
sobj
- the ISObject
instancepublic static org.osgl.mvc.result.RenderBinary binary(java.io.File file)
Returns a RenderBinary
result with a file. The result will render the binary using “inline” content disposition.
file
- the file to be renderedpublic static org.osgl.mvc.result.RenderBinary renderBinary(java.io.File file)
Alias of binary(File)
file
- the file to be renderedpublic static org.osgl.mvc.result.RenderBinary binary(org.osgl.Osgl.Function<java.io.OutputStream,?> outputStreamWriter)
Returns a RenderBinary
result with a delayed output stream writer. The result will render the binary using “inline” content disposition.
outputStreamWriter
- the delayed writerpublic static org.osgl.mvc.result.RenderBinary renderBinary(org.osgl.Osgl.Function<java.io.OutputStream,?> outputStreamWriter)
Alias of binary(Osgl.Function)
outputStreamWriter
- the delayed writerpublic static org.osgl.mvc.result.RenderBinary download(java.io.File file)
Returns a RenderBinary
result with a file. The result will render the binary using “attachment” content disposition.
file
- the file to be renderedRenderBinary
result as described abovepublic static org.osgl.mvc.result.RenderBinary download(java.io.File file, java.lang.String attachmentName)
Returns a RenderBinary
result with a file. The result will render the binary using “attachment” content disposition, with the attachmentName
as the name of the download attachment.
file
- the file to be downloadedattachmentName
- the attachment file name.RenderBinary
result as described abovepublic static org.osgl.mvc.result.RenderBinary download(java.io.InputStream inputStream, java.lang.String attachmentName)
Returns a RenderBinary
result with an InputStream
. The result will render the binary using “attachment” content disposition, with the attachmentName
as the name of the download attachment.
inputStream
- the input stream from which byte content will be written to the attachment.attachmentName
- the attachment file name.RenderBinary
result as described abovepublic static ZXingResult barcode(java.lang.String content)
Render barcode for given content
content
- the content to generate the barcodepublic static ZXingResult renderBarcode(java.lang.String content)
Alias of barcode(String)
content
- the content to generate the barcodepublic static ZXingResult qrcode(java.lang.String content)
Render QRCode for given content
content
- the content to generate the qrcodepublic static ZXingResult renderQrcode(java.lang.String content)
Alias of qrcode(String)
content
- the content to generate the barcodepublic static RenderTemplate template(java.util.Map<java.lang.String,java.lang.Object> args)
Returns a RenderTemplate
result with a render arguments map. Note the template path should be set via ActionContext.templatePath(String)
method
args
- the template argumentspublic static RenderTemplate renderTemplate(java.util.Map<java.lang.String,java.lang.Object> args)
Alias of template(Map)
args
- the template argumentspublic static RenderTemplate renderTemplate(java.lang.Object... args)
This method is deprecated, please use template(Object...)
instead
args
- template argument listpublic static RenderTemplate template(java.lang.Object... args)
Kind of like render(Object...)
, the only differences is this method force to render a template without regarding to the request format
args
- template argument listpublic static RenderAny render(java.lang.Object... args)
The caller to this magic render
method is subject to byte code enhancement. All parameter passed into this method will be put into the application context via ActionContext.renderArg(String, Object)
using the variable name found in the local variable table. If the first argument is of type String and there is no variable name associated with that variable then it will be treated as template path and get set to the context via ActionContext.templatePath(String)
method.
This method returns different render results depends on the request format
Format | Result type |
---|---|
H.Format.json | A JSON string that map the arguments to their own local variable names |
H.Format.html or any other text formats | RenderTemplate |
H.Format.pdf or any other binary format | If first argument is of type File or InputStream, then outbound the content as a binary stream, otherwise throw out UnsupportedException |
args
- any argument that can be put into the returned JSON/XML data or as template argumentspublic static org.osgl.mvc.result.Result inferResult(org.osgl.mvc.result.Result r, ActionContext actionContext)
public static org.osgl.mvc.result.Result inferPrimitiveResult(java.lang.Object v, ActionContext actionContext, boolean requireJSON, boolean requireXML, boolean isArray)
public static org.osgl.mvc.result.Result inferResult(java.util.Map<java.lang.String,java.lang.Object> map, ActionContext actionContext)
public static org.osgl.mvc.result.Result inferResult(java.lang.Object[] array, ActionContext actionContext)
array
- actionContext
- public static org.osgl.mvc.result.Result inferResult(java.io.InputStream is, ActionContext actionContext)
Infer Result
from an InputStream
. If the current context is in JSON
format then it will render a JSON
result from the content of the input stream. Otherwise, it will render a binary
result from the inputstream
is
- the inputstreamactionContext
- public static org.osgl.mvc.result.Result inferResult(java.io.File file, ActionContext actionContext)
Infer Result
from an File
. If the current context is in JSON
format then it will render a JSON
result from the content of the file. Otherwise, it will render a binary
result from the file specified
file
- the fileactionContext
- public static org.osgl.mvc.result.Result inferResult(org.osgl.storage.ISObject sobj, ActionContext context)
public static org.osgl.mvc.result.Result inferResult(HandlerMethodMetaInfo meta, java.lang.Object v, ActionContext context, boolean hasTemplate)
Infer a Result
from a object
value v:
null
then null returnedResult
then it is returned directlyResult
InputStream
then inferResult(InputStream, ActionContext)
is used to infer the Result
File
then inferResult(File, ActionContext)
is used to infer the Result
Map
then inferResult(Map, ActionContext)
is used to infer the Result
Object
then inferResult(Object[], ActionContext)
is used to infer the Result
meta
- the HandlerMethodMetaInfov
- the value to be renderedcontext
- the action contexthasTemplate
- a boolean flag indicate if the current handler method has corresponding templateCopyright © 2014–2017 ActFramework. All rights reserved.