本文整理汇总了Java中play.data.DynamicForm.get方法的典型用法代码示例。如果您正苦于以下问题:Java DynamicForm.get方法的具体用法?Java DynamicForm.get怎么用?Java DynamicForm.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.data.DynamicForm
的用法示例。
在下文中一共展示了DynamicForm.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: grantUserPermission
import play.data.DynamicForm; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result grantUserPermission() {
DynamicForm df = formFactory.form().bindFromRequest();
String permissionString = df.get("permission");
User user = Ebean.find(User.class, df.get("id"));
if (user == null) {
return notFound();
}
if (user.getPermissions().stream().noneMatch(p -> p.getValue().equals(permissionString))) {
Permission.Type type;
try {
type = Permission.Type.valueOf(permissionString);
} catch (IllegalArgumentException e) {
return badRequest();
}
Permission permission = Ebean.find(Permission.class).where().eq("type", type).findUnique();
user.getPermissions().add(permission);
user.update();
}
return ok();
}
示例2: revokeUserPermission
import play.data.DynamicForm; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result revokeUserPermission() {
DynamicForm df = formFactory.form().bindFromRequest();
String permissionString = df.get("permission");
User user = Ebean.find(User.class, df.get("id"));
if (user == null) {
return notFound();
}
if (user.getPermissions().stream().anyMatch(p -> p.getValue().equals(permissionString))) {
Permission permission = Ebean.find(Permission.class).where()
.eq("type", Permission.Type.valueOf(permissionString))
.findUnique();
user.getPermissions().remove(permission);
user.update();
}
return ok();
}
示例3: scoreExamQuestion
import play.data.DynamicForm; //导入方法依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result scoreExamQuestion(Long id) {
DynamicForm df = formFactory.form().bindFromRequest();
ExamSectionQuestion essayQuestion = Ebean.find(ExamSectionQuestion.class, id);
if (essayQuestion == null) {
return notFound("question not found");
}
EssayAnswer answer = essayQuestion.getEssayAnswer();
if (answer == null) {
// Question was not answered at all.
answer = new EssayAnswer();
answer.save();
essayQuestion.setEssayAnswer(answer);
essayQuestion.update();
}
String essayScore = df.get("evaluatedScore");
Double score = essayScore == null ? null : Double.parseDouble(essayScore);
answer.setEvaluatedScore(round(score));
answer.update();
return ok(Json.toJson(essayQuestion));
}
示例4: saveShareRecord
import play.data.DynamicForm; //导入方法依赖的package包/类
public Result saveShareRecord() {
DynamicForm form = Form.form().bindFromRequest();
String userId = form.get("userId");
String appId = form.get("appId");
String url = form.get("url");
try {
ShareRecord shareRecord = new ShareRecord();
shareRecord.id = CodeGenerator.GenerateUUId();
shareRecord.app = Application.find.byId(appId);
shareRecord.appId = appId;
shareRecord.account = Account.find.byId(userId);
shareRecord.userId = userId;
shareRecord.share_url = url;
shareRecord.create_time = new Date();
Ebean.save(shareRecord);
return ok();
}
catch (Throwable e) {
Logger.info("erroR:" + e.getMessage());
}
return ok();
}
示例5: saveShareLog
import play.data.DynamicForm; //导入方法依赖的package包/类
public Result saveShareLog() {
DynamicForm form = Form.form().bindFromRequest();
String domain = form.get("domain");
String path = form.get("path");
String userId = form.get("userId");
String shareBy = form.get("SharedBy");
try {
ShareLog log = new ShareLog();
log.domain = domain;
log.path = path;
log.userId = userId;
log.shareBy = shareBy;
log.create_time = new Date();
Ebean.save(log);
}
catch (Throwable e) {
}
return ok();
}
示例6: login
import play.data.DynamicForm; //导入方法依赖的package包/类
public Result login() {
String header = request().getHeader("Origin");
header = (header == null ? "*" : header);
response().setHeader("Access-Control-Allow-Origin", header);
response().setHeader("Access-Control-Allow-Credentials", "true");
response().setHeader("Access-Control-Allow-Methods", "POST,GET,PUT,DELETE,OPTIONS");
DynamicForm form = Form.form().bindFromRequest();
String userId = form.get("userId");
String appId = form.get("appId");
session("userId", userId);
session("appId", appId);
//Logger.info("from login: userId: " + userId + " appId: " + appId);
return ok();
}
示例7: getSearchParams
import play.data.DynamicForm; //导入方法依赖的package包/类
public static Map<String, String> getSearchParams() {
Map<String, String> searchParams = new HashMap<String, String>();
DynamicForm form = Form.form().bindFromRequest(request());
String username = form.get(USERNAME);
username = username != null ? username.trim().toLowerCase() : null;
searchParams.put(USERNAME, username);
String queuename = form.get(QUEUE_NAME);
queuename = queuename != null ? queuename.trim().toLowerCase() : null;
searchParams.put(QUEUE_NAME, queuename);
searchParams.put(SEVERITY, form.get(SEVERITY));
searchParams.put(JOB_TYPE, form.get(JOB_TYPE));
searchParams.put(ANALYSIS, form.get(ANALYSIS));
searchParams.put(FINISHED_TIME_BEGIN, form.get(FINISHED_TIME_BEGIN));
searchParams.put(FINISHED_TIME_END, form.get(FINISHED_TIME_END));
searchParams.put(STARTED_TIME_BEGIN, form.get(STARTED_TIME_BEGIN));
searchParams.put(STARTED_TIME_END, form.get(STARTED_TIME_END));
return searchParams;
}
示例8: getHelp
import play.data.DynamicForm; //导入方法依赖的package包/类
/**
* Returns the help based on the version
*
* @param version The version for which help page has to be returned
* @return The help page based on the version
*/
private static Result getHelp(Version version) {
DynamicForm form = Form.form().bindFromRequest(request());
String topic = form.get("topic");
Html page = null;
String title = "Help";
if (topic != null && !topic.isEmpty()) {
// check if it is a heuristic help
page = ElephantContext.instance().getHeuristicToView().get(topic);
// check if it is a metrics help
if (page == null) {
page = getMetricsNameView().get(topic);
}
if (page != null) {
title = topic;
}
}
if (version.equals(Version.NEW)) {
return ok(helpPage.render(title, page));
}
return ok(oldHelpPage.render(title, page));
}
示例9: createTimeOff
import play.data.DynamicForm; //导入方法依赖的package包/类
@RequiresAuthentication(clientName = "default")
public Result createTimeOff() throws Exception {
// Load user from session
CommonProfile profile = getUserProfile();
int userId = Integer.parseInt(profile.getId());
// Bind request parameters
DynamicForm form = Form.form().bindFromRequest();
String comment = form.get("comment");
TimeOffType type = TimeOffType.valueOf(form.get("type"));
DateTime from = DateTimeUtils.stringToDateTime(form.get("from"));
DateTime to = DateTimeUtils.endOfDay(DateTimeUtils.stringToDateTime(form.get("to")));
// Call business logic
createTimeOffForGivenType(userId, type, from, to, comment);
return redirect(routes.TimeOffController.index());
}
示例10: signUp
import play.data.DynamicForm; //导入方法依赖的package包/类
public static Result signUp() {
DynamicForm loginForm = form().bindFromRequest();
String username = loginForm.get("inputName");
String firstName = loginForm.get("inputFirstName");
String lastName = loginForm.get("inputLastName");
String email = loginForm.get("inputEmail");
String password = loginForm.get("inputPassword");
String errorMessage = "";
try {
errorMessage = UserDAO.signUp(username, firstName, lastName, email, password);
if (StringUtils.isNotBlank(errorMessage)) {
flash("error", errorMessage);
} else {
flash("success", "Congratulations! Your account has been created. Please login.");
}
} catch (Exception e) {
flash("error", e.getMessage());
}
return serveAsset("");
}
示例11: clientAutoCompleteList
import play.data.DynamicForm; //导入方法依赖的package包/类
@Authenticated(LoggedIn.class)
@Transactional(readOnly = true)
public Result clientAutoCompleteList() {
response().setHeader("Access-Control-Allow-Origin", "*");
DynamicForm form = DynamicForm.form().bindFromRequest();
UserInfo user = userService.findUserByUserJid(IdentityUtils.getUserJid());
String term = form.get("term");
List<Client> clients = clientService.findAllClientByTerm(term);
ImmutableList.Builder<AutoComplete> responseBuilder = ImmutableList.builder();
for (Client client : clients) {
responseBuilder.add(new AutoComplete(client.getJid(), client.getName(), client.getName()));
}
return ok(Json.toJson(responseBuilder.build()));
}
示例12: linkedClientList
import play.data.DynamicForm; //导入方法依赖的package包/类
@Authenticated(LoggedIn.class)
@Transactional(readOnly = true)
public Result linkedClientList() {
response().setHeader("Access-Control-Allow-Origin", "*");
response().setContentType("application/javascript");
DynamicForm form = DynamicForm.form().bindFromRequest();
String callback = form.get("callback");
String referer = request().getHeader("Referer");
ImmutableMap.Builder<String, String> clientMapBuilder = ImmutableMap.builder();
if (!referer.startsWith(JophielProperties.getInstance().getJophielBaseUrl())) {
clientMapBuilder.put(JophielProperties.getInstance().getJophielBaseUrl(), JudgelsPlayProperties.getInstance().getAppTitle());
}
for (int i=0;i<JophielProperties.getInstance().getJophielClientLabels().size();++i) {
String target = JophielProperties.getInstance().getJophielClientTargets().get(i);
String label = JophielProperties.getInstance().getJophielClientLabels().get(i);
if (!referer.startsWith(target)) {
clientMapBuilder.put(target, label);
}
}
return ok(callback + "(" + Json.toJson(clientMapBuilder.build()).toString() + ")");
}
示例13: userAutoCompleteList
import play.data.DynamicForm; //导入方法依赖的package包/类
@Authenticated(LoggedIn.class)
@Transactional(readOnly = true)
public Result userAutoCompleteList() {
response().setHeader("Access-Control-Allow-Origin", "*");
response().setContentType("application/javascript");
DynamicForm form = DynamicForm.form().bindFromRequest();
UserInfo user = userService.findUserByUserJid(IdentityUtils.getUserJid());
String term = form.get("term");
List<UserInfo> users = userService.findAllUserByTerm(term);
ImmutableList.Builder<AutoComplete> responseBuilder = ImmutableList.builder();
for (UserInfo user1 : users) {
responseBuilder.add(new AutoComplete(user1.getJid(), user1.getUsername(), user1.getUsername() + " (" + user1.getName() + ")"));
}
String callback = form.get("callback");
return ok(callback + "(" + Json.toJson(responseBuilder.build()).toString() + ")");
}
示例14: userInfo
import play.data.DynamicForm; //导入方法依赖的package包/类
@Transactional(readOnly = true)
public Result userInfo() {
DynamicForm form = DynamicForm.form().bindFromRequest();
String token;
if ((request().getHeader("Authorization") != null) && ("Bearer".equals(request().getHeader("Authorization").split(" ")[0]))) {
token = new String(Base64.decodeBase64(request().getHeader("Authorization").split(" ")[1]));
} else {
token = form.get("token");
}
if (clientService.isValidAccessTokenExist(token)) {
AccessToken accessToken = clientService.findAccessTokenByAccessToken(token);
UserInfo user = userService.findUserByUserJid(accessToken.getUserJid());
ObjectNode result = Json.newObject();
result.put("sub", user.getJid());
result.put("name", user.getName());
result.put("preferred_username", user.getUsername());
result.put("email", user.getEmail());
result.put("picture", user.getProfilePictureUrl().toString());
return ok(result);
} else {
ObjectNode node = Json.newObject();
node.put("error", "invalid_token");
return unauthorized(node);
}
}
示例15: postPoll
import play.data.DynamicForm; //导入方法依赖的package包/类
/**
* Handle POST requests at `/poll`. Expects a `question` form parameter.
* @return A SEE_OTHER redirect on success, Bad Request response otherwise.
*/
public static Result postPoll() {
/* Parse the request and check for all required parameters. */
DynamicForm requestData = Form.form().bindFromRequest();
String question = requestData.get("question");
String choicesString = requestData.get("choices");
if (question == null || choicesString == null) {
return badRequest();
}
/* Create the poll and put it in our cache. */
List<String> choices = Arrays.asList(choicesString.split("\n"));
Poll poll = createPoll(question, choices);
putPollIntoCache(poll);
return ok(Json.toJson(poll));
}