Search in sources :

Example 1 with ButtonBehavior

use of com.googlecode.wicket.jquery.ui.form.button.ButtonBehavior in project openmeetings by apache.

the class ProfileForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(passwd.setLabel(Model.of(getString("current.password"))).setRequired(true));
    add(new FormSaveRefreshPanel<User>("buttons", this) {

        private static final long serialVersionUID = 1L;

        private void refreshUser() {
            User u = getModelObject();
            if (u.getId() != null) {
                u = userDao.get(u.getId());
            } else {
                u = new User();
            }
            setModelObject(u);
        }

        @Override
        protected void onSaveSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                userDao.update(getModelObject(), null, getUserId());
            } catch (Exception e) {
                error(e.getMessage());
            }
            refreshUser();
            target.add(ProfileForm.this);
        }

        @Override
        protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) {
            refreshUser();
            target.add(ProfileForm.this);
        }
    });
    add(new WebMarkupContainer("changePwd").add(new ButtonBehavior("#changePwd"), new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            chPwdDlg.open(target);
        }
    }));
    add(userForm);
    add(new UploadableProfileImagePanel("img", getUserId()));
    add(new ComunityUserForm("comunity", getModel()));
    // attach an ajax validation behavior to all form component's keydown
    // event and throttle it down to once per second
    add(new AjaxFormValidatingBehavior("keydown", Duration.ONE_SECOND));
}
Also used : User(org.apache.openmeetings.db.entity.user.User) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) UploadableProfileImagePanel(org.apache.openmeetings.web.common.UploadableProfileImagePanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComunityUserForm(org.apache.openmeetings.web.common.ComunityUserForm) ButtonBehavior(com.googlecode.wicket.jquery.ui.form.button.ButtonBehavior)

Aggregations

ButtonBehavior (com.googlecode.wicket.jquery.ui.form.button.ButtonBehavior)1 User (org.apache.openmeetings.db.entity.user.User)1 ComunityUserForm (org.apache.openmeetings.web.common.ComunityUserForm)1 UploadableProfileImagePanel (org.apache.openmeetings.web.common.UploadableProfileImagePanel)1 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 AjaxFormValidatingBehavior (org.apache.wicket.ajax.form.AjaxFormValidatingBehavior)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1