protected boolean isBillingDifferent() { final String flagFieldName = "billingAddressDifferentToBillingAddress"; final String fieldValue = formFactory().form().bindFromRequest().get(flagFieldName); return "true".equals(fieldValue); }
default FormFactory formFactory() { return new FormFactory(messagesApi(), formatters(), validatorFactory(), config()); } }
default FormFactory formFactory() { return new FormFactory(messagesApi(), formatters(), validatorFactory(), config()); } }
default Form<? extends T> createForm() { return formFactory().form(getFormDataClass()); }
default FormFactory formFactory() { return new FormFactory(messagesApi(), formatters(), validatorFactory(), config()); } }
default Form<? extends F> createNewFilledForm(final T context) { try { final F formData = getFormDataClass().getConstructor().newInstance(); fillFormData(formData, context); final Map<String, String> classFieldValues = BeanUtils.describe(formData); final Form<? extends F> filledForm = formFactory().form(getFormDataClass()).bind(classFieldValues); filledForm.discardErrors(); return filledForm; } catch (ReflectiveOperationException e) { throw new RuntimeException("Missing empty constructor for class " + getFormDataClass().getCanonicalName(), e); } }
public Result renderForm() { return onSetupEnabled(() -> ok(setup.render(formFactory.form(SphereCredentials.class), setupReverseRouter.processSetupFormCall()))); }
@SunriseRoute("processChangeLanguageForm") public CompletionStage<Result> changeLanguage() { final Form<LanguageFormData> languageForm = formFactory.form(LanguageFormData.class).bindFromRequest(); final String languageTag = languageForm.hasErrors() ? defaultLanguage() : languageForm.get().getLanguage(); logger.debug("Changed language: " + languageTag); return redirectToLanguage(languageTag); }
@SunriseRoute("processChangeCountryForm") public CompletionStage<Result> changeCountry(final String languageTag) { final Form<CountryFormData> boundForm = formFactory.form(CountryFormData.class).bindFromRequest(); final String country = boundForm.hasErrors() ? defaultCountry() : boundForm.get().getCountry(); session(SESSION_COUNTRY, country); logger.debug("Changed country: " + country); return redirectToHome(); }
public Result processForm() { return onSetupEnabled(() -> { final Form<SphereCredentials> form = formFactory.form(SphereCredentials.class).bindFromRequest(); final Result result; if (form.hasErrors()) { result = badRequest(setup.render(form, setupReverseRouter.processSetupFormCall())); } else { final SphereCredentials credentials = form.get(); final String content = String.format("ctp.projectKey=%s\n" + "ctp.clientId=%s\n" + "ctp.clientSecret=%s\n", credentials.getProjectKey(), credentials.getClientId(), credentials.getClientSecret()); final Path path = writeSettingsFile(PATH, content); result = ok(success.render(path.toString())); } return result; }); }