本文整理了Java中org.apache.tapestry5.json.JSONArray.<init>()
方法的一些代码示例,展示了JSONArray.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONArray.<init>()
方法的具体详情如下:
包路径:org.apache.tapestry5.json.JSONArray
类名称:JSONArray
方法名:<init>
[英]Creates a JSONArray with no values.
[中]创建没有值的JSONArray。
代码示例来源:origin: json-path/JsonPath
@Override
public Object createArray() {
return new JSONArray();
}
代码示例来源:origin: com.jayway.jsonpath/json-path
@Override
public Object createArray() {
return new JSONArray();
}
代码示例来源:origin: com.github.lafa.jsonpath/json-path
@Override
public Object createArray() {
return new JSONArray();
}
代码示例来源:origin: org.apache.tapestry/tapestry-json
@Override
public JSONArray coerce(String input) {
return new JSONArray(input);
}
}
代码示例来源:origin: apache/tapestry-5
@Override
public JSONArray coerce(String input) {
return new JSONArray(input);
}
}
代码示例来源:origin: apache/tapestry-5
public void with(Object... arguments)
{
assert arguments != null;
this.arguments = new JSONArray(arguments);
}
}
代码示例来源:origin: apache/tapestry-5
/**
* Create a new array, and adds all values fro the iterable to the array (using {@link #putAll(Iterable)}.
*
* This is implemented as a static method so as not to break the semantics of the existing {@link #JSONArray(Object...)} constructor.
* Adding a constructor of type Iterable would change the meaning of <code>new JSONArray(new JSONArray())</code>.
*
* @param iterable
* collection ot value to include, or null
* @since 5.4
*/
public static JSONArray from(Iterable<?> iterable)
{
return new JSONArray().putAll(iterable);
}
代码示例来源:origin: org.apache.tapestry/tapestry-json
/**
* Create a new array, and adds all values fro the iterable to the array (using {@link #putAll(Iterable)}.
*
* This is implemented as a static method so as not to break the semantics of the existing {@link #JSONArray(Object...)} constructor.
* Adding a constructor of type Iterable would change the meaning of <code>new JSONArray(new JSONArray())</code>.
*
* @param iterable
* collection ot value to include, or null
* @since 5.4
*/
public static JSONArray from(Iterable<?> iterable)
{
return new JSONArray().putAll(iterable);
}
代码示例来源:origin: org.got5/tapestry5-jquery
public DefaultDataTableModel(
TypeCoercer typeCoercer,
TranslatorSource translatorSource,
PageRenderQueue pageRenderQueue,
AjaxFormUpdateController ajaxFormUpdateController,
AjaxPartialResponseRenderer partialRenderer,
FakeInheritedBinding row, FakeInheritedBinding rowIndex) {
super();
this.typeCoercer = typeCoercer;
this.translatorSource = translatorSource;
this.pageRenderQueue = pageRenderQueue;
this.ajaxFormUpdateController = ajaxFormUpdateController;
this.partialRenderer = partialRenderer;
this.rowParam = row;
this.rowIndexParam = rowIndex;
response = new JSONObject();
rows = new JSONArray() ;
}
代码示例来源:origin: org.got5/tapestry5-jquery
/**
* Transforms the matches into a JSONArray
*
* @return JSONArray of available responses
*/
protected JSONArray generateResponseJSON(List matches)
{
JSONArray array = new JSONArray();
for (Object o : matches)
{
if (o instanceof JSONObject) array.put(o);
else array.put(o.toString());
}
return array;
}
}
代码示例来源:origin: apache/tapestry-5
private String convert(List<?> input)
{
return new JSONArray().putAll(input).toString(compactJSON);
}
代码示例来源:origin: apache/tapestry-5
public void addScript(InitializationPriority priority, String script)
{
addInitialization(priority, "t5/core/pageinit", "evalJavaScript", new JSONArray().put(script));
}
代码示例来源:origin: apache/tapestry-5
public String getInitialJSON()
{
JSONArray array = new JSONArray();
for (Object o : selected)
{
String value = encoder.toClient(o);
array.put(value);
}
return array.toString(compactJSON);
}
代码示例来源:origin: apache/tapestry-5
private boolean selected(String clientId, String elementName)
{
// Case #1: via JavaScript, the client id is passed up.
String raw = request.getParameter(Form.SUBMITTING_ELEMENT_ID);
if (InternalUtils.isNonBlank(raw) &&
new JSONArray(raw).getString(0).equals(clientId))
{
return true;
}
// Case #2: No JavaScript, look for normal semantic (non-null value for the element's name).
// If configured as an image submit, look for a value for the x position. Ah, the ugliness
// of HTML.
String name = image == null ? elementName : elementName + ".x";
String value = request.getParameter(name);
return value != null;
}
代码示例来源:origin: apache/tapestry-5
private void addPublishEventInfo(Flow<EventHandlerMethod> eventHandlerMethods,
MutableComponentModel model)
{
JSONArray publishEvents = new JSONArray();
for (EventHandlerMethod eventHandlerMethod : eventHandlerMethods)
{
if (eventHandlerMethod.publishEvent != null)
{
publishEvents.put(eventHandlerMethod.eventType.toLowerCase());
}
}
// If we do have events to publish, we apply the mixin and pass
// event information to it.
if (publishEvents.length() > 0) {
model.addMixinClassName(PublishServerSideEvents.class.getName(), "after:*");
model.setMeta(InternalConstants.PUBLISH_COMPONENT_EVENTS_META, publishEvents.toString());
}
}
代码示例来源:origin: fabienrenaud/java-json-benchmark
@Override
public org.apache.tapestry5.json.JSONObject tapestry(final Users obj) throws IOException {
org.apache.tapestry5.json.JSONObject jso = new org.apache.tapestry5.json.JSONObject();
if (obj.users != null) {
org.apache.tapestry5.json.JSONArray jsarr = new org.apache.tapestry5.json.JSONArray();
for (User u : obj.users) {
jsarr.put(tapestry(u));
}
jso.put("users", jsarr);
}
return jso;
}
代码示例来源:origin: apache/tapestry-5
private void processSubmission(String clientId)
{
this.clientId = clientId;
String raw = request.getParameter(Form.SUBMITTING_ELEMENT_ID);
if (InternalUtils.isNonBlank(raw) && new JSONArray(raw).getString(0).equals(clientId))
{
Runnable notification = new Runnable()
{
public void run()
{
resources.triggerEvent(event, context, eventCallback);
}
};
if (defer)
formSupport.defer(notification);
else
heartbeat.defer(notification);
}
}
代码示例来源:origin: apache/tapestry-5
private boolean isFormCancelled()
{
// The "cancel" query parameter is reserved for this purpose; if it is present then the form was canceled on the
// client side. For image submits, there will be two parameters: "cancel.x" and "cancel.y".
if (request.getParameter(InternalConstants.CANCEL_NAME) != null ||
request.getParameter(InternalConstants.CANCEL_NAME + ".x") != null)
{
return true;
}
// When JavaScript is involved, it's more complicated. In fact, this is part of HLS's desire
// to have all forms submit via XHR when JavaScript is present, since it would provide
// an opportunity to get the submitting element's value into the request properly.
String raw = request.getParameter(SUBMITTING_ELEMENT_ID);
if (InternalUtils.isNonBlank(raw) &&
new JSONArray(raw).getString(1).equals(InternalConstants.CANCEL_NAME))
{
return true;
}
return false;
}
代码示例来源:origin: apache/tapestry-5
@Test
public void response_sent() throws IOException
{
String encoding = "UTF-8";
Response response = mockResponse();
CharArrayWriter writer = new CharArrayWriter();
PrintWriter pw = new PrintWriter(writer);
expect(response.getPrintWriter("application/json;charset=UTF-8")).andReturn(pw);
replay();
JSONArray array = new JSONArray(" [ \"fred\", \"barney\" \n\n]");
JSONArrayEventResultProcessor p = new JSONArrayEventResultProcessor(response, encoding, false);
p.processResultValue(array);
verify();
assertEquals(writer.toString(), "[\n \"fred\",\n \"barney\"\n]");
}
}
代码示例来源:origin: org.got5/tapestry5-jquery
void beginRender(MarkupWriter writer)
{
JSONArray selectedValues = new JSONArray();
for (OptionModel selected : selectedOptions)
{
Object value = selected.getValue();
String clientValue = encoder.toClient(value);
selectedValues.put(clientValue);
}
JSONArray naturalOrder = new JSONArray();
for (String value : this.naturalOrder)
{
naturalOrder.put(value);
}
String clientId = getClientId();
JSONObject options = new JSONObject();
options.put("id", clientId);
options.put("reorder", reorder);
options.put("naturalOrder", naturalOrder);
javascriptSupport.require("tjq/palette").with(options);
writer.element("input", "type", "hidden", "id", clientId + "-values", "name", getControlName() + "-values",
"value", selectedValues);
writer.end();
}
内容来源于网络,如有侵权,请联系作者删除!