本文整理汇总了Java中play.data.Form.bind方法的典型用法代码示例。如果您正苦于以下问题:Java Form.bind方法的具体用法?Java Form.bind怎么用?Java Form.bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.data.Form
的用法示例。
在下文中一共展示了Form.bind方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addOpiniao
import play.data.Form; //导入方法依赖的package包/类
@Transactional
public Result addOpiniao(Long idIniciativa) {
JsonNode json = request().body().asJson();
if (json == null) {
return badRequest("Esperava receber json");
}
// Usando anotações de validação do play
Form<Opiniao> form = formFactory.form(Opiniao.class);
Form<Opiniao> comDados = form.bind(json);
if (comDados.hasErrors()) {
Logger.debug("Submissão com erros: " + json.toString() + "; Erros: " + comDados.errorsAsJson());
return badRequest(comDados.errorsAsJson());
}
Opiniao opiniao = comDados.get();
opiniao.setAutor(getUsuarioLogado());
Iniciativa iniciativa = iniciativaDAO.find(idIniciativa);
if (iniciativa == null) {
return notFound("Iniciativa não encontrada");
}
Logger.debug("Add opinião na iniciativa " + iniciativa.getId());
iniciativa.addOpiniao(opiniao);
iniciativaDAO.flush(); // para que a opinião seja retornada com id
return ok(toJson(opiniao));
}
示例2: validateExistingTTPValue
import play.data.Form; //导入方法依赖的package包/类
@Test
public void validateExistingTTPValue() {
Map<String, String> formData = Maps.newHashMap();
formData.put("existingTTP", "false");
Form<EligibilityExistingTTP> eligibilityForm = Form.form(EligibilityExistingTTP.class);
eligibilityForm = eligibilityForm.bind(formData);
assertEquals(eligibilityForm.hasErrors(), false);
}
示例3: errorOnInvalidTtpValue
import play.data.Form; //导入方法依赖的package包/类
@Test
public void errorOnInvalidTtpValue() {
Map<String, String> formData = Maps.newHashMap();
formData.put("existingTTP", "I don't know");
Form<EligibilityExistingTTP> eligibilityForm = Form.form(EligibilityExistingTTP.class);
eligibilityForm = eligibilityForm.bind(formData);
assertEquals(eligibilityForm.hasErrors(), true);
}
示例4: errorOnMissingTtpValue
import play.data.Form; //导入方法依赖的package包/类
@Test
public void errorOnMissingTtpValue() {
Map<String, String> formData = Maps.newHashMap();
Form<EligibilityExistingTTP> eligibilityForm = Form.form(EligibilityExistingTTP.class);
eligibilityForm = eligibilityForm.bind(formData);
assertEquals(eligibilityForm.hasErrors(), true);
}
示例5: validateSelfAssessmentValue
import play.data.Form; //导入方法依赖的package包/类
@Test
public void validateSelfAssessmentValue() {
Map<String, String> formData = Maps.newHashMap();
formData.put("selfAssessmentDebt", "true");
Form<EligibilityDebtType> eligibilityForm = Form.form(EligibilityDebtType.class);
eligibilityForm = eligibilityForm.bind(formData);
assertEquals(eligibilityForm.hasErrors(), false);
}
示例6: validateOtherTaxDebtValue
import play.data.Form; //导入方法依赖的package包/类
@Test
public void validateOtherTaxDebtValue() {
Map<String, String> formData = Maps.newHashMap();
formData.put("otherTaxDebt", "true");
Form<EligibilityDebtType> eligibilityForm = Form.form(EligibilityDebtType.class);
eligibilityForm = eligibilityForm.bind(formData);
assertEquals(eligibilityForm.hasErrors(), false);
}
示例7: errorOnInvalidData
import play.data.Form; //导入方法依赖的package包/类
@Test
public void errorOnInvalidData() {
Map<String, String> formData = Maps.newHashMap();
Form<EligibilityDebtType> eligibilityForm = Form.form(EligibilityDebtType.class);
eligibilityForm = eligibilityForm.bind(formData);
assertEquals(eligibilityForm.hasErrors(), true);
}
示例8: succeedWithValidData
import play.data.Form; //导入方法依赖的package包/类
@Test
public void succeedWithValidData() {
Map<String, String> formData = Maps.newHashMap();
formData.put("initialPayment", "5000");
formData.put("paymentFrequency", "MONTHLY");
Form<CalculatorInput> calculatorForm = Form.form(CalculatorInput.class);
calculatorForm = calculatorForm.bind(formData);
assertEquals(calculatorForm.hasErrors(), false);
}
示例9: errorOnInvalidData
import play.data.Form; //导入方法依赖的package包/类
@Test
public void errorOnInvalidData() {
Map<String, String> formData = Maps.newHashMap();
Form<CalculatorInput> calculatorForm = Form.form(CalculatorInput.class);
calculatorForm = calculatorForm.bind(formData);
assertEquals(calculatorForm.hasErrors(), true);
// add more scenarios here for data type errors
}