Example usage for org.apache.wicket.event Broadcast BREADTH

List of usage examples for org.apache.wicket.event Broadcast BREADTH

Introduction

In this page you can find the example usage for org.apache.wicket.event Broadcast BREADTH.

Prototype

Broadcast BREADTH

To view the source code for org.apache.wicket.event Broadcast BREADTH.

Click Source Link

Document

Breadth first traversal.

Usage

From source file:biz.turnonline.ecosystem.origin.frontend.myaccount.page.MyAccountBasics.java

License:Apache License

public MyAccountBasics() {
    add(new FirebaseAppInit(firebaseConfig));

    final MyAccountModel accountModel = new MyAccountModel();
    final IModel<Map<String, Country>> countriesModel = new CountriesModel();

    setModel(accountModel);//from   w  w w .  j  ava  2  s  .  c  o  m

    // form
    Form<Account> form = new Form<Account>("form", accountModel) {
        private static final long serialVersionUID = -938924956863034465L;

        @Override
        protected void onSubmit() {
            Account account = getModelObject();
            send(getPage(), Broadcast.BREADTH, new AccountUpdateEvent(account));
        }
    };
    add(form);

    PropertyModel<Boolean> companyModel = new PropertyModel<>(accountModel, "company");
    form.add(new CompanyPersonSwitcher("isCompanyRadioGroup", companyModel));

    // account email fieldset
    form.add(new Label("email", new PropertyModel<>(accountModel, "email")));

    // company basic info
    final CompanyBasicInfo<Account> basicInfo = new CompanyBasicInfo<Account>("companyData", accountModel) {
        private static final long serialVersionUID = -2992960490517951459L;

        @Override
        protected DropDownChoice<LegalForm> provideLegalForm(String componentId) {
            LegalFormListModel choices = new LegalFormListModel();
            return new IndicatingAjaxDropDown<>(componentId,
                    new LegalFormCodeModel(accountModel, "legalForm", choices), choices,
                    new LegalFormRenderer());
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(account.getCompany());
        }
    };
    form.add(basicInfo);

    // company basic info panel behaviors
    basicInfo.addLegalForm(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 6948210639258798921L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });

    basicInfo.addVatId(new Behavior() {
        private static final long serialVersionUID = 100053137512632023L;

        @Override
        public void onConfigure(Component component) {
            super.onConfigure(component);
            Account account = basicInfo.getModelObject();
            boolean visible;
            if (account == null || account.getBusiness() == null) {
                visible = true;
            } else {
                Boolean vatPayer = account.getBusiness().getVatPayer();
                visible = vatPayer == null ? Boolean.FALSE : vatPayer;
            }

            component.setVisible(visible);
        }
    });

    final TextField taxId = basicInfo.getTaxId();
    final TextField vatId = basicInfo.getVatId();
    final CheckBox vatPayer = basicInfo.getVatPayer();

    basicInfo.addVatPayer(new AjaxFormSubmitBehavior(OnChangeAjaxBehavior.EVENT_NAME) {
        private static final long serialVersionUID = -1238082494184937003L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            Account account = (Account) basicInfo.getDefaultModelObject();
            String rawTaxIdValue = taxId.getRawInput();
            AccountBusiness business = account.getBusiness();

            if (rawTaxIdValue != null && Strings.isEmpty(business == null ? null : business.getVatId())) {
                // VAT country prefix proposal
                String country = business == null ? "" : business.getDomicile();
                country = country.toUpperCase();
                //noinspection unchecked
                vatId.getModel().setObject(country + rawTaxIdValue);
            }

            // must be set manually as getDefaultProcessing() returns false
            vatPayer.setModelObject(!(business == null ? Boolean.FALSE : business.getVatPayer()));

            if (target != null) {
                target.add(vatId.getParent());
            }
        }

        @Override
        public boolean getDefaultProcessing() {
            return false;
        }
    });

    // personal data panel
    PersonalDataPanel<Account> personalData = new PersonalDataPanel<Account>("personalData", accountModel) {
        private static final long serialVersionUID = -2808922906891760016L;

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(!account.getCompany());
        }
    };
    form.add(personalData);

    // personal address panel
    PersonalAddressPanel<Account> address = new PersonalAddressPanel<Account>("personalAddress", accountModel) {
        private static final long serialVersionUID = 3481146248010938807L;

        @Override
        protected DropDownChoice<Country> provideCountry(String componentId) {
            return new IndicatingAjaxDropDown<>(componentId,
                    new PersonalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(),
                    countriesModel);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(!account.getCompany());
        }
    };
    form.add(address);

    address.addCountry(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = -1016447969591778948L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });

    // company address panel
    CompanyAddressPanel<Account> companyAddress;
    companyAddress = new CompanyAddressPanel<Account>("companyAddress", accountModel, false, false) {
        private static final long serialVersionUID = -6760545061622186549L;

        @Override
        protected DropDownChoice<Country> provideCountry(String componentId) {
            return new IndicatingAjaxDropDown<>(componentId,
                    new CompanyDomicileModel(accountModel, countriesModel), new CountryRenderer(),
                    countriesModel);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            Account account = getModelObject();
            this.setVisible(account.getCompany());
        }
    };
    form.add(companyAddress);

    companyAddress.addCountry(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = -5476413125490349124L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });

    IModel<AccountPostalAddress> postalAddressModel = new PropertyModel<>(accountModel, "postalAddress");
    IModel<Boolean> hasAddress = new PropertyModel<>(accountModel, "hasPostalAddress");
    PostalAddressPanel<AccountPostalAddress> postalAddress;
    postalAddress = new PostalAddressPanel<AccountPostalAddress>("postal-address", postalAddressModel,
            hasAddress) {
        private static final long serialVersionUID = -930960688138308527L;

        @Override
        protected DropDownChoice<Country> provideCountry(String componentId) {
            return new IndicatingAjaxDropDown<>(componentId,
                    new PostalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(),
                    countriesModel);
        }
    };
    form.add(postalAddress);

    postalAddress.addStreet(new OnChangeAjaxBehavior() {
        private static final long serialVersionUID = 4050800366443676166L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });

    PropertyModel<Object> billingContactModel = PropertyModel.of(accountModel, "billingContact");
    form.add(new SimplifiedContactFieldSet<>("contact", billingContactModel));
    // save button
    form.add(new IndicatingAjaxButton("save", new I18NResourceModel("button.save"), form));
}

From source file:by.parfen.disptaxi.webapp.etc.AutoComplitePage.java

License:Apache License

/**
 * Constructor.// ww w.  j av a2s. c  o m
 */
public AutoComplitePage() {
    Injector.get().inject(this);

    sampleEvent = new SampleEvent();
    // selectedCity = cityService.get(15L);
    sampleEvent.setCityById(60L);
    streetsList = sampleEvent.getStreets();
    // pointsList = sampleEvent.getPointsList();

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    add(feedback);

    Form<Void> form = new Form<Void>("form");
    add(form);

    final AutoCompleteTextField<String> field = new AutoCompleteTextField<String>("acStreet",
            new Model<String>("")) {
        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }

            List<String> choices = new ArrayList<String>(MAX_AUTO_COMPLETE_ELEMENTS);

            for (final Street streetItem : streetsList) {
                final String streetName = streetItem.getName();

                if (streetName.toUpperCase().startsWith(input.toUpperCase())) {
                    choices.add(streetName);
                    if (choices.size() == MAX_AUTO_COMPLETE_ELEMENTS) {
                        break;
                    }
                }
            }

            return choices.iterator();
        }
    };

    final AutoCompleteTextField<String> fieldPoint = new AutoCompleteTextField<String>("acPoint",
            new Model<String>("")) {
        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }

            List<String> choices = new ArrayList<String>(MAX_AUTO_COMPLETE_ELEMENTS);

            for (final Point pointItem : sampleEvent.getPointsList()) {
                final String pointName = pointItem.getName();

                if (pointName.toUpperCase().startsWith(input.toUpperCase())) {
                    choices.add(pointName);
                    if (choices.size() == MAX_AUTO_COMPLETE_ELEMENTS) {
                        break;
                    }
                }
            }

            return choices.iterator();
        }
    };

    final ItemPanel itemPanel = new ItemPanel("itemPanel");
    add(itemPanel);

    add(new Link<Void>("linkItemInfo") {

        @Override
        public void onClick() {
            info("onSubmit");
            info(itemPanel.getItemInfo());
        }

    });

    final Label label = new Label("label", form.getDefaultModel()) {

        @Override
        public void onEvent(IEvent<?> event) {
            Object payload = event.getPayload();
            if (payload instanceof SampleEvent) {
                SampleEvent sampelEvent = (SampleEvent) payload;
                setDefaultModel(Model
                        .of(sampelEvent.getSelectedStreetName() + ", " + sampelEvent.getSelectedPointName()));
                sampelEvent.getTarget().add(this);
            }
        }

    };

    label.setOutputMarkupId(true);
    add(label);

    form.add(field);
    form.add(fieldPoint);

    field.add(new AjaxFormSubmitBehavior(form, "onchange") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            sampleEvent.setTarget(target);
            sampleEvent.setSelectedStreetName(field.getDefaultModelObjectAsString());
            sampleEvent.setSelectedPointName("");
            send(getPage(), Broadcast.BREADTH, sampleEvent);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
        }
    });

    fieldPoint.add(new AjaxFormSubmitBehavior(form, "onchange") {
        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            sampleEvent.setTarget(target);
            sampleEvent.setSelectedPointName(fieldPoint.getDefaultModelObjectAsString());
            send(getPage(), Broadcast.BREADTH, sampleEvent);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
        }
    });
}

From source file:com.francetelecom.clara.cloud.presentation.applications.ApplicationInformationPanel.java

License:Apache License

private void createButtons() {

    buttonContainer = new WebMarkupContainer("buttonContainer");

    editButton = new AjaxLink("appModifyLink") {

        @Override//from  w ww  .  j  a v  a2  s  . c om
        public void onClick(AjaxRequestTarget target) {
            setEditable(true, target);
        }
    };

    cancelButton = new AjaxLink("appCancelLink") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            setEditable(false, target);
        }
    };

    deleteButton = new AjaxLink("appDeleteLink") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            parentPage.deleteApplication(target, appForm.getModelObject());
            setResponsePage(ApplicationsPage.class);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            String applicationLabel = appForm.getModelObject().getLabel();
            attributes.getAjaxCallListeners()
                    .add(new DeleteConfirmationDecorator(getString("portal.application.action.delete.confirm",
                            new Model<String[]>(new String[] { applicationLabel }))));
        }
    };

    updateButton = new AjaxSubmitLink("appUpdateLink") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                parentPage.updateApplication(target, (Form<Application>) form, members);
                setEditable(false, target);

                List<BreadcrumbsItem> bci = ((SelectedAppPage) getPage()).getBreadcrumbsItems();
                BreadcrumbsItem updatedItem = bci.get(1);
                updatedItem.setName(appForm.getModelObject().getLabel());
                bci.remove(1);
                bci.add(updatedItem);
                send(getPage(), Broadcast.BREADTH, new BreadcrumbsUpdateEvent(bci, target));
            } catch (ApplicationNotFoundException | DuplicateApplicationException
                    | PaasUserNotFoundException e) {
                BusinessExceptionHandler.addError(target, parentPage.getFeedbackPanel(), e);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            setEditable(true, target);
        }
    };

    cancelButton.add(new Label("cancelLabel", getStringResourceModel("portal.application.action.cancel")));
    editButton.add(new Label("modifyLabel", getStringResourceModel("portal.application.action.modify")));
    deleteButton.add(new Label("deleteLabel", getStringResourceModel("portal.application.action.delete")));
    updateButton.add(new Label("updateLabel", getStringResourceModel("portal.application.action.update")));

    buttonContainer.add(cancelButton);
    buttonContainer.add(editButton);
    buttonContainer.add(deleteButton);
    buttonContainer.add(updateButton);

    buttonContainer.setOutputMarkupId(true);

    appForm.add(buttonContainer);

}

From source file:com.francetelecom.clara.cloud.presentation.designer.pages.DesignerHelperPage.java

License:Apache License

public void openModalWindow(AjaxRequestTarget ajaxRequestTarget, LogicalModelItem modelItem,
        boolean configOverride) {
    modalServiceView.setUseInitialHeight(false);
    modalServiceView.setInitialWidth(750);
    Panel serviceFormPanel = getServicePanel(modalServiceView.getContentId(), modelItem, this, false, true,
            configOverride);//from  ww w. java 2s .com
    modalServiceView.setContent(serviceFormPanel);
    modalServiceView.show(ajaxRequestTarget);

    // Send a refresh event in case the modal window contains a CodeMirror instance
    send(serviceFormPanel, Broadcast.BREADTH, new CodeMirrorTextArea.CodeMirrorRefresh(ajaxRequestTarget));
}

From source file:com.francetelecom.clara.cloud.presentation.releases.ReleaseInformationPanel.java

License:Apache License

private void createButtons() {

    buttonContainer = new WebMarkupContainer("buttonContainer");
    editButton = new AjaxLink<Void>("releaseModifyLink") {
        @Override/*from  ww  w. ja v  a2 s .c o  m*/
        public void onClick(AjaxRequestTarget target) {
            setEditable(true, target);
        }
    };

    cancelButton = new AjaxLink<Void>("releaseCancelLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            setEditable(false, target);
        }
    };

    deleteButton = new AjaxLink<ApplicationRelease>("releaseDeleteLink", getModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {

            try {
                manageApplicationRelease.deleteApplicationRelease(getModelObject().getUID());
            } catch (ObjectNotFoundException e) {
                BusinessExceptionHandler handler = new BusinessExceptionHandler(parentPage);
                handler.error(e);
                target.add(parentPage.getFeedbackPanel());
            } catch (BusinessException e) {
                BusinessExceptionHandler handler = new BusinessExceptionHandler(parentPage);
                handler.error(e);
                target.add(parentPage.getFeedbackPanel());
            }

            if (params.getNamedKeys().contains("releaseUid")) {
                params.remove("releaseUid");
            }
            if (params.getNamedKeys().contains("edit")) {
                params.remove("edit");
            }
            if (params.getNamedKeys().contains("step")) {
                params.remove("step");
            }
            setResponsePage(SelectedAppPage.class, params);
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            String releaseLabel = getModelObject().getApplication().getLabel() + " - "
                    + getModelObject().getReleaseVersion();
            attributes.getAjaxCallListeners()
                    .add(new DeleteConfirmationDecorator(getString("portal.release.action.delete.confirm",
                            new Model<String[]>(new String[] { releaseLabel }))));
        }

    };

    updateButton = new AjaxSubmitLink("releaseUpdateLink") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                ApplicationRelease applicationRelease = manageApplicationRelease
                        .updateApplicationRelease((ApplicationRelease) form.getModelObject());
                form.setDefaultModel(new CompoundPropertyModel<ApplicationRelease>(applicationRelease));
                target.add(form);
            } catch (ObjectNotFoundException e) {
                BusinessExceptionHandler handler = new BusinessExceptionHandler(parentPage);
                handler.error(e);
                target.add(parentPage.getFeedbackPanel());
            }
            setEditable(false, target);

            List<BreadcrumbsItem> bci = ((SelectedReleasePage) getPage()).getBreadcrumbsItems();
            BreadcrumbsItem updatedItem = bci.get(2);
            ApplicationRelease updatedRelease = releaseForm.getModelObject();
            updatedItem.setName(updatedRelease.getReleaseVersion());
            bci.remove(2);
            bci.add(updatedItem);
            send(getPage(), Broadcast.BREADTH, new BreadcrumbsUpdateEvent(bci, target));
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            setEditable(true, target);
        }
    };

    cancelButton.add(new Label("cancelLabel", new StringResourceModel("portal.release.action.cancel", null)));
    editButton.add(new Label("modifyLabel", new StringResourceModel("portal.release.action.modify", null)));
    deleteButton.add(new Label("deleteLabel", new StringResourceModel("portal.release.action.delete", null)));
    updateButton.add(new Label("updateLabel", new StringResourceModel("portal.release.action.update", null)));

    buttonContainer.add(cancelButton);
    buttonContainer.add(editButton);
    buttonContainer.add(deleteButton);
    buttonContainer.add(updateButton);

    buttonContainer.setOutputMarkupId(true);

    releaseForm.add(buttonContainer);

}

From source file:com.googlecode.wicket.jquery.ui.interaction.Draggable.java

License:Apache License

/**
 * Initialization//from w  w w.j  a  v a2s.  c  o m
 */
private void init() {
    this.options = new Options();

    this.dragStartBehavior = new JQueryAjaxBehavior(this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Broadcast getBroadcast() {
            return Broadcast.BREADTH; //start from the page (see getSink()) and go deeper, this is important for the Droppable to be notified
        }

        @Override
        protected IEventSink getSink() {
            return Draggable.this.getPage();
        }

        @Override
        protected JQueryEvent newEvent(AjaxRequestTarget target) {
            return new DragStartEvent(target);
        }
    };

    this.dragStopBehavior = new JQueryAjaxBehavior(this) {

        private static final long serialVersionUID = 1L;

        @Override
        protected JQueryEvent newEvent(AjaxRequestTarget target) {
            return new DragStopEvent(target);
        }
    };
}

From source file:de.codepitbull.events.HomePage.java

License:Apache License

@Override
public void onEvent(IEvent<?> event) {
    if (event.getPayload() instanceof ResetEvent) {
        choices.clear();//from w w  w  .j  a va2  s .  com
        //Nach dem Lschen ein Default-Ajax-Event erzeugen und an alle Komponenten schicken
        send(this, Broadcast.BREADTH, ((ResetEvent) event.getPayload()).getTarget());
    }
}

From source file:de.elatexam.editor.components.panels.tree.ComplexTaskDefTree.java

License:Open Source License

/**
 * Inform the tree about the selection. This is needed to be able to fire a {@link TreeSelectionEvent}.
 *
 * @param model/*from   w  w  w. j  a v  a 2s . co m*/
 * @param tree2
 * @param target
 */
void select(final IModel<T> model, final AjaxRequestTarget target) {
    if (selectedModel != null && selectedModel.getObject() != null) {
        // redraw the now deselected node
        updateNode(selectedModel.getObject(), target);
        selectedModel.detach();
        selectedModel = null;
    }
    selectedModel = model;
    updateNode(model.getObject(), target);
    this.currentTaskdef = (IModel<ComplexTaskDef>) findCurrentTaskDef(model);

    send(getPage(), Broadcast.BREADTH, target);
}

From source file:de.lichtflut.glasnost.is.components.devops.perceptions.CreatePerceptionsWizzardPanel.java

License:Apache License

protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
    for (List<Perception> list : model.getObject()) {
        perceptionDefinitionService.store(list);
    }/* w  ww  .  j a v a 2  s. c o m*/
    send(getPage(), Broadcast.BREADTH, new ModelChangeEvent<Void>(ModelChangeEvent.PERCEPTION));
}

From source file:de.lichtflut.glasnost.is.components.devops.perceptions.PerceptionManagementPanel.java

License:Apache License

private AjaxLink<?> createDeleteLink(final IModel<Perception> model) {
    final AjaxLink<?> link = new AjaxLink<Void>("delete") {
        @Override/*from  w  ww .  j a  v  a 2  s  . com*/
        public void onClick(final AjaxRequestTarget target) {
            openConfirmationDialog(model);
        }

        private void openConfirmationDialog(final IModel<Perception> model) {
            final String confirmation = getString("dialog.confirmation.delete") + " '"
                    + model.getObject().getID() + "'";
            final DialogHoster hoster = findParent(DialogHoster.class);
            hoster.openDialog(new ConfirmationDialog(hoster.getDialogID(), Model.of(confirmation)) {
                @Override
                public void onConfirm() {
                    removePerception(model);
                    send(getPage(), Broadcast.BREADTH, new ModelChangeEvent<Void>(ModelChangeEvent.PERCEPTION));
                }

                @Override
                public void onCancel() {
                    hoster.closeDialog(this);
                }
            });
        }
    };
    return link;
}