Search in sources :

Example 1 with ComunityUserForm

use of org.apache.openmeetings.web.common.ComunityUserForm in project openmeetings by apache.

the class UserForm method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    add(password.setResetPassword(false).setLabel(Model.of(getString("110"))).setRequired(false).add(passValidator = new StrongPasswordValidator(getMinPasswdLength(cfgDao), getModelObject())));
    login.setLabel(Model.of(getString("108")));
    add(login.add(minimumLength(getMinLoginLength(cfgDao))));
    add(new DropDownChoice<>("type", Arrays.asList(Type.values())).add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            updateDomain(target);
        }
    }));
    update(null);
    add(domain.add(domainId).setOutputMarkupId(true).setOutputMarkupPlaceholderTag(true));
    add(new Label("ownerId"));
    add(new DateLabel("inserted"));
    add(new DateLabel("updated"));
    add(new CheckBox("forceTimeZoneCheck"));
    add(new Select2MultiChoice<>("rights", null, new RestrictiveChoiceProvider<Right>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getDisplayValue(Right choice) {
            return choice.name();
        }

        @Override
        public String toId(Right choice) {
            return choice.name();
        }

        @Override
        public void query(String term, int page, Response<Right> response) {
            boolean isGroupAdmin = hasGroupAdminLevel(getRights());
            for (Right r : Right.values()) {
                if (Right.GroupAdmin == r) {
                    continue;
                }
                if (isGroupAdmin && (Right.Admin == r || Right.Soap == r)) {
                    continue;
                }
                if (Strings.isEmpty(term) || r.name().contains(term)) {
                    response.add(r);
                }
            }
        }

        @Override
        public Right fromId(String id) {
            return Right.valueOf(id);
        }
    }));
    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));
    add(adminPass);
}
Also used : RestrictiveChoiceProvider(org.apache.openmeetings.web.util.RestrictiveChoiceProvider) Label(org.apache.wicket.markup.html.basic.Label) DateLabel(org.apache.openmeetings.web.util.DateLabel) Right(org.apache.openmeetings.db.entity.user.User.Right) AjaxFormValidatingBehavior(org.apache.wicket.ajax.form.AjaxFormValidatingBehavior) StrongPasswordValidator(org.apache.openmeetings.core.util.StrongPasswordValidator) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) DateLabel(org.apache.openmeetings.web.util.DateLabel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Response(org.wicketstuff.select2.Response) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) ComunityUserForm(org.apache.openmeetings.web.common.ComunityUserForm)

Example 2 with ComunityUserForm

use of org.apache.openmeetings.web.common.ComunityUserForm 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

ComunityUserForm (org.apache.openmeetings.web.common.ComunityUserForm)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AjaxFormValidatingBehavior (org.apache.wicket.ajax.form.AjaxFormValidatingBehavior)2 ButtonBehavior (com.googlecode.wicket.jquery.ui.form.button.ButtonBehavior)1 StrongPasswordValidator (org.apache.openmeetings.core.util.StrongPasswordValidator)1 User (org.apache.openmeetings.db.entity.user.User)1 Right (org.apache.openmeetings.db.entity.user.User.Right)1 UploadableProfileImagePanel (org.apache.openmeetings.web.common.UploadableProfileImagePanel)1 DateLabel (org.apache.openmeetings.web.util.DateLabel)1 RestrictiveChoiceProvider (org.apache.openmeetings.web.util.RestrictiveChoiceProvider)1 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)1 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)1 Response (org.wicketstuff.select2.Response)1