本文整理汇总了Java中org.apache.tapestry5.json.JSONObject.put方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.put方法的具体用法?Java JSONObject.put怎么用?Java JSONObject.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tapestry5.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.put方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@GET
@Path("/validate")
@PermitAll
public Response validate( @Context Request req)
{
Subject subject;
try {
subject = securityService.getSubject();
if (subject.isAuthenticated()) {
return Response.ok().build();
}
}
catch (Exception e) {
LOG.debug("User failed to log.");
}
JSONObject JSONEntity = new JSONObject();
JSONEntity.put("message","not Authenticated");
return Response.status(Response.Status.BAD_REQUEST).entity(JSONEntity.toString()).build();
}
示例2: postLogin
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@POST
@Path("/authentication")
@Consumes("application/x-www-form-urlencoded")
@PermitAll
public Response postLogin(@FormParam("j_username") String username,@FormParam("j_password") String password) {
Response.ResponseBuilder rb;
Subject subject;
try {
subject = securityService.getSubject();
if (!subject.isAuthenticated()) {
UsernamePasswordToken token = new UsernamePasswordToken(username, password);
subject.login(token);
token.clear();
String userPassword= username + ":" + password;
String basicAuth = new String(Base64.encodeBytes(userPassword.getBytes()));
Token cltToken = new Token();
cltToken.setAccess_token("Basic "+basicAuth);
cltToken.setExpires_in(1799);
cltToken.setToken_type("bearer");
cltToken.setScope("read write");
rb = Response.ok(cltToken);
return rb.build();
} else {
LOG.debug("User [" + subject.getPrincipal() + "] already authenticated.");
if(subject.getPrincipal().toString().equals(username))
{
rb = Response.ok();
return rb.build();
}
}
} catch (Exception e) {
LOG.debug("User failed to log.");
}
JSONObject JSONEntity = new JSONObject();
JSONEntity.put("message","invalid user or password");
return Response.status(Response.Status.BAD_REQUEST).entity(JSONEntity.toString()).build();
}
示例3: afterRender
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
void afterRender(final MarkupWriter writer) {
writer.end();
JSONObject parameters = new JSONObject();
for (String informalParameterName : componentResources.getInformalParameterNames()) {
parameters.put(informalParameterName,
componentResources.getInformalParameter(informalParameterName, Object.class));
}
javaScriptSupport.require("angular2/js/a2component").with(module, clientId, parameters);
}
示例4: addApplicationConfigModule
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@Contribute(ModuleManager.class)
public static void addApplicationConfigModule(
final MappedConfiguration<String, JavaScriptModuleConfiguration> configuration, final SymbolSource symbolSource,
@Symbol(SymbolConstants.PRODUCTION_MODE) final boolean productionMode) {
final JSONObject config = new JSONObject();
for (String symbolName : new String[] { SymbolConstants.CONTEXT_PATH, SymbolConstants.EXECUTION_MODE,
SymbolConstants.PRODUCTION_MODE, SymbolConstants.START_PAGE_NAME, SymbolConstants.TAPESTRY_VERSION,
SymbolConstants.SUPPORTED_LOCALES }) {
String value = symbolSource.valueForSymbol(symbolName);
config.put(symbolName, value);
}
config.put("react-api-path", ReactAPIFilter.path);
StringBuilder sb = new StringBuilder();
sb.append("define(");
sb.append(config.toString(productionMode));
sb.append(");");
final byte[] bytes = sb.toString().getBytes(StandardCharsets.UTF_8);
configuration.add("eddyson/react/application-config", new JavaScriptModuleConfiguration(new VirtualResource() {
@Override
public InputStream openStream() throws IOException {
return new ByteArrayInputStream(bytes);
}
@Override
public String getFile() {
return "application-config.js";
}
@Override
public URL toURL() {
return null;
}
}));
}
示例5: afterRender
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
void afterRender(final MarkupWriter writer) {
writer.end();
JSONObject parameters = new JSONObject();
for (String informalParameterName : componentResources.getInformalParameterNames()) {
parameters.put(informalParameterName,
componentResources.getInformalParameter(informalParameterName, Object.class));
}
javaScriptSupport.require("eddyson/react/components/reactcomponent").with(module, clientId, parameters);
}
示例6: afterRender
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@AfterRender
public void afterRender() {
// Tell the Tapestry.Initializer to do the initializing of a Confirm,
// which it will do when the DOM has been
// fully loaded.
JSONObject spec = new JSONObject();
spec.put("elementId", clientElement.getClientId());
spec.put("message", message);
javaScriptSupport.addInitializerCall("confirm", spec);
}
示例7: afterRender
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@AfterRender
public void afterRender() {
// Tell the Tapestry.Initializer to do the initializing of a Confirm, which
// it will do when the DOM has been
// fully loaded.
JSONObject spec = new JSONObject();
spec.put("elementId", clientElement.getClientId());
spec.put("message", message);
javaScriptSupport.addInitializerCall("confirm", spec);
}
示例8: getSpecificOptions
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
@Override
public JSONObject getSpecificOptions() {
JSONObject res= new JSONObject();
if (width!=null){
res.put("width", width);
}
if (height!=null){
res.put("height", height);
}
return res;
}
示例9: getData
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
public JSONArray getData(){
JSONObject o1= new JSONObject();
o1.put("label", "one");
o1.put("value", 20.0);
JSONObject o2= new JSONObject();
o2.put("label", "two");
o2.put("value", 50.0);
JSONObject o3= new JSONObject();
o3.put("label", "three");
o3.put("value", 30.0);
return new JSONArray(o1, o2, o3);
}
示例10: getParams
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
public JSONObject getParams(){
JSONObject json = new JSONObject();
json.put("active_class", "open");// specify the class used for active sections
json.put("is_hover",false);
return json;
}
示例11: onSuccess
import org.apache.tapestry5.json.JSONObject; //导入方法依赖的package包/类
public Object onSuccess() {
if (genConfig) {
JSONObject cfg = new JSONObject();
// all default values
cfg.put("useRecordingSyncMap", "false");
cfg.put("developer_mode", "false");
cfg.put("svdrpPort", "5000");
cfg.put("remoteOsdSleepTime", "200");
cfg.put("remoteOsdIncSleepTime", "200");
cfg.put("useEpgd", String.valueOf(setup.isUseEpgd()));
cfg.put("epgVdr", setup.getEpgVdr());
// hsqldb configuration
JSONObject hsql = new JSONObject();
hsql.put("path", "/var/cache/jonglisto-db");
hsql.put("remote", "false");
cfg.put("hsqldb", hsql);
// nashorn scripts
JSONObject nashorn = new JSONObject();
nashorn.put("svdrp", "/etc/jonglisto/svdrp.js");
nashorn.put("epg2vdr", "/etc/jonglisto/epg2vdr.js");
cfg.put("NashornScripts", nashorn);
// mysql configuration
JSONObject mysql = new JSONObject();
mysql.put("url", "jdbc:mysql://" + setup.getEpgdHost() + ":" + setup.getEpgdPort() + "/" + setup.getEpgdDatabase());
mysql.put("username", setup.getEpgdUser());
mysql.put("password", setup.getEpgdPassword());
cfg.put("epg2vdr", mysql);
// aliases
JSONObject aliases = new JSONObject();
setup.getAvailableVdr().stream() //
.forEach(s -> {
aliases.put(s.getAlias(), s.getUuid());
});
cfg.put("aliases", aliases);
// VDR
setup.getAvailableVdr().stream() //
.forEach(s -> {
JSONObject vdrcfg = new JSONObject();
vdrcfg.put("uuid", s.getAlias());
vdrcfg.put("displayName", s.getDisplayName());
JSONObject vdrval = new JSONObject();
vdrval.put("TIMER_AUX", "");
vdrval.put("TIMER_MINUS_MINUTES", 10);
vdrval.put("TIMER_PLUS_MINUTES", 10);
vdrval.put("TIMER_PRIORITY", 50);
vdrval.put("TIMER_LIFETIME", 99);
vdrval.put("RECORDING_NAMING_MODE", 1);
vdrcfg.put("config", vdrval);
cfg.append("VDR", vdrcfg);
});
// Sichten
setup.getAvailableViews().stream() //
.forEach(s -> {
JSONObject sicht = new JSONObject();
sicht.put("displayName", s.getName());
sicht.put("head", s.getHead().get(0));
sicht.put("timers", s.getTimer().get(0));
s.getChannels().stream().forEach(c -> sicht.append("channels", c));
s.getRecordings().stream().forEach(r -> sicht.append("recordings", r));
cfg.append("Sichten", sicht);
});
streamResponse.setStreamContent(cfg.toString(false));
streamResponse.setStreamFilename("jonglisto.json");
streamResponse.setStreamType("text/plain");
return streamResponse;
} else {
return null;
}
}