use of com.helger.web.scope.IRequestWebScopeWithoutResponse in project peppol-practical by phax.
the class LayoutAreaContentProviderPublic method _getNavbar.
@Nonnull
private static BootstrapNavbar _getNavbar(final LayoutExecutionContext aLEC) {
final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
final BootstrapNavbar aNavbar = new BootstrapNavbar();
aNavbar.addBrand(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(AppHelper.getApplicationTitle()), aLinkToStartPage);
aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("Participant information").setIcon(EFamFamIcon.USER_GREEN).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_TOOLS_PARTICIPANT_INFO)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("Document validation").setIcon(EFamFamIcon.SCRIPT_GO).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_VALIDATION_UPLOAD)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("ID information").setIcon(EFamFamIcon.CUP).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_TOOLS_ID_INFO)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
if (aUser != null) {
aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
if (SecurityHelper.hasUserRole(aUser.getID(), CPPApp.ROLE_CONFIG_ID)) {
aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(AbstractSecureApplicationServlet.SERVLET_DEFAULT_PATH)).addChild("Administration").addClass(CBootstrapCSS.MX_2));
}
aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)).addClass(CBootstrapCSS.MX_2));
} else {
// show login in Navbar
final BootstrapNavbarNav aNav = aToggleable.addAndReturnNav();
final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
{
final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.P_2).addStyle(CCSSProperties.MIN_WIDTH.newValue("400px"));
aDiv.addChild(AppCommonUI.createViewLoginForm(aLEC, null, false));
aDropDown.addChild(aDiv);
}
aNav.addItem().addNavDropDown("Login", aDropDown);
aToggleable.addChild(new BootstrapButton(EBootstrapButtonType.SUCCESS).addChild(EPhotonCoreText.BUTTON_SIGN_UP.getDisplayText(aDisplayLocale)).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SIGN_UP)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
}
return aNavbar;
}
use of com.helger.web.scope.IRequestWebScopeWithoutResponse in project peppol-practical by phax.
the class AppCommonUI method init.
public static void init() {
RequestParameterManager.getInstance().setParameterHandler(new RequestParameterHandlerURLPathNamed());
BootstrapDataTables.setConfigurator((aLEC, aTable, aDataTables) -> {
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
aDataTables.setAutoWidth(false).setLengthMenu(LENGTH_MENU).setAjaxBuilder(new JQueryAjaxBuilder().url(CAjax.DATATABLES.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorDataTables.OBJECT_ID, aTable.getID()))).setServerFilterType(EDataTablesFilterType.ALL_TERMS_PER_ROW).setTextLoadingURL(CAjax.DATATABLES_I18N.getInvocationURL(aRequestScope), AjaxExecutorDataTablesI18N.LANGUAGE_ID).addPlugin(new DataTablesPluginSearchHighlight());
});
// By default allow markdown in system message
BootstrapSystemMessage.setDefaultUseMarkdown(true);
// Register comment handlers
CommentThreadManager.getInstance().registerObjectType(CPPApp.OT_PAGE);
}
use of com.helger.web.scope.IRequestWebScopeWithoutResponse 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.web.scope.IRequestWebScopeWithoutResponse in project peppol-practical by phax.
the class AppLayoutHTMLProvider method fillBody.
@Override
protected void fillBody(@Nonnull final ISimpleWebExecutionContext aSWEC, @Nonnull final HCHtml aHtml) throws ForcedRedirectException {
final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope();
final Locale aDisplayLocale = aSWEC.getDisplayLocale();
final IMenuItemPage aMenuItem = RequestSettings.getMenuItem(aRequestScope);
final LayoutExecutionContext aLEC = new LayoutExecutionContext(aSWEC, aMenuItem);
final HCHead aHead = aHtml.head();
final HCBody aBody = aHtml.body();
// Add menu item in page title
aHead.setPageTitle(StringHelper.getConcatenatedOnDemand(AppHelper.getApplicationTitle(), " - ", aMenuItem.getDisplayText(aDisplayLocale)));
final IHCNode aNode = m_aFactory.apply(aLEC);
aBody.addChild(aNode);
}
Aggregations