Example usage for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior

List of usage examples for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior

Introduction

In this page you can find the example usage for org.apache.wicket.ajax AjaxEventBehavior AjaxEventBehavior.

Prototype

public AjaxEventBehavior(String event) 

Source Link

Document

Construct.

Usage

From source file:org.apache.openmeetings.web.admin.servers.ServersPanel.java

License:Apache License

public ServersPanel(String id) {
    super(id);// w w  w  .  j  ava 2s.  co m
    SearchableDataView<Server> dataView = new SearchableDataView<Server>("serverList",
            new SearchableDataProvider<Server>(ServerDao.class)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final Item<Server> item) {
            final Server server = item.getModelObject();
            item.add(new Label("id"));
            item.add(new Label("name"));
            item.add(new Label("address"));
            item.add(new AjaxEventBehavior("click") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(server);
                    form.hideNewRecord();
                    target.add(form, listContainer);
                    target.appendJavaScript("omServerPanelInit();");
                }
            });
            item.add(AttributeModifier.replace("class",
                    getRowClass(server.getId(), form.getModelObject().getId())));
        }
    };

    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    };
    DataViewContainer<Server> container = new DataViewContainer<Server>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<Server>("orderById", "id", container))
            .addLink(new OmOrderByBorder<Server>("orderByName", "name", container))
            .addLink(new OmOrderByBorder<Server>("orderByAddress", "address", container));
    add(container.getLinks());
    add(navigator);

    form = new ServerForm("form", listContainer, new Server());
    form.showNewRecord();
    add(form);

}

From source file:org.apache.openmeetings.web.admin.users.UsersPanel.java

License:Apache License

public UsersPanel(String id) {
    super(id);//from ww  w . ja  va  2s  .com

    final SearchableDataView<User> dataView = new SearchableDataView<User>("userList",
            new SearchableDataProvider<User>(UserDao.class)) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<User> item) {
            User u = item.getModelObject();
            final Long userId = u.getId();
            item.add(new Label("id"));
            item.add(new Label("login"));
            item.add(new Label("firstname"));
            item.add(new Label("lastname"));
            item.add(new AjaxEventBehavior("click") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(getBean(UserDao.class).get(userId));
                    form.hideNewRecord();
                    form.update(target);
                }
            });
            item.add(AttributeModifier.append("class", getRowClass(u.getId(), form.getModelObject().getId())));
        }
    };
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    };
    DataViewContainer<User> container = new DataViewContainer<User>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<User>("orderById", "id", container))
            .addLink(new OmOrderByBorder<User>("orderByLogin", "login", container))
            .addLink(new OmOrderByBorder<User>("orderByFirstName", "firstname", container))
            .addLink(new OmOrderByBorder<User>("orderByLastName", "lastname", container));
    add(container.getLinks());
    add(navigator);

    UserDao userDao = getBean(UserDao.class);
    form = new UserForm("form", listContainer, userDao.getNewUserInstance(userDao.get(getUserId())), warning);
    form.showNewRecord();
    add(form, warning);
}

From source file:org.apache.openmeetings.web.common.ConfirmableAjaxBorder.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    add(new AjaxEventBehavior("click") {
        private static final long serialVersionUID = 1L;

        @Override/*from w  w  w . ja va  2  s .  c  o  m*/
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            ConfirmableAjaxBorder.this.updateAjaxAttributes(attributes);
        }

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            dialog.open(target);
        }
    });
    addToBorder(form.add(dialog));
}

From source file:org.apache.openmeetings.web.common.OmButton.java

License:Apache License

public OmButton(String id) {
    super(id);/*from w w  w  .j  ava  2  s  . c om*/
    add(new AjaxEventBehavior("click") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            OmButton.this.onClick(target);
        }
    });
}

From source file:org.apache.openmeetings.web.common.tree.FileItemPanel.java

License:Apache License

public FileItemPanel(String id, final IModel<? extends FileItem> model, final FileTreePanel fileTreePanel) {
    super(id, model, fileTreePanel);
    if (model.getObject() instanceof Recording) {
        Recording r = (Recording) model.getObject();
        long errorCount = getBean(RecordingLogDao.class).countErrors(r.getId());
        boolean visible = errorCount != 0
                || (Status.RECORDING != r.getStatus() && Status.CONVERTING != r.getStatus() && !r.exists());
        errors.add(new AjaxEventBehavior("click") {
            private static final long serialVersionUID = 1L;

            @Override//from  www . j ava 2s.c  o  m
            protected void onEvent(AjaxRequestTarget target) {
                fileTreePanel.errorsDialog.setDefaultModel(model);
                fileTreePanel.errorsDialog.open(target);
            }
        }).setVisible(visible);
    } else {
        errors.setVisible(false);
    }
    drag.add(errors);
}

From source file:org.apache.openmeetings.web.common.tree.FileTreePanel.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();
    final AddFolderDialog addFolder = new AddFolderDialog("addFolder", Application.getString(712)) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w w w .  jav  a  2s  .  co  m*/
        protected void onSubmit(AjaxRequestTarget target) {
            createFolder(target, getModelObject());
        }
    };
    add(addFolder);
    Droppable<FileItem> trashToolbar = new Droppable<FileItem>("trash-toolbar") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("hoverClass", Options.asString("ui-state-hover trash-toolbar-hover"));
            behavior.setOption("accept", Options.asString(".recorditem, .fileitem"));
        }

        @Override
        public JQueryBehavior newWidgetBehavior(String selector) {
            return new DroppableBehavior(selector, this) {
                private static final long serialVersionUID = 1L;

                @Override
                protected JQueryAjaxBehavior newOnDropAjaxBehavior(IJQueryAjaxAware source) {
                    return new OnDropAjaxBehavior(source) {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public CharSequence getCallbackFunctionBody(CallbackParameter... parameters) {
                            String dialogId = UUID.randomUUID().toString();

                            String statement = "var $drop = $(this);";
                            statement += "$('body').append('<div id=" + dialogId + ">" + getString("713")
                                    + "</div>');";
                            statement += "$( '#" + dialogId + "' ).dialog({ title: '" + getString("80")
                                    + "', dialogClass: 'no-close', buttons: [";
                            statement += "    { text: '" + getString("54")
                                    + "', click: function() { $drop.append(ui.draggable); $(this).dialog('close'); "
                                    + super.getCallbackFunctionBody(parameters) + " } },";
                            statement += "    { text: '" + getString("25")
                                    + "', click: function() { $( this ).dialog('close'); } } ";
                            statement += "],";
                            statement += "close: function(event, ui) { $(this).dialog('destroy').remove(); }";
                            statement += "});";

                            return statement;
                        }
                    };
                }
            };
        }

        @Override
        public void onDrop(AjaxRequestTarget target, Component component) {
            Object o = component.getDefaultModelObject();
            if (o instanceof FileItem) {
                delete((FileItem) o, target);
            }
        }
    };
    add(trashToolbar);
    trashToolbar.add(getUpload("upload"));
    trashToolbar.add(new WebMarkupContainer("create").add(new AjaxEventBehavior("click") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            addFolder.open(target);
        }
    }));
    trashToolbar.add(new WebMarkupContainer("refresh").add(new AjaxEventBehavior("click") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            update(target);
        }
    }));
    trashToolbar.add(new ConfirmableAjaxBorder("trash", getString("80"), getString("713")) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            FileItem f = selected.getObject();
            if (f != null && f.getId() != null) {
                super.onEvent(target);
            }
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            delete(selected.getObject(), target);
        }
    });

    add(trees.add(tree).setOutputMarkupId(true));
    updateSizes();
    add(sizes.add(new Label("homeSize", homeSize), new Label("publicSize", publicSize))
            .setOutputMarkupId(true));
    add(errorsDialog);
}

From source file:org.apache.openmeetings.web.components.admin.configurations.ConfigsPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public ConfigsPanel(String id) {
    super(id);/*w ww  .  ja  va 2 s .  c o m*/

    SearchableDataView<Configuration> dataView = new SearchableDataView<Configuration>("configList",
            new SearchableDataProvider<Configuration>(ConfigurationDao.class)) {
        private static final long serialVersionUID = 8715559628755439596L;

        @Override
        protected void populateItem(final Item<Configuration> item) {
            final Configuration configuration = item.getModelObject();
            item.add(new Label("configuration_id", "" + configuration.getConfiguration_id()));
            item.add(new Label("conf_key", "" + configuration.getConf_key()));
            item.add(new Label("conf_value", "" + configuration.getConf_value()));
            item.add(new AjaxEventBehavior("onclick") {
                private static final long serialVersionUID = -8069413566800571061L;

                protected void onEvent(AjaxRequestTarget target) {
                    form.hideNewRecord();
                    form.setModelObject(configuration);
                    target.add(form);
                    target.appendJavaScript("omConfigPanelInit();");
                }
            });
            item.add(AttributeModifier.replace("class",
                    "clickable " + ((item.getIndex() % 2 == 1) ? "even" : "odd")));
        }
    };
    final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer");
    add(listContainer.add(dataView).setOutputMarkupId(true));
    DataViewContainer<Configuration> container = new DataViewContainer<Configuration>(listContainer, dataView);
    container.setLinks(new OrderByBorder<Configuration>("orderById", "configuration_id", container),
            new OrderByBorder<Configuration>("orderByKey", "conf_key", container),
            new OrderByBorder<Configuration>("orderByValue", "conf_value", container));
    add(container.orderLinks);
    add(new PagedEntityListPanel("navigator", dataView) {
        private static final long serialVersionUID = 5097048616003411362L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    });

    form = new ConfigForm("form", listContainer, new Configuration());
    form.showNewRecord();
    add(form);

}

From source file:org.apache.openmeetings.web.components.admin.groups.GroupsPanel.java

License:Apache License

@SuppressWarnings("unchecked")
public GroupsPanel(String id) {
    super(id);//from w ww. ja va  2 s  . c  o m
    final WebMarkupContainer listContainer = new WebMarkupContainer("listContainer");
    final WebMarkupContainer addUsersBtn = new WebMarkupContainer("addUsersBtn");
    addUsersBtn.add(new AjaxEventBehavior("onclick") {
        private static final long serialVersionUID = 6037994365235148885L;

        protected void onEvent(AjaxRequestTarget target) {
            addUsersForm.clear();
            target.add(addUsersForm);
            target.appendJavaScript("addUsers();");
        }
    });

    //Adding the Group Form
    form = new GroupForm("form", listContainer, new Organisation()) {
        private static final long serialVersionUID = -3042797340375988889L;

        @Override
        protected void onModelChanged() {
            super.onModelChanged();
            boolean orgEmpty = getModelObject().getOrganisation_id() == null;
            if (orgEmpty) {
                addUsersBtn.add(AttributeModifier.replace("class", "formNewButton disabled"));
            } else {
                addUsersBtn.add(AttributeModifier.replace("class", "formNewButton"));
            }
            addUsersBtn.setEnabled(!orgEmpty);
            addUsersForm.setOrganisation(getModelObject());
        }

        @Override
        void updateView(AjaxRequestTarget target) {
            super.updateView(target);
            target.add(addUsersBtn);
        }
    };
    add(form.add(addUsersBtn.setOutputMarkupId(true)));
    addUsersForm = new AddUsersForm("addUsers", form);
    add(addUsersForm);

    //List view
    SearchableDataView<Organisation> dataView = new SearchableDataView<Organisation>("groupList",
            new SearchableDataProvider<Organisation>(OrganisationDao.class)) {
        private static final long serialVersionUID = 8715559628755439596L;

        @Override
        protected void populateItem(Item<Organisation> item) {
            final Organisation organisation = item.getModelObject();
            item.add(new Label("organisation_id", "" + organisation.getOrganisation_id()));
            item.add(new Label("name", "" + organisation.getName()));
            item.add(new AjaxEventBehavior("onclick") {
                private static final long serialVersionUID = -8069413566800571061L;

                protected void onEvent(AjaxRequestTarget target) {
                    form.hideNewRecord();
                    form.setModelObject(organisation);
                    form.updateView(target);
                    target.appendJavaScript("groupsInit();");
                }
            });
            item.add(AttributeModifier.append("class",
                    "clickable " + ((item.getIndex() % 2 == 1) ? "even" : "odd")));
        }
    };

    //Paging
    add(listContainer.add(dataView).setOutputMarkupId(true));
    DataViewContainer<Organisation> container = new DataViewContainer<Organisation>(listContainer, dataView);
    container.setLinks(new OrderByBorder<Organisation>("orderById", "organisation_id", container),
            new OrderByBorder<Organisation>("orderByName", "name", container));
    add(container.orderLinks);
    add(new PagedEntityListPanel("navigator", dataView) {
        private static final long serialVersionUID = 5097048616003411362L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    });
}

From source file:org.apache.openmeetings.web.components.admin.groups.GroupUsersPanel.java

License:Apache License

public GroupUsersPanel(String id, long orgId) {
    super(id);//from w  w  w.j  a  v  a2 s  .c om
    this.organisationId = orgId;
    setOutputMarkupId(true);

    SearchableDataView<Organisation_Users> dataView = new SearchableDataView<Organisation_Users>("userList",
            new SearchableDataProvider<Organisation_Users>(OrganisationUserDao.class) {
                private static final long serialVersionUID = 1L;

                public long size() {
                    return search == null ? Application.getBean(OrganisationUserDao.class).count(organisationId)
                            : Application.getBean(OrganisationUserDao.class).count(organisationId, search);
                }

                public java.util.Iterator<? extends Organisation_Users> iterator(long first, long count) {
                    return (search == null && getSort() == null
                            ? Application.getBean(OrganisationUserDao.class).get(organisationId, (int) first,
                                    (int) count)
                            : Application.getBean(OrganisationUserDao.class).get(organisationId, search,
                                    (int) first, (int) count, getSortStr())).iterator();
                }
            }) {
        private static final long serialVersionUID = 8715559628755439596L;

        @Override
        protected void populateItem(Item<Organisation_Users> item) {
            final Organisation_Users orgUser = item.getModelObject();
            User u = orgUser.getUser();
            if (u != null) {
                item.add(new Label("label", Model.of(getUser(u))));
            } else {
                item.add(new Label("label", Model.of("")));
            }
            item.add(new WebMarkupContainer("deleteUserBtn").add(new AjaxEventBehavior("onclick") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                    super.updateAjaxAttributes(attributes);
                    attributes.getAjaxCallListeners().add(new ConfirmCallListener(833L));
                }

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    Application.getBean(OrganisationUserDao.class).delete(orgUser, WebSession.getUserId());
                    target.add(GroupUsersPanel.this);
                }
            }));
            item.add(AttributeModifier.append("class", ((item.getIndex() % 2 == 1) ? "even" : "odd")));
        }
    };
    add(dataView).setOutputMarkupId(true);
    add(new PagedEntityListPanel("navigator", dataView) {
        private static final long serialVersionUID = 5097048616003411362L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            target.add(GroupUsersPanel.this);
        }
    });
}

From source file:org.apache.openmeetings.web.components.admin.labels.LangForm.java

License:Apache License

/**
 * Render Main/* ww  w. j a  va  2s.  c  om*/
 * 
 * @param id
 * @param listContainer
 * @param language
 * @param langPanel
 */
public LangForm(String id, final WebMarkupContainer listContainer, final LangPanel langPanel) {
    super(id);
    setOutputMarkupId(true);

    FieldLanguageDao langDao = Application.getBean(FieldLanguageDao.class);

    languages = new DropDownChoice<FieldLanguage>("language",
            new PropertyModel<FieldLanguage>(langPanel, "language"), langDao.getLanguages(),
            new ChoiceRenderer<FieldLanguage>("name", "language_id"));

    languages.add(new AjaxFormComponentUpdatingBehavior("onchange") {
        private static final long serialVersionUID = -2055912815073387536L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(listContainer);
        }
    });
    add(languages);

    add(new WebMarkupContainer("deleteLangBtn").add(new AjaxEventBehavior("onclick") {
        private static final long serialVersionUID = -1650946343073068686L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new ConfirmCallListener(833L));
        }

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            langPanel.language.setDeleted(true);
            FieldLanguageDao langDao = Application.getBean(FieldLanguageDao.class);
            try {
                langDao.updateLanguage(langPanel.language);
            } catch (Exception e) {
                // TODO add feedback message
                e.printStackTrace();
            }
            languages.setChoices(langDao.getLanguages());
            target.add(languages);
            // FIXME need to force update list container
            target.add(listContainer);
        }
    }));

    // attach an ajax validation behavior to all form component's keydown
    // event and throttle it down to once per second
    AjaxFormValidatingBehavior.addToAllFormComponents(this, "keydown", Duration.ONE_SECOND);
}