Here are the examples of the java api play.data.DynamicForm taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
6 Examples
18
Source : BundleSubmissionStore.java
with GNU General Public License v2.0
from ia-toki
with GNU General Public License v2.0
from ia-toki
public BundleAnswer createBundleAnswerFromNewSubmission(DynamicForm data, String languageCode) {
return new BundleAnswer.Builder().answers(data.rawData()).languageCode(languageCode).build();
}
18
Source : AbstractJudgelsAPIController.java
with GNU General Public License v2.0
from ia-toki
with GNU General Public License v2.0
from ia-toki
protected Result okAsJson(Http.Request req, Object responseBody) {
String finalResponseBody;
try {
finalResponseBody = mapper.writeValuereplacedtring(responseBody);
} catch (IOException e) {
return internalServerError(e.getMessage());
}
DynamicForm dForm = formFactory.form().bindFromRequest(req);
String callback = dForm.get("callback");
if (callback != null) {
return ok(callback + "(" + finalResponseBody + ");").as("application/javascript");
} else {
return ok(finalResponseBody).as("application/json");
}
}
17
Source : ApplicantProgramBlocksController.java
with Apache License 2.0
from seattle-uat
with Apache License 2.0
from seattle-uat
public CompletionStage<Result> update(Request request, long applicantId, long programId, long blockId) {
DynamicForm form = formFactory.form().bindFromRequest(request);
ImmutableMap<String, String> formData = cleanForm(form.rawData());
return applicantService.stageAndUpdateIfValid(applicantId, programId, blockId, formData).thenComposeAsync((errorAndROApplicantProgramService) -> {
if (errorAndROApplicantProgramService.isError()) {
errorAndROApplicantProgramService.getErrors().forEach(e -> logger.error("Exception while updating applicant data", e));
return supplyAsync(() -> badRequest("Unable to process this request"));
}
ReadOnlyApplicantProgramService roApplicantProgramService = errorAndROApplicantProgramService.getResult();
return update(request, applicantId, programId, blockId, roApplicantProgramService);
}, httpExecutionContext.current()).exceptionally(ex -> {
if (ex instanceof CompletionException) {
Throwable cause = ex.getCause();
if (cause instanceof ProgramNotFoundException) {
return badRequest(cause.toString());
} else if (cause instanceof ProgramBlockNotFoundException) {
logger.error("Exception while updating applicant data", cause);
return badRequest("Unable to process this request");
}
throw new RuntimeException(cause);
}
throw new RuntimeException(ex);
});
}
15
Source : AdminProgramBlockQuestionsController.java
with Apache License 2.0
from seattle-uat
with Apache License 2.0
from seattle-uat
@Secure(authorizers = Labels.UAT_ADMIN)
public Result destroy(Request request, long programId, long blockId) {
DynamicForm requestData = formFactory.form().bindFromRequest(request);
ImmutableList<Long> questionIds = requestData.rawData().entrySet().stream().filter(formField -> formField.getKey().startsWith("block-question-")).map(formField -> Long.valueOf(formField.getValue())).collect(ImmutableList.toImmutableList());
try {
programService.removeQuestionsFromBlock(programId, blockId, questionIds);
} catch (ProgramNotFoundException e) {
return notFound(String.format("Program ID %d not found.", programId));
} catch (ProgramBlockNotFoundException e) {
return notFound(String.format("Block ID %d not found for Program %d", blockId, programId));
} catch (QuestionNotFoundException e) {
return notFound(String.format("Question ID %s not found", questionIds));
}
return redirect(controllers.admin.routes.AdminProgramBlocksController.edit(programId, blockId));
}
15
Source : BundleProblemSubmissionController.java
with GNU General Public License v2.0
from ia-toki
with GNU General Public License v2.0
from ia-toki
@Transactional
public Result postSubmit(Http.Request req, long problemId) {
String actorJid = getUserJid(req);
Problem problem = checkFound(problemStore.findProblemById(problemId));
boolean isClean = !problemStore.userCloneExists(actorJid, problem.getJid());
checkAllowed(problemRoleChecker.isAllowedToSubmit(req, problem) && isClean);
DynamicForm dForm = formFactory.form().bindFromRequest(req);
BundleAnswer bundleAnswer = bundleSubmissionStore.createBundleAnswerFromNewSubmission(dForm, getCurrentStatementLanguage(req));
String submissionJid = bundleSubmissionStore.submit(problem.getJid(), null, bundleAnswer);
bundleSubmissionStore.storeSubmissionFiles(bundleSubmissionFs, null, submissionJid, bundleAnswer);
return redirect(routes.BundleProblemSubmissionController.viewSubmissions(problem.getId()));
}
14
Source : AdminProgramBlockQuestionsController.java
with Apache License 2.0
from seattle-uat
with Apache License 2.0
from seattle-uat
@Secure(authorizers = Labels.UAT_ADMIN)
public Result create(Request request, long programId, long blockId) {
DynamicForm requestData = formFactory.form().bindFromRequest(request);
ImmutableList<Long> questionIds = requestData.rawData().entrySet().stream().filter(formField -> formField.getKey().startsWith("question-")).map(formField -> Long.valueOf(formField.getValue())).collect(ImmutableList.toImmutableList());
try {
programService.addQuestionsToBlock(programId, blockId, questionIds);
} catch (ProgramNotFoundException e) {
return notFound(String.format("Program ID %d not found.", programId));
} catch (ProgramBlockNotFoundException e) {
return notFound(String.format("Block ID %d not found for Program %d", blockId, programId));
} catch (QuestionNotFoundException e) {
return notFound(String.format("Question IDs %s not found", questionIds));
} catch (DuplicateProgramQuestionException e) {
return notFound(String.format("Some Question IDs %s already exist in Program ID %d", questionIds, programId));
}
return redirect(controllers.admin.routes.AdminProgramBlocksController.edit(programId, blockId));
}