use of com.helger.photon.core.form.RequestField in project peppol-practical by phax.
the class PageSecureSMLConfiguration method showInputForm.
@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMLConfiguration aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final boolean bEdit = eFormAction.isEdit();
aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit SML configuration '" + aSelectedObject.getDisplayName() + "'" : "Create new SML configuration"));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("ID").setCtrl(new HCEdit(new RequestField(FIELD_ID, aSelectedObject != null ? aSelectedObject.getID() : null)).setReadOnly(bEdit)).setHelpText("The internal ID of the SML configuration. This value cannot be edited.").setErrorList(aFormErrors.getListOfField(FIELD_ID)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(FIELD_DISPLAY_NAME, aSelectedObject != null ? aSelectedObject.getDisplayName() : null))).setHelpText("The name of the SML configuration. This is for informational purposes only and has no effect on the functionality.").setErrorList(aFormErrors.getListOfField(FIELD_DISPLAY_NAME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("DNS Zone").setCtrl(new HCEdit(new RequestField(FIELD_DNS_ZONE, aSelectedObject != null ? aSelectedObject.getDNSZone() : null))).setHelpText(new HCTextNode("The name of the DNS Zone that this SML is working upon (e.g. "), new HCCode().addChild("sml.peppolcentral.org"), new HCTextNode("). The value will automatically converted to all-lowercase!")).setErrorList(aFormErrors.getListOfField(FIELD_DNS_ZONE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Management Service URL").setCtrl(new HCEdit(new RequestField(FIELD_MANAGEMENT_ADDRESS_URL, aSelectedObject != null ? aSelectedObject.getManagementServiceURL() : null))).setHelpText("The service URL where the SML management application is running on including the host name. It may not contain the '" + CSMLDefault.MANAGEMENT_SERVICE_METADATA + "' or '" + CSMLDefault.MANAGEMENT_SERVICE_PARTICIPANTIDENTIFIER + "' path elements!").setErrorList(aFormErrors.getListOfField(FIELD_MANAGEMENT_ADDRESS_URL)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Client Certificate required?").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_CLIENT_CERTIFICATE_REQUIRED, aSelectedObject != null ? aSelectedObject.isClientCertificateRequired() : DEFAULT_CLIENT_CERTIFICATE_REQUIRED))).setHelpText("Check this if this SML requires a client certificate for access. Both Peppol production SML and SMK require a client certificate. Only a locally running SML software may not require a client certificate.").setErrorList(aFormErrors.getListOfField(FIELD_CLIENT_CERTIFICATE_REQUIRED)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP API type").setCtrl(new SMPAPITypeSelect(new RequestField(FIELD_SMP_API_TYPE, aSelectedObject != null ? aSelectedObject.getSMPAPIType().getID() : null), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_SMP_API_TYPE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("SMP identifier type").setCtrl(new SMPIdentifierTypeSelect(new RequestField(FIELD_SMP_ID_TYPE, aSelectedObject != null ? aSelectedObject.getSMPIdentifierType().getID() : null), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_SMP_ID_TYPE)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Production SML?").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_PRODUCTION, aSelectedObject != null ? aSelectedObject.isProduction() : true))).setHelpText("Check this if this SML is a production SML. Don't check e.g. for SMK.").setErrorList(aFormErrors.getListOfField(FIELD_PRODUCTION)));
}
use of com.helger.photon.core.form.RequestField in project peppol-practical by phax.
the class PagePublicContact method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final String sRecaptchWebKey = AppConfig.getRecaptchaWebKey();
final String sRecaptchSecretKey = AppConfig.getRecaptchaSecretKey();
final boolean bRecaptchaEnabled = StringHelper.hasText(sRecaptchWebKey) && StringHelper.hasText(sRecaptchSecretKey);
aNodeList.addChild(p("If you have general questions concerning Peppol technology, you may contact me using the form below. Please be aware, that I run this page on a voluntary basis and that the answers you may receive are my personal answers and not official OpenPeppol answers."));
boolean bShowForm = true;
final FormErrorList aFormErrors = new FormErrorList();
if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
final String sName = StringHelper.trim(aWPEC.params().getAsString(FIELD_NAME));
final String sEmail = StringHelper.trim(aWPEC.params().getAsString(FIELD_EMAIL));
final String sTopic = aWPEC.params().getAsString(FIELD_TOPIC);
final String sText = StringHelper.trim(aWPEC.params().getAsString(FIELD_TEXT));
final String sReCaptchaResponse = StringHelper.trim(aWPEC.params().getAsString(HCReCaptchaV2.RESPONSE_PARAMETER_NAME));
if (StringHelper.hasNoText(sName))
aFormErrors.addFieldError(FIELD_NAME, "Your name must be provided.");
if (StringHelper.hasNoText(sEmail))
aFormErrors.addFieldError(FIELD_EMAIL, "Your email address must be provided.");
else if (!EmailAddressHelper.isValid(sEmail))
aFormErrors.addFieldError(FIELD_EMAIL, "The provided email address is invalid.");
if (StringHelper.hasNoText(sText))
aFormErrors.addFieldError(FIELD_TEXT, "A message text must be provided.");
if (bRecaptchaEnabled)
if (aFormErrors.isEmpty() || StringHelper.hasText(sReCaptchaResponse)) {
if (!CaptchaStateSessionSingleton.getInstance().isChecked()) {
// Check only if no other errors occurred
if (ReCaptchaServerSideValidator.check(sRecaptchSecretKey, sReCaptchaResponse).isFailure())
aFormErrors.addFieldError(FIELD_CAPTCHA, "Please confirm you are not a robot!");
else
CaptchaStateSessionSingleton.getInstance().setChecked();
}
}
if (aFormErrors.isEmpty()) {
if (!_isSpamBody(sText)) {
final EmailData aEmailData = new EmailData(EEmailType.TEXT);
aEmailData.setFrom(new EmailAddress("peppol-practical@helger.com", "Peppol Practical"));
aEmailData.to().add(new EmailAddress("philip@helger.com"));
aEmailData.replyTo().add(new EmailAddress(sEmail, sName));
aEmailData.setSubject("[" + AppHelper.getApplicationTitle() + "] Contact Form - " + sName);
final StringBuilder aSB = new StringBuilder();
aSB.append("Contact form from " + AppHelper.getApplicationTitle() + " was filled out.\n\n");
aSB.append("Name: ").append(sName).append("\n");
aSB.append("Email: ").append(sEmail).append("\n");
aSB.append("Topic: ").append(sTopic).append("\n");
aSB.append("Text:\n").append(sText).append("\n");
aEmailData.setBody(aSB.toString());
LOGGER.info("Sending contact form from '" + sName + "' and email '" + sEmail + "' with topic '" + sTopic + "'");
ScopedMailAPI.getInstance().queueMail(InternalErrorSettings.getSMTPSettings(), aEmailData);
} else
LOGGER.info("Ignoring spam contact form from '" + sEmail + "' with topic '" + sTopic + "'");
aNodeList.addChild(success("Thank you for your message. Please note that I run this page on a voluntary basis on my expenses - you may consider a donation."));
bShowForm = false;
}
}
if (bShowForm) {
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your name").setCtrl(new HCEdit(new RequestField(FIELD_NAME))).setErrorList(aFormErrors.getListOfField(FIELD_NAME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL)));
final HCExtSelect aSelect = new HCExtSelect(new RequestField(FIELD_TOPIC));
aSelect.addOption("SML/SMK");
aSelect.addOption("SMP");
aSelect.addOption("AccessPoint (AP)/AS4");
aSelect.addOption("Peppol Directory");
aSelect.addOption("Validation");
aSelect.addOption("CEF");
aSelect.addOption("General question");
aSelect.addOptionPleaseSelect(aDisplayLocale);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Topic").setCtrl(aSelect).setErrorList(aFormErrors.getListOfField(FIELD_TOPIC)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your message").setCtrl(new HCTextAreaAutosize(new RequestField(FIELD_TEXT)).setRows(5)).setErrorList(aFormErrors.getListOfField(FIELD_TEXT)));
if (bRecaptchaEnabled)
if (!CaptchaStateSessionSingleton.getInstance().isChecked()) {
// Add visible Captcha
aForm.addFormGroup(new BootstrapFormGroup().setCtrl(HCReCaptchaV2.create(sRecaptchWebKey, aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_CAPTCHA)));
}
aForm.addChild(new HCHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM));
aForm.addChild(new BootstrapSubmitButton().addChild("Send message").setIcon(EFontAwesome4Icon.PAPER_PLANE));
}
}
use of com.helger.photon.core.form.RequestField in project peppol-practical by phax.
the class PagePublicSignUp method showInputForm.
protected void showInputForm(@Nonnull final Locale aDisplayLocale, @Nonnull final AbstractHCForm<?> aForm, @Nonnull final FormErrorList aFormErrors) {
final List<IHCNode> aPasswordHelpText = HCExtHelper.list2divList(GlobalPasswordSettings.getPasswordConstraintList().getAllPasswordConstraintDescriptions(aDisplayLocale));
aForm.addChild(info("Sign up to ").addChild(strong(AppHelper.getApplicationTitle())).addChild(" easily by filling out this form. No further information and no credit card information is needed."));
final BootstrapForm aRealForm = (BootstrapForm) aForm;
aRealForm.setLeft(3);
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("First name").setCtrl(new HCEdit(new RequestField(FIELD_FIRSTNAME))).setErrorList(aFormErrors.getListOfField(FIELD_FIRSTNAME)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Last name").setCtrl(new HCEdit(new RequestField(FIELD_LASTNAME))).setErrorList(aFormErrors.getListOfField(FIELD_LASTNAME)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL1))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL1)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Email address (confirmation)").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL2))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL2)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Password").setCtrl(new HCEditPassword(FIELD_PASSWORD)).setHelpText(aPasswordHelpText).setErrorList(aFormErrors.getListOfField(FIELD_PASSWORD)));
aRealForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Password (confirmation)").setCtrl(new HCEditPassword(FIELD_PASSWORD_CONFIRM)).setHelpText(aPasswordHelpText).setErrorList(aFormErrors.getListOfField(FIELD_PASSWORD_CONFIRM)));
}
use of com.helger.photon.core.form.RequestField in project peppol-practical by phax.
the class AppCommonUI method createViewLoginForm.
@Nonnull
public static BootstrapForm createViewLoginForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final String sPreselectedUserName, final boolean bShowRegistration) {
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
// Use new IDs for both fields, in case the login stuff is displayed more
// than once!
final String sIDUserName = GlobalIDFactory.getNewStringID();
final String sIDPassword = GlobalIDFactory.getNewStringID();
final String sIDErrorField = GlobalIDFactory.getNewStringID();
final BootstrapForm aForm = new BootstrapForm(aLEC).setAction(aLEC.getSelfHref()).setFormType(EBootstrapFormType.DEFAULT);
aForm.setLeft(3);
// Placeholder for error message
aForm.addChild(new HCDiv().setID(sIDErrorField).addStyle(CCSSProperties.MARGIN.newValue("4px 0")));
// User name field
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(EPhotonCoreText.EMAIL_ADDRESS.getDisplayText(aDisplayLocale)).setCtrl(new HCEdit(new RequestField(CLogin.REQUEST_ATTR_USERID, sPreselectedUserName)).setPlaceholder(EPhotonCoreText.EMAIL_ADDRESS.getDisplayText(aDisplayLocale)).setID(sIDUserName)));
// Password field
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(EPhotonCoreText.LOGIN_FIELD_PASSWORD.getDisplayText(aDisplayLocale)).setCtrl(new HCEditPassword(CLogin.REQUEST_ATTR_PASSWORD).setPlaceholder(EPhotonCoreText.LOGIN_FIELD_PASSWORD.getDisplayText(aDisplayLocale)).setID(sIDPassword)));
// Login button
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
{
final JSPackage aOnClick = new JSPackage();
final JSAnonymousFunction aJSSuccess = new JSAnonymousFunction();
final JSVar aJSData = aJSSuccess.param("data");
aJSSuccess.body()._if(aJSData.ref(AjaxExecutorPublicLogin.JSON_LOGGEDIN), JSHtml.windowLocationReload(), JQuery.idRef(sIDErrorField).empty().append(aJSData.ref(AjaxExecutorPublicLogin.JSON_HTML)));
aOnClick.add(new JQueryAjaxBuilder().url(CAjax.LOGIN.getInvocationURI(aRequestScope)).method(EHttpMethod.POST).data(new JSAssocArray().add(CLogin.REQUEST_ATTR_USERID, JQuery.idRef(sIDUserName).val()).add(CLogin.REQUEST_ATTR_PASSWORD, JQuery.idRef(sIDPassword).val())).success(aJSSuccess).build());
aOnClick._return(false);
aToolbar.addSubmitButton(EPhotonCoreText.LOGIN_BUTTON_SUBMIT.getDisplayText(aDisplayLocale), aOnClick, EDefaultIcon.YES.getIcon());
}
if (bShowRegistration) {
aToolbar.addChild(new BootstrapButton(EBootstrapButtonType.SUCCESS).addChild(EPhotonCoreText.BUTTON_SIGN_UP.getDisplayText(aDisplayLocale)).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SIGN_UP)));
}
return aForm;
}
use of com.helger.photon.core.form.RequestField in project peppol-practical by phax.
the class PageSecureCRMSubscriber method showInputForm.
@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ICRMSubscriber aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
final CRMGroupManager aCRMGroupMgr = PPMetaManager.getCRMGroupMgr();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
aForm.addChild(getUIHandler().createActionHeader(eFormAction.isEdit() ? "Edit CRM subscriber" : "Create new CRM subscriber"));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Salutation").setCtrl(new HCSalutationSelect(new RequestField(FIELD_SALUTATION, aSelectedObject == null ? null : aSelectedObject.getSalutationID()), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_SALUTATION)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(FIELD_NAME, aSelectedObject == null ? null : aSelectedObject.getName()))).setErrorList(aFormErrors.getListOfField(FIELD_NAME)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL_ADDRESS, aSelectedObject == null ? null : aSelectedObject.getEmailAddress()))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL_ADDRESS)));
{
final HCNodeList aGroups = new HCNodeList();
for (final ICRMGroup aCRMGroup : aCRMGroupMgr.getAll().getSortedInline(IHasDisplayName.getComparatorCollating(aDisplayLocale))) {
final String sCRMGroupID = aCRMGroup.getID();
final RequestFieldBooleanMultiValue aRFB = new RequestFieldBooleanMultiValue(FIELD_GROUP, sCRMGroupID, aSelectedObject != null && aSelectedObject.isAssignedToGroup(aCRMGroup));
aGroups.addChild(div(new HCCheckBox(aRFB).setValue(sCRMGroupID)).addChild(" " + aCRMGroup.getDisplayName()));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Assigned groups").setCtrl(aGroups).setErrorList(aFormErrors.getListOfField(FIELD_GROUP)));
}
}
Aggregations