org.apache.wicket.ajax.markup.html.form.AjaxButton Java Examples
The following examples show how to use
org.apache.wicket.ajax.markup.html.form.AjaxButton.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginForm.java From JPPF with Apache License 2.0 | 6 votes |
/** * . */ public LoginForm() { super(PREFIX + ".form"); add(username = new TextField<>(PREFIX + ".username.field", Model.of(""))); add(password = new PasswordTextField(PREFIX + ".password.field", Model.of(""))); password.setRequired(false); add(error = new Label(PREFIX + ".error", Model.of("")) { @Override protected void onComponentTag(final ComponentTag tag) { if (hasError) tag.append("style", "margin-top: 15px", ";"); } }); final AjaxButton button = new AjaxButton(PREFIX + ".ok") { @Override protected void onSubmit(final AjaxRequestTarget target) { if (debugEnabled) log.debug("clicked on login.ok"); doOK(target); } }; add(button); setDefaultButton(button); }
Example #2
Source File: AbstractUploadFilePanel.java From Orienteer with Apache License 2.0 | 6 votes |
public AbstractUploadFilePanel(String id, final ModalWindow modal,final AbstractModalWindowCommand<?> command) { super(id); modal.setMinimalHeight(300); modal.showUnloadConfirmation(false); Form<?> uploadForm = new Form<Object>("uploadForm"); final FileUploadField inputFile = new FileUploadField("inputFile"); uploadForm.add(inputFile); uploadForm.add(new AjaxButton("loadFile",getLoadButtonTitle(),uploadForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { FileUpload file = inputFile.getFileUpload(); if (file!=null){ onLoadFile(file); command.onAfterModalSubmit(); modal.close(target); } } }); add(uploadForm); }
Example #3
Source File: BeanListPropertyEditor.java From onedev with MIT License | 5 votes |
private WebMarkupContainer addRow(Serializable element) { WebMarkupContainer row = new WebMarkupContainer(rows.newChildId()); row.setOutputMarkupId(true); rows.add(row); RepeatingView columns = new RepeatingView("properties"); row.add(columns); for (PropertyContext<Serializable> propertyContext: propertyContexts) { WebMarkupContainer column = new WebMarkupContainer(columns.newChildId()); column.add(AttributeAppender.append("class", "property-" + propertyContext.getPropertyName())); columns.add(column); Serializable propertyValue = (Serializable) propertyContext.getPropertyValue(element); PropertyEditor<?> propertyEditor = propertyContext.renderForEdit("propertyEditor", Model.of(propertyValue)); column.add(propertyEditor); column.add(new FencedFeedbackPanel("feedback", propertyEditor)); } row.add(new AjaxButton("deleteElement") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { super.onSubmit(target, form); markFormDirty(target); target.appendJavaScript($(row).chain("remove").get()); rows.remove(row); target.add(noElements); onPropertyUpdating(target); } }.setDefaultFormProcessing(false)); return row; }
Example #4
Source File: RegisterDialog.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); add(feedback.setOutputMarkupId(true)); add(firstNameField = new RequiredTextField<>("firstName", new PropertyModel<String>(RegisterDialog.this, "firstName"))); add(lastNameField = new RequiredTextField<>("lastName", new PropertyModel<String>(RegisterDialog.this, "lastName"))); add(loginField = new RequiredTextField<>("login", new PropertyModel<String>(RegisterDialog.this, "login"))); add(passwordField = new PasswordTextField("password", new PropertyModel<String>(RegisterDialog.this, "password"))); add(confirmPassword = new PasswordTextField("confirmPassword", new Model<String>()).setResetPassword(true)); add(emailField = new RequiredTextField<>("email", new PropertyModel<String>(RegisterDialog.this, "email")) { private static final long serialVersionUID = 1L; @Override protected String[] getInputTypes() { return new String[] {"email"}; } }); add(captcha = new Captcha("captcha")); firstNameField.setLabel(new ResourceModel("117")); lastNameField.setLabel(new ResourceModel("136")); loginField.add(minimumLength(getMinLoginLength())).setLabel(new ResourceModel("114")); passwordField.setResetPassword(true).add(new StrongPasswordValidator(new User()) { private static final long serialVersionUID = 1L; @Override public void validate(IValidatable<String> pass) { User u = new User(); u.setLogin(loginField.getRawInput()); u.setAddress(new Address()); u.getAddress().setEmail(emailField.getRawInput()); setUser(u); super.validate(pass); } }).setLabel(new ResourceModel("110")); confirmPassword.setLabel(new ResourceModel("116")); emailField.add(RfcCompliantEmailAddressValidator.getInstance()).setLabel(new ResourceModel("119")); AjaxButton ab = new AjaxButton("submit") { // FAKE button so "submit-on-enter" works as expected private static final long serialVersionUID = 1L; }; add(ab); setDefaultButton(ab); }
Example #5
Source File: CaptchaPanel.java From syncope with Apache License 2.0 | 5 votes |
public CaptchaPanel(final String id) { super(id); captchaImageResource = new CaptchaImageResource() { private static final long serialVersionUID = 2436829189992948005L; @Override protected byte[] render() { randomText = RANDOM_LETTERS.generate(6); getChallengeIdModel().setObject(randomText); return super.render(); } }; Image captchaImage = new Image("image", captchaImageResource); captchaImage.setOutputMarkupId(true); add(captchaImage); add(new AjaxButton("reloadButton") { private static final long serialVersionUID = -957948639666058749L; @Override protected void onSubmit(final AjaxRequestTarget target) { captchaImageResource.invalidate(); target.add(captchaImage); } }.setDefaultFormProcessing(false)); add(new AjaxTextFieldPanel("captcha", "captcha", captchaText). hideLabel(). setOutputMarkupId(true). setOutputMarkupPlaceholderTag(true)); }
Example #6
Source File: SchemasPanel.java From syncope with Apache License 2.0 | 5 votes |
public SchemasPanel(final String id, final PageReference pageRef) { super(id); this.pageRef = pageRef; Model<String> keywordModel = new Model<>(StringUtils.EMPTY); WebMarkupContainer searchBoxContainer = new WebMarkupContainer("searchBox"); add(searchBoxContainer); Form<?> form = new Form<>("form"); searchBoxContainer.add(form); AjaxTextFieldPanel filter = new AjaxTextFieldPanel("filter", "filter", keywordModel, true); form.add(filter.hideLabel().setOutputMarkupId(true).setRenderBodyOnly(true)); AjaxButton search = new AjaxButton("search") { private static final long serialVersionUID = 8390605330558248736L; @Override protected void onSubmit(final AjaxRequestTarget target) { send(SchemasPanel.this, Broadcast.DEPTH, new SchemaTypePanel.SchemaSearchEvent(target, keywordModel.getObject())); } }; search.setOutputMarkupId(true); form.add(search); form.setDefaultButton(search); Accordion accordion = new Accordion("accordionPanel", buildTabList()); accordion.setOutputMarkupId(true); add(accordion); }
Example #7
Source File: ActionDataTablePanel.java From syncope with Apache License 2.0 | 5 votes |
public void addCancelButton(final BaseModal<?> modal) { AjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -4804368561204623354L; @Override protected void onSubmit(final AjaxRequestTarget target) { modal.close(target); } }; cancel.setDefaultFormProcessing(false); batchForm.addOrReplace(cancel); }
Example #8
Source File: OrienteerBasePage.java From Orienteer with Apache License 2.0 | 5 votes |
private Form<String> createSearchForm(String id, IModel<String> queryModel) { return new Form<String>(id, queryModel) { @Override protected void onInitialize() { super.onInitialize(); add(new TextField<>("query", queryModel, String.class)); add(new AjaxButton("search") {}); } @Override protected void onConfigure() { super.onConfigure(); OSecurityUser user = OrienteerWebSession.get().getUser(); if (user != null) { OSecurityRole allowedRole = user.checkIfAllowed(OSecurityHelper.FEATURE_RESOURCE, SearchPage.SEARCH_FEATURE, OrientPermission.READ.getPermissionFlag()); setVisible(allowedRole != null); } else { setVisible(false); } } @Override protected void onSubmit() { setResponsePage(new SearchPage(queryModel)); } }; }
Example #9
Source File: OClassSearchPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private AjaxButton createSearchButton(String id) { return new AjaxButton(id) { @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); target.add(resultsContainer); } }; }
Example #10
Source File: AddTabDialog.java From Orienteer with Apache License 2.0 | 5 votes |
public AddTabDialog(String id) { super(id); Form<T> form = new Form<T>("addTabForm"); form.add(tabName = new TextField<String>("tabName", Model.of(""))); form.add(new AjaxButton("addTab") { @Override protected void onSubmit(AjaxRequestTarget target) { onCreateTab(tabName.getModelObject(), Optional.of(target)); tabName.setModelObject(""); } }); add(form); }
Example #11
Source File: CurationSidebar.java From inception with Apache License 2.0 | 4 votes |
private Form<Void> createSettingsForm(String aId) { Form<Void> settingsForm = new Form<Void>(aId); LambdaAjaxButton<Void> applyBtn = new LambdaAjaxButton<>("apply", this::updateForNewCurator); settingsForm.add(applyBtn); // set up curation target selection as radio button List<String> curationTargets = Arrays.asList( new String[] { CURATION_USER, userRepository.getCurrentUser().getUsername() }); ChoiceRenderer<String> choiceRenderer = new ChoiceRenderer<String>() { private static final long serialVersionUID = -8165699251116827372L; @Override public Object getDisplayValue(String aUsername) { if (aUsername.equals(CURATION_USER)) { return " curation document"; } else { return " my document"; } } }; curationTargetChoice = new BootstrapRadioChoice<String>("curationTargetRadioBtn", Model.of(curationService.retrieveCurationTarget( userRepository.getCurrentUser().getUsername(), getModelObject().getProject().getId())), curationTargets, choiceRenderer) { private static final long serialVersionUID = 1513847274470368949L; @Override protected IValueMap getAdditionalAttributesForLabel(int aIndex, String aChoice) { // use normal font for choices IValueMap attrValMap = super.getAdditionalAttributesForLabel(aIndex, aChoice); if (attrValMap == null) { attrValMap = new AttributeMap(); } attrValMap.put("style", "font-weight:normal"); return attrValMap; } }; settingsForm.add(curationTargetChoice); // toggle visibility of settings form usersForm.add(new AjaxButton("toggleOptionsVisibility") { private static final long serialVersionUID = -5535838955781542216L; @Override protected void onSubmit(AjaxRequestTarget aTarget) { settingsForm.setVisible(!settingsForm.isVisible()); aTarget.add(mainContainer); } }); return settingsForm; }
Example #12
Source File: AdministratePage.java From sakai with Educational Community License v2.0 | 4 votes |
public AdministratePage(){ disableLink(administrateLink); //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //Add Delegated Access to My Workspaces: final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() { @Override public String getObject() { String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus(); if(lastRanInfoStr == null){ lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject(); }else{ try{ long lastRanInfoInt = Long.parseLong(lastRanInfoStr); if(lastRanInfoInt == -1){ return new ResourceModel("addDaMyworkspace.job.status.failed").getObject(); }else if(lastRanInfoInt == 0){ return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject(); }else{ Date successDate = new Date(lastRanInfoInt); return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate); } }catch (Exception e) { return new ResourceModel("na").getObject(); } } return lastRanInfoStr; } }); addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true); final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId(); add(addDaMyworkspaceStatusLabel); Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm"); AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)){ @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { projectLogic.scheduleAddDAMyworkspaceJobStatus(); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.add(formFeedback); target.appendJavaScript("hideFeedbackTimer('" + formFeedbackId + "');"); target.add(addDaMyworkspaceStatusLabel,addDaMyworkspaceStatusLabelId); } }; addDaMyworkspaceForm.add(addDaMyworkspaceButton); add(addDaMyworkspaceForm); }
Example #13
Source File: AdministratePage.java From sakai with Educational Community License v2.0 | 4 votes |
public AdministratePage(){ disableLink(administrateLink); //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //Add Delegated Access to My Workspaces: final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() { @Override public String getObject() { String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus(); if(lastRanInfoStr == null){ lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject(); }else{ try{ long lastRanInfoInt = Long.parseLong(lastRanInfoStr); if(lastRanInfoInt == -1){ return new ResourceModel("addDaMyworkspace.job.status.failed").getObject(); }else if(lastRanInfoInt == 0){ return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject(); }else{ Date successDate = new Date(lastRanInfoInt); return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate); } }catch (Exception e) { return new ResourceModel("na").getObject(); } } return lastRanInfoStr; } }); addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true); final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId(); add(addDaMyworkspaceStatusLabel); Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm"); AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)){ @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { projectLogic.scheduleAddDAMyworkspaceJobStatus(); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.add(formFeedback); target.appendJavaScript("hideFeedbackTimer('" + formFeedbackId + "');"); target.add(addDaMyworkspaceStatusLabel,addDaMyworkspaceStatusLabelId); } }; addDaMyworkspaceForm.add(addDaMyworkspaceButton); add(addDaMyworkspaceForm); }