use of org.apache.wicket.ajax.AbstractDefaultAjaxBehavior in project midpoint by Evolveum.
the class PageBase method createModalWindow.
protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
final ModalWindow modal = new ModalWindow(id);
add(modal);
modal.setResizable(false);
modal.setTitle(title);
modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100)));
modal.setInitialWidth(width);
modal.setWidthUnit("px");
modal.setInitialHeight(height);
modal.setHeightUnit("px");
modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
@Override
public boolean onCloseButtonClicked(AjaxRequestTarget target) {
return true;
}
});
modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
@Override
public void onClose(AjaxRequestTarget target) {
modal.close(target);
}
});
modal.add(new AbstractDefaultAjaxBehavior() {
@Override
public void renderHead(Component component, IHeaderResponse response) {
response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;"));
response.render(JavaScriptHeaderItem.forScript("$(document).ready(function() {\n" + " $(document).bind('keyup', function(evt) {\n" + " if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n" + " evt.preventDefault();\n" + " }\n" + " });\n" + "});", id));
}
@Override
protected void respond(AjaxRequestTarget target) {
modal.close(target);
}
});
return modal;
}
use of org.apache.wicket.ajax.AbstractDefaultAjaxBehavior in project midpoint by Evolveum.
the class MidPointApplication method init.
@Override
public void init() {
super.init();
getCspSettings().blocking().disabled();
getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(MidPointApplication.class, // todo no jquery.js is found
"../../../../../webjars/AdminLTE/2.4.18/bower_components/jquery/dist/jquery.min.js"));
getComponentInstantiationListeners().add(new SpringComponentInjector(this, applicationContext, true));
systemConfigurationChangeDispatcher.registerListener(new DeploymentInformationChangeListener(this));
SystemConfigurationType config = getSystemConfigurationIfAvailable();
if (config != null) {
deploymentInfo = config.getDeploymentInformation();
}
ResourceSettings resourceSettings = getResourceSettings();
resourceSettings.setParentFolderPlaceholder("$-$");
resourceSettings.setHeaderItemComparator(new PriorityFirstComparator(true));
SecurePackageResourceGuard guard = (SecurePackageResourceGuard) resourceSettings.getPackageResourceGuard();
guard.addPattern("+*.woff2");
List<IStringResourceLoader> resourceLoaders = resourceSettings.getStringResourceLoaders();
resourceLoaders.add(0, new MidPointStringResourceLoader(localizationService));
IResourceStreamLocator locator = new CachingResourceStreamLocator(new MidPointResourceStreamLocator(resourceSettings.getResourceFinders()));
resourceSettings.setResourceStreamLocator(locator);
resourceSettings.setThrowExceptionOnMissingResource(false);
getMarkupSettings().setStripWicketTags(true);
getMarkupSettings().setStripComments(true);
if (RuntimeConfigurationType.DEVELOPMENT.equals(getConfigurationType())) {
getDebugSettings().setAjaxDebugModeEnabled(true);
getDebugSettings().setDevelopmentUtilitiesEnabled(true);
initializeDevelopmentSerializers();
mount(new MountedMapper("/inspector", InspectorPage.class, new PageParametersEncoder()));
mount(new MountedMapper("/liveSession", LiveSessionsPage.class, new PageParametersEncoder()));
mount(new MountedMapper("/pageStore", PageStorePage.class, new PageParametersEncoder()));
}
// pretty url for resources (e.g. images)
mountFiles(ImgResources.BASE_PATH, ImgResources.class);
// exception handling an error pages
ApplicationSettings appSettings = getApplicationSettings();
appSettings.setAccessDeniedPage(PageError401.class);
appSettings.setInternalErrorPage(PageError.class);
appSettings.setPageExpiredErrorPage(PageError.class);
mount(new MountedMapper(MOUNT_INTERNAL_SERVER_ERROR, PageError.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_UNAUTHORIZED_ERROR, PageError401.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_FORBIDEN_ERROR, PageError403.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_NOT_FOUND_ERROR, PageError404.class, new PageParametersEncoder()));
mount(new MountedMapper(MOUNT_GONE_ERROR, PageError410.class, new PageParametersEncoder()));
getRequestCycleListeners().add(new LoggingRequestCycleListener(this));
getAjaxRequestTargetListeners().add(new AjaxRequestTarget.IListener() {
@Override
public void updateAjaxAttributes(AbstractDefaultAjaxBehavior behavior, AjaxRequestAttributes attributes) {
// check whether behavior will use POST method, if not then don't put CSRF token there
if (!isPostMethodTypeBehavior(behavior, attributes)) {
return;
}
CsrfToken csrfToken = SecurityUtils.getCsrfToken();
if (csrfToken == null) {
return;
}
String parameterName = csrfToken.getParameterName();
String value = csrfToken.getToken();
attributes.getExtraParameters().put(parameterName, value);
}
});
getSessionListeners().add((ISessionListener) asyncWebProcessManager);
// descriptor loader, used for customization
new PageMounter().loadData(this);
descriptorLoader.loadData();
if (applicationContext != null) {
Map<String, MidPointApplicationConfiguration> map = applicationContext.getBeansOfType(MidPointApplicationConfiguration.class);
if (map != null) {
map.forEach((key, value) -> value.init(this));
}
}
// for schrodinger selenide library
initializeSchrodinger();
ServletContext servletContext = getServletContext();
if (servletContext != null) {
taskManager.setWebContextPath(servletContext.getContextPath());
}
}
use of org.apache.wicket.ajax.AbstractDefaultAjaxBehavior in project openmeetings by apache.
the class MainPanel method onInitialize.
@Override
protected void onInitialize() {
menu = new MenuPanel("menu", getMainMenu());
add(topControls.setOutputMarkupPlaceholderTag(true).setMarkupId("topControls"));
add(contents.add(getClient() == null || panel == null ? EMPTY : panel).setOutputMarkupId(true).setMarkupId("contents"));
topControls.add(menu.setVisible(false), topLinks.setVisible(false).setOutputMarkupPlaceholderTag(true).setMarkupId("topLinks"));
topLinks.add(new AjaxLink<Void>("messages") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateContents(PROFILE_MESSAGES, target);
}
});
topLinks.add(new AjaxLink<Void>("profile") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateContents(PROFILE_EDIT, target);
}
});
final AboutDialog about = new AboutDialog("aboutDialog");
topLinks.add(new AjaxLink<Void>("about") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
about.open(target);
}
});
if (getApplication().getDebugSettings().isDevelopmentUtilitiesEnabled()) {
add(new DebugBar("dev").setOutputMarkupId(true));
} else {
add(new EmptyPanel("dev").setVisible(false));
}
add(new OmAjaxClientInfoBehavior());
add(about, chat = new ChatPanel("chatPanel"));
add(newMessage = new MessageDialog("newMessageDialog", new CompoundPropertyModel<>(new PrivateMessage())) {
private static final long serialVersionUID = 1L;
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
BasePanel bp = getCurrentPanel();
if (send.equals(button) && bp != null) {
bp.onNewMessageClose(handler);
}
}
});
add(userInfo = new UserInfoDialog("userInfoDialog", newMessage));
add(new AbstractDefaultAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void respond(AjaxRequestTarget target) {
userInfo.open(target, getParam(getComponent(), PARAM_USER_ID).toLong());
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
response.render(new PriorityHeaderItem(getNamedFunction("showUserInfo", this, explicit(PARAM_USER_ID))));
}
});
add(new AbstractDefaultAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void respond(AjaxRequestTarget target) {
ContactsHelper.addUserToContactList(getParam(getComponent(), PARAM_USER_ID).toLong());
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
response.render(new PriorityHeaderItem(getNamedFunction("addContact", this, explicit(PARAM_USER_ID))));
}
});
add(new AbstractDefaultAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void respond(AjaxRequestTarget target) {
newMessage.reset(true).open(target, getParam(getComponent(), PARAM_USER_ID).toOptionalLong());
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
response.render(new PriorityHeaderItem(getNamedFunction("privateMessage", this, explicit(PARAM_USER_ID))));
}
});
add(inviteUser = new InviteUserToRoomDialog("invite-to-room"));
add(new AbstractDefaultAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void respond(AjaxRequestTarget target) {
inviteUser.open(target, getParam(getComponent(), PARAM_USER_ID).toLong());
}
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
response.render(new PriorityHeaderItem(getNamedFunction("inviteUser", this, explicit(PARAM_USER_ID))));
}
});
topLinks.add(new ConfirmableAjaxBorder("logout", getString("310"), getString("634")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
getSession().invalidate();
setResponsePage(Application.get().getSignInPageClass());
}
});
super.onInitialize();
}
Aggregations