List of usage examples for org.apache.wicket.ajax.form AjaxFormValidatingBehavior AjaxFormValidatingBehavior
public AjaxFormValidatingBehavior(String event, Duration throttleDelay)
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.annotation.component.AnnotationDetailEditorPanel.java
License:Apache License
public AnnotationDetailEditorPanel(String id, IModel<BratAnnotatorModel> aModel) { super(id, aModel); bModel = aModel.getObject();// ww w .j a va 2 s . com annotationFeatureForm = new AnnotationFeatureForm("annotationFeatureForm", aModel.getObject()) { private static final long serialVersionUID = 8081614428845920047L; @Override protected void onConfigure() { super.onConfigure(); // Avoid reversing in read-only layers setEnabled(bModel.getDocument() != null && !isAnnotationFinished()); } }; annotationFeatureForm.setOutputMarkupId(true); annotationFeatureForm.add(new AjaxFormValidatingBehavior(annotationFeatureForm, "onsubmit") { private static final long serialVersionUID = -5642108496844056023L; @Override protected void onSubmit(AjaxRequestTarget aTarget) { try { actionAnnotate(aTarget, bModel, false); } catch (UIMAException | ClassNotFoundException | IOException | BratAnnotationException e) { error(e.getMessage()); } } }); add(annotationFeatureForm); }
From source file:org.apache.openmeetings.web.admin.configurations.ConfigForm.java
License:Apache License
public ConfigForm(String id, WebMarkupContainer listContainer, Configuration configuration) { super(id, new CompoundPropertyModel<Configuration>(configuration)); setOutputMarkupId(true);// ww w.jav a2 s . c o m this.listContainer = listContainer; add(new RequiredTextField<String>("key").setLabel(Model.of(Application.getString(267))) .add(new IValidator<String>() { private static final long serialVersionUID = 1L; @Override public void validate(IValidatable<String> validatable) { Configuration c = getBean(ConfigurationDao.class).forceGet(validatable.getValue()); if (c != null && !c.isDeleted() && !c.getId().equals(ConfigForm.this.getModelObject().getId())) { validatable.error(new ValidationError(Application.getString(1544L))); } } })); add(new TextField<String>("value").setLabel(Model.of(Application.getString(271)))); add(forDatePattern("updated", WEB_DATE_PATTERN)); add(new Label("user.login")); add(new TextArea<String>("comment")); // 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)); }
From source file:org.apache.openmeetings.web.admin.groups.GroupForm.java
License:Apache License
public GroupForm(String id, WebMarkupContainer groupList, Group group) { super(id, new CompoundPropertyModel<Group>(group)); this.groupList = groupList; setOutputMarkupId(true);/* w w w .ja v a2 s . c o m*/ add(new RequiredTextField<String>("name").setLabel(Model.of(Application.getString(165)))); usersPanel = new GroupUsersPanel("users", getGroupId()); add(usersPanel); add(userToadd = new Select2Choice<User>("user2add", Model.of((User) null), new AdminUserChoiceProvider() { private static final long serialVersionUID = 1L; @Override public String getDisplayValue(User choice) { return formatUser(choice); } })); userToadd.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { Group o = GroupForm.this.getModelObject(); User u = userToadd.getModelObject(); boolean found = false; if (o.getId() != null) { found = null != getBean(GroupUserDao.class).getByGroupAndUser(o.getId(), u.getId()); } if (!found && u != null) { for (GroupUser ou : usersPanel.getUsers2add()) { if (ou.getUser().getId().equals(u.getId())) { found = true; break; } } if (!found) { GroupUser ou = new GroupUser(o, u); usersPanel.getUsers2add().add(ou); userToadd.setModelObject(null); target.add(usersPanel, userToadd); } } } }); // 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)); }
From source file:org.apache.openmeetings.web.admin.labels.LangForm.java
License:Apache License
/** * Render Main//from w ww . j a v a 2 s . c o m * * @param id * @param listContainer * @param language * @param langPanel */ public LangForm(String id, final WebMarkupContainer listContainer, final LangPanel langPanel) { super(id); setOutputMarkupId(true); languages = new DropDownChoice<Map.Entry<Long, Locale>>("language", new PropertyModel<Map.Entry<Long, Locale>>(langPanel, "language"), getLanguages(), new ChoiceRenderer<Map.Entry<Long, Locale>>() { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(Map.Entry<Long, Locale> object) { return object.getValue().getDisplayName(); } @Override public String getIdValue(Map.Entry<Long, Locale> object, int index) { return "" + object.getKey(); } }); languages.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(listContainer); } }); add(languages); // 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)); }
From source file:org.apache.openmeetings.web.admin.ldaps.LdapForm.java
License:Apache License
public LdapForm(String id, WebMarkupContainer listContainer, final LdapConfig ldapConfig) { super(id, new CompoundPropertyModel<LdapConfig>(ldapConfig)); setOutputMarkupId(true);/*w ww . j a v a2s . co m*/ this.listContainer = listContainer; add(new RequiredTextField<String>("name").setLabel(Model.of(Application.getString(1108)))); add(new CheckBox("active")); add(forDatePattern("inserted", WEB_DATE_PATTERN)); add(new Label("insertedby.login")); add(forDatePattern("updated", WEB_DATE_PATTERN)); add(new Label("updatedby.login")); add(new RequiredTextField<String>("configFileName").setLabel(Model.of(Application.getString(1115)))); add(new CheckBox("addDomainToUserName")); add(new TextField<String>("domain")); add(new TextArea<String>("comment")); // 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)); }
From source file:org.apache.openmeetings.web.admin.oauth.OAuthForm.java
License:Apache License
public OAuthForm(String id, WebMarkupContainer listContainer, OAuthServer server) { super(id, new CompoundPropertyModel<OAuthServer>(server)); this.listContainer = listContainer; setOutputMarkupId(true);//from ww w . j a va 2 s .c om add(new CheckBox("isEnabled")); add(new RequiredTextField<String>("name").setLabel(Model.of(Application.getString(1573)))); add(new TextField<String>("iconUrl").setLabel(Model.of(Application.getString(1575)))); add(new RequiredTextField<String>("clientId").setLabel(Model.of(Application.getString(1576)))); add(new RequiredTextField<String>("clientSecret").setLabel(Model.of(Application.getString(1577)))); add(redirectUriText = (TextField<String>) new TextField<String>("redirectUri", Model.of("")) .setLabel(Model.of(Application.getString(1587)))); add(new RequiredTextField<String>("requestKeyUrl").setLabel(Model.of(Application.getString(1578)))); add(new RequiredTextField<String>("requestTokenUrl").setLabel(Model.of(Application.getString(1579)))); add(new RequiredTextField<String>("requestTokenAttributes") .setLabel(Model.of(Application.getString(1586)))); add(new RequiredTextField<String>("requestInfoUrl").setLabel(Model.of(Application.getString(1580)))); add(new DropDownChoice<RequestMethod>("requestTokenMethod", Arrays.asList(RequestMethod.values()), new ChoiceRenderer<RequestMethod>("name", "name"))); add(new RequiredTextField<String>("loginParamName").setLabel(Model.of(Application.getString(1582)))); add(new RequiredTextField<String>("emailParamName").setLabel(Model.of(Application.getString(1583)))); add(new TextField<String>("firstnameParamName").setLabel(Model.of(Application.getString(1584)))); add(new TextField<String>("lastnameParamName").setLabel(Model.of(Application.getString(1585)))); // 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)); }
From source file:org.apache.openmeetings.web.admin.rooms.RoomForm.java
License:Apache License
public RoomForm(String id, WebMarkupContainer roomList, final Room room) { super(id, new CompoundPropertyModel<Room>(room)); this.roomList = roomList; setOutputMarkupId(true);/*from w ww . j a v a2 s . c om*/ RequiredTextField<String> name = new RequiredTextField<String>("name"); name.setLabel(new Model<String>(Application.getString(193))); add(name); add(new DropDownChoice<Long>("numberOfPartizipants", // DROPDOWN_NUMBER_OF_PARTICIPANTS, // new ChoiceRenderer<Long>() { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(Long id) { return id; } @Override public String getIdValue(Long id, int index) { return "" + id; } })); add(new RoomTypeDropDown("type").setRequired(true).setLabel(Model.of(Application.getString(194)))); add(new TextArea<String>("comment")); add(new CheckBox("appointment").setEnabled(false)); add(new CheckBox("ispublic")); List<Group> orgList = Application.getBean(GroupDao.class).get(0, Integer.MAX_VALUE); final List<RoomGroup> orgRooms = new ArrayList<RoomGroup>(orgList.size()); for (Group org : orgList) { orgRooms.add(new RoomGroup(org, getModelObject())); } add(new Select2MultiChoice<RoomGroup>("roomGroups", null, new ChoiceProvider<RoomGroup>() { private static final long serialVersionUID = 1L; @Override public String getDisplayValue(RoomGroup choice) { String name = choice.getGroup().getName(); return name == null ? "" : name; } @Override public String getIdValue(RoomGroup choice) { Long id = choice.getGroup().getId(); return id == null ? null : "" + id; } @Override public void query(String term, int page, Response<RoomGroup> response) { for (RoomGroup or : orgRooms) { if (Strings.isEmpty(term) || or.getGroup().getName().contains(term)) { response.add(or); } } } @Override public Collection<RoomGroup> toChoices(Collection<String> _ids) { List<Long> ids = new ArrayList<Long>(); for (String id : _ids) { ids.add(Long.valueOf(id)); } List<RoomGroup> list = new ArrayList<RoomGroup>(); for (Group o : getBean(GroupDao.class).get(ids)) { list.add(new RoomGroup(o, RoomForm.this.getModelObject())); } return list; } })); add(new CheckBox("isDemoRoom")); TextField<Integer> demoTime = new TextField<Integer>("demoTime"); demoTime.setLabel(new Model<String>(Application.getString(637))); add(demoTime); add(new CheckBox("allowUserQuestions")); add(new CheckBox("audioOnly")); add(new CheckBox("allowFontStyles")); add(new CheckBox("closed")); add(new TextField<String>("redirectURL")); add(new CheckBox("waitForRecording")); add(new CheckBox("allowRecording")); add(new CheckBox("hideTopBar")); add(new CheckBox("chatHidden")); add(new CheckBox("activitiesHidden")); add(new CheckBox("hideFilesExplorer")); add(new CheckBox("hideActionsMenu")); add(new CheckBox("hideScreenSharing")); add(new CheckBox("hideWhiteboard")); add(new CheckBox("showMicrophoneStatus")); add(new CheckBox("chatModerated")); add(new CheckBox("chatOpened")); add(new CheckBox("filesOpened")); add(new CheckBox("autoVideoSelect")); // Users in this Room clients = new ListView<Client>("clients", clientsInRoom) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<Client> item) { Client client = item.getModelObject(); item.add(new Label("clientId", "" + client.getId())) .add(new Label("clientLogin", "" + client.getUsername())) .add(new ConfirmableAjaxBorder("clientDelete", getString("80"), getString("833")) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { Client c = item.getModelObject(); getBean(IUserService.class).kickUserByStreamId(getSid(), c.getStreamid(), c.getServer() == null ? 0 : c.getServer().getId()); updateClients(target); } }); } }; add(clientsContainer.add(clients.setOutputMarkupId(true)).setOutputMarkupId(true)); // Moderators final Select2Choice<User> moderatorChoice = new Select2Choice<User>("moderator2add", moderator2add, new AdminUserChoiceProvider() { private static final long serialVersionUID = 1L; @Override public void query(String term, int page, Response<User> response) { response.addAll(getBean(UserDao.class).get(term, false, page * PAGE_SIZE, PAGE_SIZE)); response.setHasMore(PAGE_SIZE == response.getResults().size()); } @Override public String getDisplayValue(User choice) { Address a = choice.getAddress(); return String.format("\"%s %s\" <%s>", choice.getFirstname(), choice.getLastname(), a == null ? "" : a.getEmail()); } }); add(moderatorChoice.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { Room r = RoomForm.this.getModelObject(); User u = moderator2add.getObject(); boolean found = false; if (u != null) { if (r.getModerators() == null) { r.setModerators(new ArrayList<RoomModerator>()); } for (RoomModerator rm : r.getModerators()) { if (rm.getUser().getId().equals(u.getId())) { found = true; break; } } if (!found) { RoomModerator rm = new RoomModerator(); rm.setRoomId(r.getId()); rm.setUser(u); r.getModerators().add(0, rm); moderator2add.setObject(null); target.add(moderatorContainer, moderatorChoice); } } } }).setOutputMarkupId(true)); add(moderatorContainer.add(new ListView<RoomModerator>("moderators") { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<RoomModerator> item) { RoomModerator moderator = item.getModelObject(); Label name = new Label("uName", moderator.getUser().getFirstname() + " " + moderator.getUser().getLastname()); if (moderator.getId() == null) { name.add(AttributeAppender.append("class", "newItem")); } item.add(new CheckBox("superModerator", new PropertyModel<Boolean>(moderator, "superModerator"))) .add(new Label("userId", "" + moderator.getUser().getId())).add(name) .add(new Label("email", moderator.getUser().getAddress().getEmail())) .add(new ConfirmableAjaxBorder("delete", getString("80"), getString("833")) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { RoomForm.this.getModelObject().getModerators().remove(item.getIndex()); target.add(moderatorContainer); } }); } }).setOutputMarkupId(true)); add(new CheckBox("moderated")); add(new TextField<String>("confno").setEnabled(false)); add(pin = new TextField<String>("pin")); pin.setEnabled(room.isSipEnabled()); add(new TextField<String>("ownerId").setEnabled(false)); add(new AjaxCheckBox("sipEnabled") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { updateView(target); } }.setOutputMarkupId(true)); // 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)); }
From source file:org.apache.openmeetings.web.admin.servers.ServerForm.java
License:Apache License
public ServerForm(String id, WebMarkupContainer listContainer, final Server server) { super(id, new CompoundPropertyModel<Server>(server)); setOutputMarkupId(true);// www. j ava 2s .c om this.listContainer = listContainer; add(new RequiredTextField<String>("name").setLabel(Model.of(Application.getString(1500)))); add(new CheckBox("active")); add(new RequiredTextField<String>("address").setLabel(Model.of(Application.getString(1501)))); add(new TextField<Integer>("port")); add(new TextField<String>("user")); add(new TextField<String>("pass")); add(new TextField<String>("webapp")); add(new TextField<String>("protocol")); add(forDatePattern("lastPing", WEB_DATE_PATTERN)); //add(new Label("pingRunning")); add(forDatePattern("inserted", WEB_DATE_PATTERN)); add(new Label("insertedby.login")); add(forDatePattern("updated", WEB_DATE_PATTERN)); add(new Label("updatedby.login")); add(new TextArea<String>("comment")); // 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)); }
From source file:org.apache.openmeetings.web.admin.users.UserForm.java
License:Apache License
public UserForm(String id, WebMarkupContainer listContainer, final User user, MessageDialog warning) { super(id, new CompoundPropertyModel<User>(user)); setOutputMarkupId(true);/*from www . j a va 2s . co m*/ this.listContainer = listContainer; this.warning = warning; // Add form fields addFormFields(); // 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)); }
From source file:org.apache.openmeetings.web.user.profile.EditProfileForm.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); add(passwd.setLabel(new ResourceModel("current.password")).setRequired(true).setVisible(checkPassword)); add(actions = new FormActionsPanel<User>("buttons", this) { private static final long serialVersionUID = 1L; private void refreshUser() { User u = getModelObject();/*from w w w. ja v a 2 s . c om*/ 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(EditProfileForm.this); } @Override protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) { refreshUser(); target.add(EditProfileForm.this); } @Override protected void onPurgeSubmit(AjaxRequestTarget target, Form<?> form) { userDao.purge(getModelObject(), getUserId()); WebSession.get().invalidateNow(); setResponsePage(Application.get().getSignInPageClass()); } }); 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); } }).setVisible(checkPassword)); 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)); add(new BookmarkablePageLink<>("link", PrivacyPage.class)); }