|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.sling.api.servlets.HtmlResponse
org.apache.sling.servlets.post.impl.helper.JSONResponse
public class JSONResponse
Represents a JSON response to be sent to the client. For backward compatibility,
this extends HtmlResponse
.
Nested Class Summary | |
---|---|
class |
JSONResponse.JSONResponseException
|
Field Summary | |
---|---|
static String |
RESPONSE_CONTENT_TYPE
|
Fields inherited from class org.apache.sling.api.servlets.HtmlResponse |
---|
PN_CHANGE_LOG, PN_ERROR, PN_IS_CREATED, PN_LOCATION, PN_PARENT_LOCATION, PN_PATH, PN_REFERER, PN_STATUS_CODE, PN_STATUS_MESSAGE, PN_TITLE |
Constructor Summary | |
---|---|
JSONResponse()
|
Method Summary | |
---|---|
Throwable |
getError()
Returns any recorded error or null |
Object |
getProperty(String name)
Returns the generic response property with the given name and type or null if no such property exists. |
void |
onChange(String type,
String... arguments)
Records a generic change of the given type . |
void |
send(javax.servlet.http.HttpServletResponse response,
boolean setStatus)
Writes the response to the given writer and replaces all ${var} patterns by the value of the respective property. |
void |
setCreateRequest(boolean isCreateRequest)
Sets whether the request was a create request or not. |
void |
setError(Throwable error)
|
void |
setProperty(String name,
Object value)
Sets a generic response property with the given |
Methods inherited from class org.apache.sling.api.servlets.HtmlResponse |
---|
getLocation, getParentLocation, getPath, getProperty, getReferer, getStatusCode, getStatusMessage, isCreateRequest, isSuccessful, onCopied, onCreated, onDeleted, onModified, onMoved, setLocation, setParentLocation, setPath, setReferer, setStatus, setTitle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String RESPONSE_CONTENT_TYPE
Constructor Detail |
---|
public JSONResponse() throws JSONResponse.JSONResponseException
JSONResponse.JSONResponseException
Method Detail |
---|
public void onChange(String type, String... arguments) throws JSONResponse.JSONResponseException
HtmlResponse
type
.
The change is added to the internal list of changes with the syntax of a
method call, where the type
is the method name and the
arguments
are the string arguments to the method enclosed in
double quotes. For example, the the call
onChange("sameple", "arg1", "arg2");is aded as
sample("arg1", "arg2")to the internal list of changes.
onChange
in class HtmlResponse
type
- The type of the modificationarguments
- The arguments to the modifications
JSONResponse.JSONResponseException
public void setError(Throwable error)
setError
in class HtmlResponse
public Throwable getError()
HtmlResponse
null
getError
in class HtmlResponse
null
public void setCreateRequest(boolean isCreateRequest)
HtmlResponse
setCreateRequest
in class HtmlResponse
public void setProperty(String name, Object value)
HtmlResponse
setProperty
in class HtmlResponse
name
- name of the propertyvalue
- value of the propertypublic Object getProperty(String name) throws JSONResponse.JSONResponseException
HtmlResponse
null
if no such property exists.
getProperty
in class HtmlResponse
JSONResponse.JSONResponseException
public void send(javax.servlet.http.HttpServletResponse response, boolean setStatus) throws IOException
HtmlResponse
send
in class HtmlResponse
response
- to send tosetStatus
- whether to set the status code on the response
IOException
- if an i/o exception occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |