当前位置: 首页>>代码示例>>Java>>正文


Java DynamicForm类代码示例

本文整理汇总了Java中play.data.DynamicForm的典型用法代码示例。如果您正苦于以下问题:Java DynamicForm类的具体用法?Java DynamicForm怎么用?Java DynamicForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DynamicForm类属于play.data包,在下文中一共展示了DynamicForm类的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();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:UserController.java

示例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();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:UserController.java

示例3: createInspection

import play.data.DynamicForm; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("TEACHER")})
public Result createInspection() {
    DynamicForm df = formFactory.form().bindFromRequest();
    Long examId = Long.parseLong(df.get("examId"));
    Exam exam = Ebean.find(Exam.class, examId);
    if (exam == null) {
        return notFound("sitnet_error_exam_not_found");
    }
    if (exam.getLanguageInspection() != null) {
        return forbidden("already sent for inspection");
    }
    if (!exam.getSubjectToLanguageInspection()) {
        return forbidden("not allowed to send for inspection");
    }
    LanguageInspection inspection = new LanguageInspection();
    User user = getLoggedUser();
    AppUtil.setCreator(inspection, user);
    inspection.setExam(exam);
    inspection.save();
    return ok();
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:LanguageInspectionController.java

示例4: registerExamWithoutRecord

import play.data.DynamicForm; //导入依赖的package包/类
@Restrict({@Group("TEACHER"), @Group("ADMIN")})
public Result registerExamWithoutRecord() throws IOException {
    DynamicForm df = formFactory.form().bindFromRequest();
    final Exam exam = Ebean.find(Exam.class)
            .fetch("languageInspection")
            .fetch("parent")
            .fetch("parent.creator")
            .where()
            .idEq(Long.parseLong(df.get("id"))).findUnique();
    return validateExamState(exam, false).orElseGet(() -> {
        exam.setState(Exam.State.GRADED_LOGGED);
        exam.setGrade(null);
        exam.setGradeless(true);
        exam.update();
        return ok();
    });
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:18,代码来源:ExamRecordController.java

示例5: answerEssay

import play.data.DynamicForm; //导入依赖的package包/类
@ActionMethod
public Result answerEssay(String hash, Long questionId) {
    return getEnrolmentError(hash).orElseGet(() -> {
        DynamicForm df = formFactory.form().bindFromRequest();
        String essayAnswer = df.get("answer");
        ExamSectionQuestion question = Ebean.find(ExamSectionQuestion.class, questionId);
        if (question == null) {
            return forbidden();
        }
        EssayAnswer answer = question.getEssayAnswer();
        if (answer == null) {
            answer = new EssayAnswer();
        } else if (df.get("objectVersion") != null) {
            long objectVersion = Long.parseLong(df.get("objectVersion"));
            answer.setObjectVersion(objectVersion);
        }
        answer.setAnswer(essayAnswer);
        answer.save();
        question.setEssayAnswer(answer);
        question.save();
        return ok(answer);
    });
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:24,代码来源:StudentExamController.java

示例6: 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));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:22,代码来源:ReviewController.java

示例7: addInspectionComment

import play.data.DynamicForm; //导入依赖的package包/类
@Restrict({@Group("ADMIN"), @Group("TEACHER")})
public Result addInspectionComment(Long id) {
    Exam exam = Ebean.find(Exam.class, id);
    if (exam == null) {
        return notFound("Inspection not found");
    }
    DynamicForm df = formFactory.form().bindFromRequest();
    InspectionComment ic = new InspectionComment();
    User user = getLoggedUser();
    AppUtil.setCreator(ic, user);
    AppUtil.setModifier(ic, user);
    ic.setComment(df.get("comment"));
    ic.setExam(exam);
    ic.save();
    return ok(ic, PathProperties.parse("(creator(firstName, lastName, email), created, comment)"));
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:ReviewController.java

示例8: 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();
}
 
开发者ID:chengxp3,项目名称:galaxy,代码行数:26,代码来源:DrawController.java

示例9: 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();
}
 
开发者ID:chengxp3,项目名称:galaxy,代码行数:24,代码来源:DrawController.java

示例10: createList

import play.data.DynamicForm; //导入依赖的package包/类
public Result createList() {
	
	DynamicForm form = Form.form().bindFromRequest();
	String contentId = form.data().get("contentId");
	String choiceId = form.data().get("choiceId");
	
	String[] choiceList = choiceId.split(",");
	
	Status simpleResult = null;
	for (String choice : choiceList) {
		simpleResult = (Status)saveResult(new ActivityResult(), contentId, choice);
		
		if (simpleResult.getWrappedSimpleResult().header().status() != 200) {
			return simpleResult;
		}
	}
	
	return ok();
}
 
开发者ID:chengxp3,项目名称:galaxy,代码行数:20,代码来源:ActivityResultController.java

示例11: 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();
}
 
开发者ID:chengxp3,项目名称:galaxy,代码行数:20,代码来源:WxController.java

示例12: errorsAsJson

import play.data.DynamicForm; //导入依赖的package包/类
@Test
public void errorsAsJson() {
    running(fakeApplication(), new Runnable() {
        @Override
        public void run() {
            Lang lang = new Lang(new play.api.i18n.Lang("en", ""));
            
            Map<String, List<ValidationError>> errors = new HashMap<String, List<ValidationError>>();
            List<ValidationError> error = new ArrayList<ValidationError>();
            error.add(new ValidationError("foo", RequiredValidator.message, new ArrayList<Object>()));
            errors.put("foo", error);
            
            DynamicForm form = new DynamicForm(new HashMap<String, String>(), errors, F.None());
            
            JsonNode jsonErrors = form.errorsAsJson(lang);
            assertThat(jsonErrors.findPath("foo").iterator().next().asText()).isEqualTo(play.i18n.Messages.get(lang, RequiredValidator.message));
        }
    });
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:20,代码来源:SimpleTest.java

示例13: 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;
}
 
开发者ID:linkedin,项目名称:dr-elephant,代码行数:21,代码来源:Application.java

示例14: 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));
}
 
开发者ID:linkedin,项目名称:dr-elephant,代码行数:31,代码来源:Application.java

示例15: 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());
}
 
开发者ID:peerdavid,项目名称:ComeAndGo,代码行数:20,代码来源:TimeOffController.java


注:本文中的play.data.DynamicForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。