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


Java Form.bind方法代码示例

本文整理汇总了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));
}
 
开发者ID:nazareno,项目名称:diferentonas-server,代码行数:31,代码来源:OpiniaoController.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:11,代码来源:EligibilityExistingTTPTest.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:11,代码来源:EligibilityExistingTTPTest.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:10,代码来源:EligibilityExistingTTPTest.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:11,代码来源:EligibilityDebtTypeTest.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:11,代码来源:EligibilityDebtTypeTest.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:10,代码来源:EligibilityDebtTypeTest.java

示例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);
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:12,代码来源:CalculatorInputTest.java

示例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
}
 
开发者ID:hmrc,项目名称:self-service-time-to-pay-frontend-java,代码行数:12,代码来源:CalculatorInputTest.java


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