List of usage examples for org.apache.wicket.ajax.attributes AjaxRequestAttributes setEventPropagation
public AjaxRequestAttributes setEventPropagation(EventPropagation eventPropagation)
From source file:com.evolveum.midpoint.web.component.assignment.UserSelectionButton.java
License:Apache License
private void initLayout() { AjaxLink<String> userSelectionButton = new AjaxLink<String>(ID_USER_SELECTION_BUTTON) { private static final long serialVersionUID = 1L; @Override//from w w w. j a v a 2 s . c o m protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); } @Override public void onClick(AjaxRequestTarget target) { if (showUserSelectionPopup) { initUserSelectionPopup(target); } showUserSelectionPopup = true; } }; userSelectionButton.add(AttributeModifier.append("class", getTargetUserButtonClass())); userSelectionButton.setOutputMarkupId(true); userSelectionButton.add(new AttributeAppender("title", new IModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return getUserSelectionButtonTitle(); } })); add(userSelectionButton); Label label = new Label(ID_USER_SELECTION_BUTTON_LABEL, new IModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return getUserButtonLabel(); } }); label.setRenderBodyOnly(true); userSelectionButton.add(label); AjaxLink deleteButton = new AjaxLink(ID_DELETE_SELECTED_USER_BUTTON) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { UserSelectionButton.this.onDeleteSelectedUsersPerformed(target); } }; deleteButton.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return isDeleteButtonVisible(); } }); userSelectionButton.add(deleteButton); }
From source file:com.evolveum.midpoint.web.page.self.AbstractShoppingCartTabPanel.java
License:Apache License
private void initAddAllButton(WebMarkupContainer shoppingCartContainer) { AjaxButton addAllButton = new AjaxButton(ID_ADD_ALL_BUTTON, createStringResource("AbstractShoppingCartTabPanel.addAllButton")) { private static final long serialVersionUID = 1L; @Override/*ww w. jav a 2 s. c o m*/ public void onClick(AjaxRequestTarget ajaxRequestTarget) { AbstractShoppingCartTabPanel.this.addAllAssignmentsPerformed(ajaxRequestTarget); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); } }; addAllButton.add(new VisibleEnableBehaviour() { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { ObjectDataProvider provider = getGridViewComponent().getProvider(); return provider != null && provider.size() > 0; } @Override public boolean isEnabled() { int assignmentsLimit = AssignmentsUtil.loadAssignmentsLimit( new OperationResult(OPERATION_LOAD_ASSIGNMENTS_LIMIT), AbstractShoppingCartTabPanel.this.getPageBase()); return !AssignmentsUtil.isShoppingCartAssignmentsLimitReached(assignmentsLimit, AbstractShoppingCartTabPanel.this.getPageBase()); } }); addAllButton.add(AttributeAppender.append("title", AssignmentsUtil.getShoppingCartAssignmentsLimitReachedTitleModel(getPageBase()))); shoppingCartContainer.add(addAllButton); }
From source file:com.googlecode.wicket.kendo.ui.widget.menu.form.MenuItemAjaxButton.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setPreventDefault(false); // wicket7 attributes.setEventPropagation(EventPropagation.BUBBLE); }
From source file:org.apache.isis.viewer.wicket.ui.components.widgets.linkandlabel.ActionLink.java
License:Apache License
@Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); if (getSettings().isPreventDoubleClickForNoArgAction()) { PanelUtil.disableBeforeReenableOnComplete(attributes, this); }//from w ww .j a v a2 s . com // allow the event to bubble so the menu is hidden after click on an item attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); }
From source file:org.apache.isis.viewer.wicket.ui.components.widgets.linkandlabel.ActionLinkFactoryAbstract.java
License:Apache License
protected AbstractLink newLink(final String linkId, final ObjectAdapter objectAdapter, final ObjectAction action) { final ActionModel actionModel = ActionModel.create(objectAdapter, action); // this returns non-null if the action is no-arg and returns a URL or a Blob or a Clob. Otherwise can use default handling // TODO: the method looks at the actual compile-time return type; cannot see a way to check at runtime what is returned. // TODO: see https://issues.apache.org/jira/browse/ISIS-1264 for further detail. final AjaxDeferredBehaviour ajaxDeferredBehaviour = determineDeferredBehaviour(action, actionModel); final AbstractLink link = new AjaxLink<Object>(linkId) { private static final long serialVersionUID = 1L; @Override// ww w.j a v a 2s . com public void onClick(AjaxRequestTarget target) { if (ajaxDeferredBehaviour != null) { ajaxDeferredBehaviour.initiate(target); } else { final ActionPromptProvider promptProvider = ActionPromptProvider.Util.getFrom(getPage()); final ActionPrompt actionPrompt = promptProvider.getActionPrompt(); final ActionPromptHeaderPanel titlePanel = PersistenceSession.ConcurrencyChecking .executeWithConcurrencyCheckingDisabled(new Callable<ActionPromptHeaderPanel>() { @Override public ActionPromptHeaderPanel call() throws Exception { final String titleId = actionPrompt.getTitleId(); return new ActionPromptHeaderPanel(titleId, actionModel); } }); final ActionPanel actionPanel = (ActionPanel) getComponentFactoryRegistry() .createComponent(ComponentType.ACTION_PROMPT, actionPrompt.getContentId(), actionModel); actionPanel.setShowHeader(false); actionPrompt.setTitle(titlePanel, target); actionPrompt.setPanel(actionPanel, target); actionPanel.setActionPrompt(actionPrompt); actionPrompt.showPrompt(target); } } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); // allow the event to bubble so the menu is hidden after click on an item attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); } @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); Buttons.fixDisabledState(this, tag); } }; if (ajaxDeferredBehaviour != null) { link.add(ajaxDeferredBehaviour); } link.add(new CssClassAppender("noVeil")); return link; }
From source file:org.apache.openmeetings.web.user.profile.MessagesContactsPanel.java
License:Apache License
public MessagesContactsPanel(String id) { super(id);// ww w. j av a 2s . co m NOT_MOVE_FOLDER.setId(MOVE_CHOOSE); NOT_MOVE_FOLDER.setFolderName(Application.getString(1243)); foldersModel.setObject(getBean(PrivateMessageFolderDao.class).get(0, Integer.MAX_VALUE)); updateMoveModel(); final AddFolderDialog addFolder = new AddFolderDialog("addFolder") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); PrivateMessageFolderDao fDao = getBean(PrivateMessageFolderDao.class); fDao.addPrivateMessageFolder(getModelObject(), getUserId()); foldersModel.setObject(fDao.get(0, Integer.MAX_VALUE)); updateMoveModel(); target.add(folders, moveDropDown); } }; add(addFolder); add(new JQueryBehavior(".email.new", "button")); folders.add(inbox.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { selectFolder(inbox, INBOX_FOLDER_ID, target); } })); folders.add(sent.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { selectFolder(sent, SENT_FOLDER_ID, target); } })); folders.add(trash.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { selectFolder(trash, TRASH_FOLDER_ID, target); } })); folders.add(new WebMarkupContainer("newdir").add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { addFolder.open(target); } }).add(new JQueryBehavior(".email.newdir", "button"))); add(folders.add(new ListView<PrivateMessageFolder>("folder", foldersModel) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<PrivateMessageFolder> item) { item.add(new Label("name", item.getModelObject().getFolderName())); item.add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { attributes.setEventPropagation(EventPropagation.STOP_IMMEDIATE); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { PrivateMessageFolderDao fDao = getBean(PrivateMessageFolderDao.class); fDao.delete(item.getModelObject(), getUserId()); foldersModel.setObject(fDao.get(0, Integer.MAX_VALUE)); updateMoveModel(); target.add(folders, moveDropDown); } }); item.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { selectFolder(item, item.getModelObject().getId(), target); } }); setFolderClass(item); } }).setOutputMarkupId(true)); SearchableDataProvider<PrivateMessage> sdp = new SearchableDataProvider<PrivateMessage>( PrivateMessageDao.class) { private static final long serialVersionUID = 1L; @Override protected PrivateMessageDao getDao() { return (PrivateMessageDao) super.getDao(); } @Override public Iterator<? extends PrivateMessage> iterator(long first, long count) { allMessages.clear(); readMessages.clear(); unreadMessages.clear(); String sort = getSort() == null ? "" : "m." + getSort().getProperty(); boolean isAsc = getSort() == null ? true : getSort().isAscending(); return getDao().get(getUserId(), selectedFolderModel.getObject(), search, sort, isAsc, (int) first, (int) count).iterator(); } @Override public long size() { return getDao().count(getUserId(), selectedFolderModel.getObject(), search); } }; final SearchableDataView<PrivateMessage> dv = new SearchableDataView<PrivateMessage>("messages", sdp) { private static final long serialVersionUID = 1L; @Override protected void populateItem(Item<PrivateMessage> item) { PrivateMessage m = item.getModelObject(); final Long id = m.getId(); allMessages.add(id); if (m.getIsRead()) { readMessages.add(id); } else { unreadMessages.add(id); } item.add(new Label("id", id)); item.add(new Label("from", getDisplayName(m.getFrom()))); item.add(new Label("subject", m.getSubject())); item.add(new Label("send", getDateFormat().format(m.getInserted()))); item.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { long selected = id; if (selectedMessages.contains(id)) { selectedMessages.remove(id); selected = selectedMessages.isEmpty() ? -1 : selectedMessages.iterator().next(); } else { selectedMessages.add(id); } selectMessage(selected, target); target.add(container); } }); StringBuilder cssClass = new StringBuilder(m.getIsRead() ? "" : "unread"); if (selectedMessages.contains(id)) { if (cssClass.length() > 0) { cssClass.append(" "); } cssClass.append("ui-state-active"); } item.add(AttributeModifier.replace("class", cssClass.toString())); } }; PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dv) { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { emptySelection(target); target.add(container); } }; dataContainer = new DataViewContainer<PrivateMessage>(container, dv, navigator); dataContainer.addLink(new OmOrderByBorder<PrivateMessage>("orderById", "id", dataContainer)) .addLink(new OmOrderByBorder<PrivateMessage>("orderByFrom", "from.lastname", dataContainer)) .addLink(new OmOrderByBorder<PrivateMessage>("orderBySubject", "subject", dataContainer)) .addLink(new OmOrderByBorder<PrivateMessage>("orderBySend", "inserted", dataContainer)); add(dataContainer.getLinks()); add(navigator); add(unread.setOutputMarkupId(true)); add(buttons.setOutputMarkupId(true)); buttons.add(toInboxBtn.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { getBean(PrivateMessageDao.class).moveMailsToFolder(selectedMessages, INBOX_FOLDER_ID); selectFolder(selectedFolder, selectedFolderModel.getObject(), target); } })); buttons.add(deleteBtn.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { if (TRASH_FOLDER_ID.equals(selectedFolderModel.getObject())) { getBean(PrivateMessageDao.class).delete(selectedMessages); } else { getBean(PrivateMessageDao.class).moveMailsToFolder(selectedMessages, TRASH_FOLDER_ID); } emptySelection(target); target.add(container); } })); buttons.add(readBtn.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { getBean(PrivateMessageDao.class).updateReadStatus(selectedMessages, true); emptySelection(target); target.add(container, unread); } })); buttons.add(unreadBtn.add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { getBean(PrivateMessageDao.class).updateReadStatus(selectedMessages, false); emptySelection(target); target.add(container); } })); buttons.add(selectDropDown.setOutputMarkupId(true).add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { switch (selectDropDown.getModelObject()) { case SELECT_CHOOSE: break; case SELECT_ALL: selectedMessages.clear(); selectedMessages.addAll(allMessages); break; case SELECT_NONE: selectedMessages.clear(); break; case SELECT_UNREAD: selectedMessages.clear(); selectedMessages.addAll(unreadMessages); break; case SELECT_READ: selectedMessages.clear(); selectedMessages.addAll(readMessages); break; } target.add(container); } })); buttons.add(moveDropDown.setOutputMarkupId(true).add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { Long folderId = moveDropDown.getModelObject().getId(); if (!MOVE_CHOOSE.equals(folderId)) { getBean(PrivateMessageDao.class).moveMailsToFolder(selectedMessages, folderId); } selectFolder(selectedFolder, selectedFolderModel.getObject(), target); } })); selectMessage(-1, null); add(container.add(dv).setOutputMarkupId(true)); //TODO add valid autoupdate add(new AjaxSelfUpdatingTimerBehavior(seconds(15))); add(selectedMessage.add(roomContainer.setVisible(false)).setOutputMarkupId(true)); IDataProvider<UserContact> dp = new IDataProvider<UserContact>() { private static final long serialVersionUID = 1L; @Override public void detach() { } @Override public Iterator<? extends UserContact> iterator(long first, long count) { return getBean(UserContactDao.class).get(getUserId(), (int) first, (int) count).iterator(); } @Override public long size() { return getBean(UserContactDao.class).count(getUserId()); } @Override public IModel<UserContact> model(UserContact object) { return Model.of(object); } }; final DataView<UserContact> dw = new DataView<UserContact>("users", dp) { private static final long serialVersionUID = 1L; private String getName(UserContact uc) { return uc.getOwner().getFirstname() + " " + uc.getOwner().getLastname(); //FIXME salutation } @Override protected void populateItem(Item<UserContact> item) { UserContact uc = item.getModelObject(); final Long contactId = uc.getId(); final Long userId = uc.getOwner().getId(); if (uc.isPending()) { item.add(AttributeModifier.append("class", "unread")); } item.add(new Label("name", getName(uc))); item.add(new WebMarkupContainer("accept").add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { ContactsHelper.acceptUserContact(contactId); updateContacts(target); } }).setVisible(uc.isPending())); item.add(new WebMarkupContainer("decline").add(new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { getBean(UserContactDao.class).delete(contactId); updateContacts(target); } }).setVisible(uc.isPending())); item.add(new WebMarkupContainer("view") .add(AttributeAppender.append("onclick", String.format("showUserInfo(%s);", userId)))); item.add(new WebMarkupContainer("message") .add(AttributeAppender.append("onclick", String.format("privateMessage(%s);", userId))) .setVisible(!uc.isPending())); item.add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { attributes.setEventPropagation(EventPropagation.STOP_IMMEDIATE); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { getBean(UserContactDao.class).delete(contactId); updateContacts(target); } }.setVisible(!uc.isPending())); } }; updateContacts(null); add(contacts.add(dw, pendingContacts, allContacts).setOutputMarkupId(true));//TODO update //hack to add FixedHeaderTable after Tabs. add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void respond(AjaxRequestTarget target) { selectFolder(inbox, INBOX_FOLDER_ID, target); selectMessage(-1, target); } @Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(OnDomReadyHeaderItem.forScript(getCallbackScript())); } }); }
From source file:org.apache.syncope.client.console.wicket.ajax.form.IndicatorModalCloseBehavior.java
License:Apache License
@Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); }
From source file:org.hippoecm.frontend.dialog.DialogLink.java
License:Apache License
public DialogLink(final String id, final IModel<String> linkText, final DialogAction action) { super(id, linkText); setOutputMarkupId(true);/*www .ja v a 2s . co m*/ link = new AjaxLink("dialog-link") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { action.execute(); } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setEventPropagation(BUBBLE); } }; add(link); link.add(new Label("dialog-link-text", linkText)); }