org.apache.wicket.event.Broadcast Java Examples
The following examples show how to use
org.apache.wicket.event.Broadcast.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestorePasswordPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private AjaxFormCommand<Void> createRestorePasswordButton(String id) { return new AjaxFormCommand<Void>(id, new ResourceModel("panel.restore.password.button.restore")) { @Override protected void onInstantiation() { super.onInstantiation(); setBootstrapType(BootstrapType.PRIMARY); } @Override public void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); OrienteerUserRepository.getUserByEmail(emailModel.getObject()) .ifPresent(user -> usersService.restoreUserPassword(user)); emailModel.setObject(null); send(getParent(), Broadcast.BUBBLE, new RestorePasswordEventPayload(target, false)); } }; }
Example #2
Source File: AjaxWizard.java From syncope with Apache License 2.0 | 6 votes |
@Override public final void onCancel() { AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class).orElse(null); try { onCancelInternal(); if (eventSink == null) { send(AjaxWizard.this, Broadcast.BUBBLE, new NewItemCancelEvent<>(item, target)); } else { send(eventSink, Broadcast.EXACT, new NewItemCancelEvent<>(item, target)); } } catch (Exception e) { LOG.warn("Wizard error on cancel", e); sendError(e); ((BaseWebPage) pageRef.getPage()).getNotificationPanel().refresh(target); } }
Example #3
Source File: LoginModalPanel.java From AppStash with Apache License 2.0 | 6 votes |
private LoginPanel loginPanel() { return new LoginPanel("loginPanel") { @Override protected boolean isSubmitLinkVisible() { return false; } @Override protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (authenticate) { Session.get().info(getString("authentication.success")); setResponsePage(getPage()); send(getPage(), Broadcast.BREADTH, new LoginEvent(LoginModalPanel.this, target)); } else { error(getString("authentication.failed")); target.add(modalContainer); } } }; }
Example #4
Source File: CartPanel.java From AppStash with Apache License 2.0 | 6 votes |
private Component cartView() { cartView = new ListView<CartItemInfo>("cart", cartListModel()) { @Override protected void populateItem(ListItem<CartItemInfo> item) { WebMarkupContainer cartItem = new WebMarkupContainer("item"); cartItem.add(new Label("name", new PropertyModel<String>(item.getModel(), "product.name"))); cartItem.add(new IndicatingAjaxLink<Void>("delete") { @Override public void onClick(AjaxRequestTarget target) { IModel<CartItemInfo> model = item.getModel(); send(CartPanel.this, Broadcast.BREADTH, new RemoveFromCartEvent(model.getObject(), target)); } }); cartItem.add(new Label("price", new PriceModel(new PropertyModel<>(item.getModel(), "totalSum")))); item.add(cartItem); } }; cartView.setReuseItems(false); cartView.setOutputMarkupId(true); return cartView; }
Example #5
Source File: AjaxWizard.java From syncope with Apache License 2.0 | 6 votes |
private Serializable onApply(final AjaxRequestTarget target) throws TimeoutException { try { Future<Pair<Serializable, Serializable>> executor = execute(new ApplyFuture(target)); Pair<Serializable, Serializable> res = executor.get(getMaxWaitTimeInSeconds(), TimeUnit.SECONDS); if (res.getLeft() != null) { send(pageRef.getPage(), Broadcast.BUBBLE, res.getLeft()); } return res.getRight(); } catch (InterruptedException | ExecutionException e) { if (e.getCause() instanceof CaptchaNotMatchingException) { throw (CaptchaNotMatchingException) e.getCause(); } throw new WicketRuntimeException(e); } }
Example #6
Source File: AnySelectionDirectoryPanel.java From syncope with Apache License 2.0 | 6 votes |
@Override public ActionsPanel<A> getActions(final IModel<A> model) { final ActionsPanel<A> panel = super.getActions(model); panel.add(new ActionLink<A>() { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target, final A ignore) { send(AnySelectionDirectoryPanel.this, Broadcast.BUBBLE, new ItemSelection<>(target, model.getObject())); } }, ActionType.SELECT, AnyEntitlement.READ.getFor(type)); return panel; }
Example #7
Source File: SearchClausePanel.java From syncope with Apache License 2.0 | 6 votes |
public void enableSearch(final IEventSink resultContainer) { this.resultContainer = resultContainer; this.searchButton.setEnabled(true); this.searchButton.setVisible(true); field.add(PREVENT_DEFAULT_RETURN); field.add(new AjaxEventBehavior(Constants.ON_KEYDOWN) { private static final long serialVersionUID = -7133385027739964990L; @Override protected void onEvent(final AjaxRequestTarget target) { if (resultContainer == null) { send(SearchClausePanel.this, Broadcast.BUBBLE, new SearchEvent(target)); } else { send(resultContainer, Broadcast.EXACT, new SearchEvent(target)); } } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AJAX_SUBMIT_ON_RETURN.accept(attributes); } }); }
Example #8
Source File: ActionPanel.java From syncope with Apache License 2.0 | 6 votes |
protected void beforeOnClick(final AjaxRequestTarget target) { switch (this.action.getType()) { case DELETE: case CREATE: case MEMBERS: case MAPPING: case SET_LATEST_SYNC_TOKEN: case REMOVE_SYNC_TOKEN: case EDIT_APPROVAL: case CLAIM: send(this, Broadcast.BUBBLE, new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target)); break; default: break; } }
Example #9
Source File: CartPanel.java From the-app with Apache License 2.0 | 6 votes |
private Component cartView() { cartView = new ListView<CartItemInfo>("cart", cartListModel()) { @Override protected void populateItem(ListItem<CartItemInfo> item) { WebMarkupContainer cartItem = new WebMarkupContainer("item"); cartItem.add(new Label("name", new PropertyModel<String>(item.getModel(), "product.name"))); cartItem.add(new IndicatingAjaxLink<Void>("delete") { @Override public void onClick(AjaxRequestTarget target) { IModel<CartItemInfo> model = item.getModel(); send(CartPanel.this, Broadcast.BREADTH, new RemoveFromCartEvent(model.getObject(), target)); } }); cartItem.add(new Label("price", new PriceModel(new PropertyModel<>(item.getModel(), "totalSum")))); item.add(cartItem); } }; cartView.setReuseItems(false); cartView.setOutputMarkupId(true); return cartView; }
Example #10
Source File: StatementEditor.java From inception with Apache License 2.0 | 6 votes |
private void actionMakeExplicit(AjaxRequestTarget aTarget) { try { // add the statement as-is to the knowledge base kbService.upsertStatement(kbModel.getObject(), statement.getObject()); // to update the statement in the UI, one could either reload all statements of the // corresponding instance or (much easier) just set the inferred attribute of the // KBStatement to false, so that's what's done here statement.getObject().setInferred(false); aTarget.add(this); send(getPage(), Broadcast.BREADTH, new AjaxStatementChangedEvent(aTarget, statement.getObject())); } catch (RepositoryException e) { error("Unable to make statement explicit " + e.getLocalizedMessage()); LOG.error("Unable to make statement explicit.", e); aTarget.addChildren(getPage(), IFeedback.class); } }
Example #11
Source File: StatementEditor.java From inception with Apache License 2.0 | 6 votes |
private void actionSave(AjaxRequestTarget aTarget, Form<KBStatement> aForm) { KBStatement modifiedStatement = aForm.getModelObject(); if (modifiedStatement.getValue() == null) { error("The value of statement cannot be empty"); aTarget.addChildren(getPage(), IFeedback.class); return; } try { // persist the modified statement and replace the original, unchanged model KBStatement oldStatement = statement.getObject(); kbService.upsertStatement(kbModel.getObject(), modifiedStatement); statement.setObject(modifiedStatement); // switch back to ViewMode and send notification to listeners actionCancelExistingStatement(aTarget); send(getPage(), Broadcast.BREADTH, new AjaxStatementChangedEvent(aTarget, statement.getObject(), oldStatement)); } catch (RepositoryException e) { error("Unable to update statement: " + e.getLocalizedMessage()); LOG.error("Unable to update statement.", e); aTarget.addChildren(getPage(), IFeedback.class); } }
Example #12
Source File: LoginModalPanel.java From the-app with Apache License 2.0 | 6 votes |
private LoginPanel loginPanel() { return new LoginPanel("loginPanel") { @Override protected boolean isSubmitLinkVisible() { return false; } @Override protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (authenticate) { Session.get().info(getString("authentication.success")); setResponsePage(getPage()); send(getPage(), Broadcast.BREADTH, new LoginEvent(LoginModalPanel.this, target)); } else { error(getString("authentication.failed")); target.add(modalContainer); } } }; }
Example #13
Source File: SchemaOClassesModalPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private Command<OClass> createCancelCommand(OrienteerDataTable<OClass, String> table) { return new AjaxFormCommand<OClass>(new ResourceModel("widget.architect.editor.list.classes.command.cancel"), table) { @Override protected void onInstantiation() { super.onInstantiation(); setBootstrapType(BootstrapType.DANGER); setIcon(FAIconType.times); } @Override public void onClick(Optional<AjaxRequestTarget> targetOptional) { if (targetOptional.isPresent()) { AjaxRequestTarget target = targetOptional.get(); executeCallback(target, "null"); SchemaOClassesModalPanel.this.send( getParent(), Broadcast.BUBBLE, new CloseModalWindowEvent(target, SchemaOClassesModalPanel.this::onModalClose) ); } } }; }
Example #14
Source File: StatementEditor.java From inception with Apache License 2.0 | 6 votes |
private void actionMakeExplicit(AjaxRequestTarget aTarget) { try { // add the statement as-is to the knowledge base kbService.upsertStatement(kbModel.getObject(), statement.getObject()); // to update the statement in the UI, one could either reload all statements of the // corresponding instance or (much easier) just set the inferred attribute of the // KBStatement to false, so that's what's done here statement.getObject().setInferred(false); aTarget.add(this); send(getPage(), Broadcast.BREADTH, new AjaxStatementChangedEvent(aTarget, statement.getObject())); } catch (RepositoryException e) { error("Unable to make statement explicit " + e.getLocalizedMessage()); LOG.error("Unable to make statement explicit.", e); aTarget.addChildren(getPage(), IFeedback.class); } }
Example #15
Source File: AddTabCommand.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected void initializeContent(final ModalWindow modal) { modal.setTitle(new ResourceModel("command.add.tab")); modal.setContent(new AddTabDialog<T>(modal.getContentId()) { private static final long serialVersionUID = 1L; @Override protected void onCreateTab(String name, Optional<AjaxRequestTarget> targetOptional) { targetOptional.ifPresent(modal::close); if(Strings.isEmpty(name)) { name = getLocalizer().getString("command.add.tab.modal.defaultname", null); } AbstractWidgetPage<T> page = (AbstractWidgetPage<T>)findPage(); page.getCurrentDashboard().setModeObject(DisplayMode.VIEW); //Close action on current tab page.addTab(name); page.selectTab(name, targetOptional); send(page, Broadcast.DEPTH, new SwitchDashboardTabEvent(targetOptional)); page.getCurrentDashboard().setModeObject(DisplayMode.EDIT); //Open action on new tab targetOptional.ifPresent(target -> target.add(page.getCurrentDashboardComponent())); } }); modal.setAutoSize(true); modal.setMinimalWidth(300); }
Example #16
Source File: StatementEditor.java From inception with Apache License 2.0 | 6 votes |
private void actionSave(AjaxRequestTarget aTarget, Form<KBStatement> aForm) { KBStatement modifiedStatement = aForm.getModelObject(); try { String language = aForm.getModelObject().getLanguage() != null ? aForm.getModelObject().getLanguage() : kbModel.getObject().getDefaultLanguage(); modifiedStatement.setLanguage(language); // persist the modified statement and replace the original, unchanged model kbService.upsertStatement(kbModel.getObject(), modifiedStatement); statement.setObject(modifiedStatement); // switch back to ViewMode and send notification to listeners actionCancelExistingStatement(aTarget); send(getPage(), Broadcast.BREADTH, new AjaxStatementChangedEvent(aTarget, statement.getObject())); } catch (RepositoryException e) { error("Unable to update statement: " + e.getLocalizedMessage()); LOG.error("Unable to update statement.", e); aTarget.addChildren(getPage(), IFeedback.class); } }
Example #17
Source File: SideInfoPanel.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(newContent("content")); add(new AjaxLink<Void>("close") { @Override public void onClick(AjaxRequestTarget target) { String script = String.format("$('#%s').hide('slide', {direction: 'right', duration: 200});", SideInfoPanel.this.getMarkupId()); target.appendJavaScript(script); send(getPage(), Broadcast.BREADTH, new SideInfoClosed(target)); } }); add(AttributeAppender.append("class", "side-info closed")); }
Example #18
Source File: BpmnPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public void onEvent(IEvent<?> event) { if(event.getPayload() instanceof ActionPerformedEvent && event.getType().equals(Broadcast.BUBBLE)) { ActionPerformedEvent<?> apEvent = (ActionPerformedEvent<?>)event.getPayload(); if(apEvent.getCommand()!=null && apEvent.getCommand().isChangingDisplayMode() && apEvent.isAjax()) { apEvent.getTarget().get().add(this); } } }
Example #19
Source File: AbstractWidgetPage.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public void initialize() { super.initialize(); add(tabbedPanel = new TabbedPanel<DashboardTab>("dashboardTabs", getDashboardTabs()){ @Override protected void onLinkClick(AjaxRequestTarget target) { super.onLinkClick(target); send(AbstractWidgetPage.this, Broadcast.DEPTH, new SwitchDashboardTabEvent(Optional.ofNullable(target))); } }); }
Example #20
Source File: RestorePasswordPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private AjaxLink<Void> createLoginLink(String id) { return new AjaxLink<Void>(id) { @Override public void onClick(AjaxRequestTarget target) { emailModel.setObject(null); send(getParent(), Broadcast.BUBBLE, new RestorePasswordEventPayload(target, false)); } }; }
Example #21
Source File: OUsersLoginButtonsPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private AjaxLink<Void> createForgotPasswordLink(String id) { return new AjaxLink<Void>(id) { @Override public void onClick(AjaxRequestTarget target) { send(this, Broadcast.BUBBLE, new RestorePasswordEventPayload(target, true)); } @Override protected void onConfigure() { super.onConfigure(); setVisible(OrienteerUserModuleRepository.isRestorePassword()); } }; }
Example #22
Source File: SchemasPanel.java From syncope with Apache License 2.0 | 5 votes |
public SchemasPanel(final String id, final PageReference pageRef) { super(id); this.pageRef = pageRef; Model<String> keywordModel = new Model<>(StringUtils.EMPTY); WebMarkupContainer searchBoxContainer = new WebMarkupContainer("searchBox"); add(searchBoxContainer); Form<?> form = new Form<>("form"); searchBoxContainer.add(form); AjaxTextFieldPanel filter = new AjaxTextFieldPanel("filter", "filter", keywordModel, true); form.add(filter.hideLabel().setOutputMarkupId(true).setRenderBodyOnly(true)); AjaxButton search = new AjaxButton("search") { private static final long serialVersionUID = 8390605330558248736L; @Override protected void onSubmit(final AjaxRequestTarget target) { send(SchemasPanel.this, Broadcast.DEPTH, new SchemaTypePanel.SchemaSearchEvent(target, keywordModel.getObject())); } }; search.setOutputMarkupId(true); form.add(search); form.setDefaultButton(search); Accordion accordion = new Accordion("accordionPanel", buildTabList()); accordion.setOutputMarkupId(true); add(accordion); }
Example #23
Source File: SchemaOClassesModalPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private Command<OClass> createAddClassesCommand(OrienteerDataTable<OClass, String> table) { return new AddOClassesCommand(new ResourceModel("widget.architect.editor.list.classes.command.add"), table) { @Override protected void performAction(AjaxRequestTarget target, String json) { executeCallback(target, json); send(getParent(), Broadcast.BUBBLE, new CloseModalWindowEvent(target, SchemaOClassesModalPanel.this::onModalClose)); } }; }
Example #24
Source File: LoginPanel.java From AppStash with Apache License 2.0 | 5 votes |
protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (!authenticate) { error(getString("authentication.failed")); target.add(feedback); } else { getAuthenticationService().getAuthenticatedUserInfo(); Session.get().info(getString("authentication.success")); send(this, Broadcast.BREADTH, new LoginEvent(LoginPanel.this, target)); setResponsePage(Application.get().getHomePage()); } }
Example #25
Source File: ProductItemPanel.java From AppStash with Apache License 2.0 | 5 votes |
private IndicatingAjaxLink<Void> addToCartLink() { IndicatingAjaxLink<Void> result = new IndicatingAjaxLink<Void>("addToCartIcon") { @Override public void onClick(AjaxRequestTarget target) { //send wicket event for add to cart target.add(feedback); send(getPage(), Broadcast.BREADTH, new AddToCartEvent(target, getPage(), productInfoModel.getObject(), getTags())); } }; result.setVisible(showAddToCartLink()); return result; }
Example #26
Source File: LayerSelectionPanel.java From webanno with Apache License 2.0 | 5 votes |
private void actionChangeDefaultLayer(AjaxRequestTarget aTarget) { AnnotatorState state = getModelObject(); aTarget.add(relationHint); aTarget.add(forwardAnnotationGroup); // If forward annotation was enabled, disable it if (state.isForwardAnnotation()) { state.setForwardAnnotation(false); } send(this, Broadcast.BUBBLE, new DefaultLayerChangedEvent(layerSelector.getModelObject())); // Save the currently selected layer as a user preference so it is remains active when a // user leaves the application and later comes back to continue annotating long prevDefaultLayer = state.getPreferences().getDefaultLayer(); if (state.getDefaultAnnotationLayer() != null) { state.getPreferences().setDefaultLayer(state.getDefaultAnnotationLayer().getId()); } else { state.getPreferences().setDefaultLayer(-1); } if (prevDefaultLayer != state.getPreferences().getDefaultLayer()) { try { userPreferencesService.savePreferences(state.getProject(), userDao.getCurrentUser().getUsername(), state.getMode(), state.getPreferences()); } catch (IOException e) { handleException(this, aTarget, e); } } }
Example #27
Source File: LinkFeatureEditor.java From webanno with Apache License 2.0 | 5 votes |
private void actionSet(AjaxRequestTarget aTarget) { if (StringUtils.isBlank((String) field.getModelObject()) && getTraits().isEnableRoleLabels()) { error("Must set slot label before changing!"); aTarget.addChildren(getPage(), IFeedback.class); } else { @SuppressWarnings("unchecked") List<LinkWithRoleModel> links = (List<LinkWithRoleModel>) LinkFeatureEditor.this.getModelObject().value; AnnotatorState state = LinkFeatureEditor.this.stateModel.getObject(); FeatureState fs = state.getArmedFeature(); // Update the slot LinkWithRoleModel m = links.get(state.getArmedSlot()); m.role = (String) field.getModelObject(); links.set(state.getArmedSlot(), m); // avoid reordering aTarget.add(content); // Send event - but only if we set the label on a slot which was already filled/saved. // Unset slots only exist in the link editor and if we commit the change here, we // trigger a reload of the feature editors from the CAS which makes the unfilled slots // disappear and leaves behind an armed slot pointing to a removed slot. if (m.targetAddr != -1) { send(this, Broadcast.BUBBLE, new FeatureEditorValueChangedEvent(this, aTarget)); } } }
Example #28
Source File: ProductDetailPage.java From the-app with Apache License 2.0 | 5 votes |
private AbstractLink addToCartLink() { return new IndicatingAjaxLink<Void>("addToCart") { @Override public void onClick(AjaxRequestTarget target) { target.add(feedback); send(getPage(), Broadcast.BREADTH, new AddToCartEvent(target, getPage(), productInfoModel.getObject(), getTags())); } }; }
Example #29
Source File: LoginPanel.java From the-app with Apache License 2.0 | 5 votes |
protected void submitLoginForm(AjaxRequestTarget target, LoginInfo loginInfo) { boolean authenticate = authenticate(loginInfo); if (!authenticate) { error(getString("authentication.failed")); target.add(feedback); } else { getAuthenticationService().getAuthenticatedUserInfo(); Session.get().info(getString("authentication.success")); send(this, Broadcast.BREADTH, new LoginEvent(LoginPanel.this, target)); setResponsePage(Application.get().getHomePage()); } }
Example #30
Source File: AvatarUploadField.java From onedev with MIT License | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); add(dataField = new TextField<String>("data", Model.of(getModelObject()))); WebComponent fileInput = new WebComponent("fileInput"); fileInput.setOutputMarkupId(true); add(fileInput); add(new WebMarkupContainer("fileLabel") { @Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("for", fileInput.getMarkupId()); } }); add(behavior = new AbstractPostAjaxBehavior() { @Override protected void respond(AjaxRequestTarget target) { send(AvatarUploadField.this, Broadcast.BUBBLE, new AvatarFileSelected(target)); } }); }