Hi ,
Today i’m trying to open Dialog from login window
Login window is overridden , why trying to create reset password dialog
I’m getting Access Denied
With Exception
22:23:52.319 [http-nio-8080-exec-42] ERROR com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.widgets.CubaButton: com.haulmont.cuba.core.global.AccessDeniedException: SCREEN inputDialog
How i make it works
Controller
@UiController("VTowerLogin")
@UiDescriptor("vtower-login.xml")
public class VTowerLogin extends LoginScreen {
@Inject
private UserService userService;
@Inject
private Dialogs dialogs;
@Inject
private Notifications notifications;
@Inject
private MessageBundle messageBundle;
@Subscribe("resetPasswordBtn")
public void onCustomActionsBtnClick(Button.ClickEvent event) {
dialogs.createInputDialog(this)
.withCaption("Enter values")
.withParameters(
InputParameter.stringParameter("email").withCaption(messageBundle.getMessage("reset-pass-email-field-caption"))
)
.withActions(
InputDialogAction.action("confirm")
.withCaption("Confirm")
.withPrimary(true)
.withHandler(actionEvent -> {
InputDialog dialog = actionEvent.getInputDialog();
String email = dialog.getValue("email");
userService.resetPassword(email);
notifications.create()
.withCaption(messageBundle.getMessage("reset-password-success"))
.withDescription(messageBundle.getMessage("new-password-sent-mail"))
.withPosition(Notifications.Position.TOP_RIGHT)
.withType(Notifications.NotificationType.HUMANIZED)
.show();
dialog.closeWithDefaultAction();
}),
InputDialogAction.action("refuse")
.withCaption("Refuse")
.withValidationRequired(false)
.withHandler(actionEvent ->
actionEvent.getInputDialog().closeWithDefaultAction())
)
.show();
}
}
XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd"
caption="msg://caption"
messagesPack="com.vtss.vtower.web.screens.login">
<actions>
<action id="submit"
caption="mainMsg://loginWindow.okButton"
icon="app/images/login-button.png"
invoke="login" shortcut="ENTER"/>
</actions>
<layout stylename="c-login-main-layout" expand="loginWrapper">
<vbox id="loginWrapper">
<vbox id="loginMainBox"
align="MIDDLE_CENTER"
stylename="c-login-panel"
width="AUTO">
<hbox id="loginTitleBox"
align="MIDDLE_CENTER"
stylename="c-login-title">
<image id="logoImage"
align="MIDDLE_LEFT"
height="AUTO"
scaleMode="SCALE_DOWN"
stylename="c-login-icon"
width="AUTO"/>
<label id="welcomeLabel"
align="MIDDLE_LEFT"
stylename="c-login-caption"
value="mainMsg://loginWindow.welcomeLabel"/>
</hbox>
<capsLockIndicator id="capsLockIndicator"
align="MIDDLE_CENTER"
stylename="c-login-capslockindicator"/>
<vbox id="loginForm"
spacing="true"
stylename="c-login-form">
<cssLayout id="loginCredentials"
stylename="c-login-credentials">
<textField id="loginField"
htmlName="loginField"
inputPrompt="mainMsg://loginWindow.loginPlaceholder"
stylename="c-login-username"/>
<passwordField id="passwordField"
autocomplete="true"
htmlName="passwordField"
inputPrompt="mainMsg://loginWindow.passwordPlaceholder"
capsLockIndicator="capsLockIndicator"
stylename="c-login-password"/>
</cssLayout>
<hbox id="rememberLocalesBox"
stylename="c-login-remember-locales">
<checkBox id="rememberMeCheckBox"
caption="mainMsg://loginWindow.rememberMe"
stylename="c-login-remember-me"/>
<lookupField id="localesSelect"
nullOptionVisible="false"
stylename="c-login-locale"
textInputAllowed="false"/>
</hbox>
<label id="spacer"/>
<hbox spacing="true">
<linkButton id="resetPasswordBtn"
align="MIDDLE_LEFT"
caption="mainMsg://action.reset.password"
description="msg://press-me-for-reset-password"/>
<button id="loginButton"
align="MIDDLE_RIGHT"
action="submit"
stylename="c-login-submit-button"/>
</hbox>
</vbox>
</vbox>
</vbox>
<label id="poweredByLink"
align="MIDDLE_CENTER"
htmlEnabled="true"
stylename="c-powered-by"
value="mainMsg://vtower.poweredBy"/>
</layout>
</window>