List of usage examples for org.apache.wicket.ajax.form OnChangeAjaxBehavior OnChangeAjaxBehavior
public OnChangeAjaxBehavior()
From source file:com.inductiveautomation.xopc.drivers.modbus2.configuration.web.ModbusConfigurationUI.java
License:Open Source License
private CheckBox newStepCheckboxField(final ModbusConfigurationEntry configEntry) { final CheckBox checkboxField = new CheckBox("step", new PropertyModel<Boolean>(configEntry, "designatorRange.step")); checkboxField.add(new OnChangeAjaxBehavior() { @Override// w w w .j a v a 2 s.c o m protected void onUpdate(AjaxRequestTarget target) { configEntry.getDesignatorRange().setStep(checkboxField.getModelObject()); } }); return checkboxField; }
From source file:com.inductiveautomation.xopc.drivers.modbus2.configuration.web.ModbusConfigurationUI.java
License:Open Source License
private TextField<String> newModbusUnitIDTextField(final ModbusConfigurationEntry configEntry) { final RequiredTextField<String> textField = new RequiredTextField<String>("unitid", new PropertyModel<String>(configEntry, "modbusRange.unitID")); textField.add(new ModbusUnitIDValidator()); textField.add(new OnChangeAjaxBehavior() { @Override//from w w w. j a va 2s. co m protected void onUpdate(AjaxRequestTarget target) { configEntry.modbusRange.setUnitID(textField.getModelObject()); } }); return textField; }
From source file:com.inductiveautomation.xopc.drivers.modbus2.configuration.web.ModbusConfigurationUI.java
License:Open Source License
private TextField<String> newModbusAddressTextField(final ModbusConfigurationEntry configEntry) { final RequiredTextField<String> textField = new RequiredTextField<String>("address", new PropertyModel<String>(configEntry, "modbusRange.start")); textField.add(new ModbusAddressValidator()); textField.add(new OnChangeAjaxBehavior() { @Override/* w ww .jav a 2 s.c om*/ protected void onUpdate(AjaxRequestTarget target) { configEntry.modbusRange.setStart(textField.getModelObject()); } }); return textField; }
From source file:com.inductiveautomation.xopc.drivers.modbus2.configuration.web.ModbusConfigurationUI.java
License:Open Source License
private DropDownChoice<AddressType> newModbusAddressTypeDropdown(final ModbusConfigurationEntry configEntry) { final DropDownChoice<AddressType> dropDown = new DropDownChoice<AddressType>("type", new PropertyModel<AddressType>(configEntry, "modbusRange.modbusAddressType"), modbusTypes, new ModbusAddressTypeChoiceRenderer()); dropDown.setRequired(true);/*from w w w . j av a 2s. co m*/ dropDown.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { configEntry.getModbusRange().setModbusAddressType(dropDown.getModelObject()); } }); return dropDown; }
From source file:com.modusoperandi.dragonfly.widgets.fileQuery.FileQueryWidgetPage.java
License:Open Source License
/** * Instantiates a new file query widget page. *//*from ww w. j a v a2 s.co m*/ public FileQueryWidgetPage() { final Form<?> queryForm = new Form<>("queryForm"); // //////////////////////////// // File // Populate the drop down list with the files on the server getFileList(fileList, Arrays.asList(".csv"), null); selectFile = new DropDownChoice<>("fileName", new PropertyModel<String>(this, "fileName"), fileList); // Enable the transform whenever the user selects one selectFile.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { getFileList(fileList, Arrays.asList(".csv"), null); target.add(selectFile); status = "Update pending"; target.add(statusField); } }); queryForm.add(selectFile); // //////////////////////////// // Mapping File // Populate the drop down list with the files on the server getFileList(mappingFileList, Arrays.asList(".mapping"), null); selectMappingFile = new DropDownChoice<>("mappingFileName", new PropertyModel<String>(this, "mappingFileName"), mappingFileList); // Enable the transform whenever the user selects one selectMappingFile.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { getFileList(mappingFileList, Arrays.asList(".mapping"), null); target.add(selectMappingFile); status = "Update pending"; target.add(statusField); } }); queryForm.add(selectMappingFile); // //////////////////////////// // File Type final DropDownChoice<?> selectType = new DropDownChoice<>("fileType", new PropertyModel<String>(this, "fileType"), Arrays.asList("CSV")); // Enable the transform whenever the user selects one selectType.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { status = "Update pending"; target.add(statusField); } }); queryForm.add(selectType); // //////////////////////////// // Query Name final TextField<String> queryName = new TextField<>("dataSetName", new PropertyModel<>(this, "indexName")); queryName.add(new ModalUpdateOnlyOnChangeAjaxBehavior()); queryForm.add(queryName); add(queryForm); // //////////////////////////// // Status statusField = new Label("status", new PropertyModel<>(this, "status")); statusField.setOutputMarkupId(true); queryForm.add(statusField); // //////////////////////////// // Add the Query and Delete buttons to the form. queryForm.add(new QueryAjaxButton()); queryForm.add(new DeleteIndexAjaxButton()); }
From source file:com.modusoperandi.dragonfly.widgets.table.TableWidgetPage.java
License:Open Source License
/** * Instantiates a new table widget page. *//*from w ww . ja v a 2 s . c om*/ public TableWidgetPage() { // ///////////////////////////// // Elasticsearch getEsClient(); sortOrder = "Asc"; // ///////////////////////////// // UI setVersioned(false); final Form<?> queryForm = new Form<>("queryForm"); add(queryForm); // //////////////////////////// // Index Name populateIndices(); selectIndex = new DropDownChoice<>("dataSetName", new PropertyModel<String>(this, "indexName"), indexList); selectIndex.add(new AjaxFormComponentUpdatingBehavior("focus") { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { if (populateIndices()) { target.add(selectIndex); } } }); selectIndex.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { resetFacets(); target.add(selectFacetField); target.add(selectFacetValue); target.appendJavaScript(jqgridUpdateJs()); target.appendJavaScript(jqgridPopulatedJs()); } }); queryForm.add(selectIndex); // //////////////////////////// // Filter final TextField<String> filterField = new TextField<>("filter", new PropertyModel<String>(this, "filter")); filterField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.appendJavaScript(jqgridUpdateJs()); target.appendJavaScript(jqgridPopulatedJs()); } }); queryForm.add(filterField); // //////////////////////////// // Facet selectFacetField = new DropDownChoice<>("facetField", new PropertyModel<String>(this, "facetField"), fieldList); selectFacetField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { populateFacet(esMakeQuery()); target.add(selectFacetValue); target.appendJavaScript(jqgridUpdateJs()); target.appendJavaScript(jqgridPopulatedJs()); } }); queryForm.add(selectFacetField); selectFacetValue = new DropDownChoice<>("facetValue", new PropertyModel<String>(this, "facetValue"), valueList); selectFacetValue.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2981822623630720652L; @Override protected void onUpdate(final AjaxRequestTarget target) { target.appendJavaScript(jqgridUpdateJs()); target.appendJavaScript(jqgridPopulatedJs()); } }); queryForm.add(selectFacetValue); // ////////////////////////////// // Table populateTableBehavior = new TablePopulateAjaxBehavior(); add(populateTableBehavior); // ////////////////////////////// // Updates add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.ajax.AbstractAjaxTimerBehavior#onTimer(org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onTimer(final AjaxRequestTarget target) { if (indexName != null) { final IndicesExistsResponse exists = getEsClient().admin().indices() .exists(new IndicesExistsRequest(indexName)).actionGet(); if (exists.isExists()) { final CountResponse response = getEsClient().prepareCount(indexName).execute().actionGet(); if (response.getCount() != lastCount) { System.out .println(Long.toString(lastCount) + " : " + Long.toString(response.getCount())); lastCount = response.getCount(); target.appendJavaScript(jqgridUpdateJs()); target.appendJavaScript(jqgridPopulatedJs()); } } } } }); }
From source file:com.mycompany.DropDownPage.java
License:Apache License
public DropDownPage() { List<ChoiceElement> years = Arrays.asList(new ChoiceElement("2010", "2010N"), new ChoiceElement("2011", "2011N"), new ChoiceElement("2012", "2012N"), new ChoiceElement("2013", "2013N"), new ChoiceElement("2014", "2014N"), new ChoiceElement("2015", "2015N")); final DropDownChoice<ChoiceElement> choice = new DropDownChoice<ChoiceElement>("choice", new Model<ChoiceElement>(), years, new IChoiceRenderer<ChoiceElement>() { public Object getDisplayValue(ChoiceElement object) { return object.getName(); }/*from w w w. java 2 s . c o m*/ public String getIdValue(ChoiceElement object, int index) { return object.getId(); } }); final WebMarkupContainer dataPanel = new WebMarkupContainer("dataPanel"); dataPanel.setOutputMarkupId(true); dataPanel.add(new EmptyPanel("dataList")); choice.add(new OnChangeAjaxBehavior() { @Override protected void onUpdate(AjaxRequestTarget target) { dataPanel.remove("dataList"); dataPanel.add(new AjaxLazyLoadPanel("dataList") { @Override public Component getLazyLoadComponent(String markupId) { return new PagingNavigatorPanel(markupId, choice.getModelObject().getName(), choice.getValue()); } }); target.add(dataPanel); } }); add(dataPanel); add(choice); }
From source file:com.norconex.commons.wicket.markup.html.form.UpdatingCheckbox.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 2483719054190303122L; @Override/* ww w. j a va 2 s . co m*/ protected void onUpdate(AjaxRequestTarget target) { onChange(target); } }); }
From source file:com.tysanclan.site.projectewok.components.PrimaryPreferencesPanel.java
License:Open Source License
/** * /* w w w . j a v a 2 s. co m*/ */ public PrimaryPreferencesPanel(String id, User user) { super(id); Form<User> settingsForm = new Form<User>("settingsForm", ModelMaker.wrap(user)) { private static final long serialVersionUID = 1L; @SpringBean private UserService userService; /** * @see org.apache.wicket.markup.html.form.Form#onSubmit() */ @SuppressWarnings("unchecked") @Override protected void onSubmit() { User _user = getModelObject(); Long user_id = _user.getId(); DropDownChoice<String> tzChoice = (DropDownChoice<String>) get("timezone"); TextField<String> customTitleField = (TextField<String>) get("customTitle"); TextField<String> imageURLField = (TextField<String>) get("imageURL"); TextArea<String> signatureArea = (TextArea<String>) get("signature"); CheckBox collapseBox = (CheckBox) get("collapseForums"); String timezone = tzChoice.getModelObject(); String customTitle = customTitleField.getModelObject(); String imageURL = imageURLField.getModelObject(); String signature = signatureArea.getModelObject(); boolean collapse = collapseBox.getModelObject(); userService.setUserAvatar(user_id, imageURL); userService.setUserCustomTitle(user_id, customTitle); userService.setUserSignature(user_id, signature); userService.setUserTimezone(user_id, timezone); userService.setUserCollapseForums(user_id, collapse); getSession().info("Preferences updated"); PrimaryPreferencesPanel.this.onSubmit(); } }; List<String> timezones = new LinkedList<String>(); timezones.addAll(Arrays.asList(TimeZone.getAvailableIDs())); Collections.sort(timezones); settingsForm.add(new CheckBox("collapseForums", new Model<>(user.isCollapseForums()))); settingsForm.add(new DropDownChoice<>("timezone", new Model<>(user.getTimezone()), timezones)); settingsForm.add(new TextField<>("customTitle", new Model<>(user.getCustomTitle())) .add(StringValidator.maximumLength(255))); TextField<String> urlField = new TextField<String>("imageURL", new Model<>(user.getImageURL())); urlField.add(StringValidator.maximumLength(255)); urlField.setOutputMarkupId(true); urlField.setOutputMarkupPlaceholderTag(true); urlField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget) */ @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { TextField<String> urlComponent = (TextField<String>) getComponent(); String newURL = urlComponent.getModelObject(); WebMarkupContainer container = getImage(); if (newURL == null || newURL.isEmpty() || "#".equals(newURL)) { container.setVisible(false); } else { container.add(AttributeModifier.replace("src", newURL)); container.setVisible(true); } if (target != null) { target.add(getImage()); } } }); settingsForm.add(urlField); settingsForm.add(new BBCodeTextArea("signature", user.getSignature())); image = new WebMarkupContainer("preview"); if (user.getImageURL() == null || user.getImageURL().isEmpty() || "#".equals(user.getImageURL())) { image.setVisible(false); } else { image.add(AttributeModifier.replace("src", user.getImageURL())); } image.setOutputMarkupId(true); image.setOutputMarkupPlaceholderTag(true); settingsForm.add(image); add(settingsForm); }
From source file:com.tysanclan.site.projectewok.components.ProfilePanel.java
License:Open Source License
/** * //w w w . j a va2 s. c om */ public ProfilePanel(String id, User user) { super(id); PageParameters params = new PageParameters(); params.add("userid", user.getId().toString()); add(new BookmarkablePageLink<User>("profilelink", MemberPage.class, params)); Form<User> profileForm = new Form<User>("profile", ModelMaker.wrap(user)) { /** * */ private static final long serialVersionUID = 1L; @SpringBean private ProfileService profileService; /** * @see org.apache.wicket.markup.html.form.Form#onSubmit() */ @SuppressWarnings("unchecked") @Override protected void onSubmit() { User u = getModelObject(); Profile profile = u.getProfile(); TextField<String> realnameField = (TextField<String>) get("realname"); TextField<String> photoURLField = (TextField<String>) get("photoURL"); TextField<String> skypeField = (TextField<String>) get("skypename"); TextField<String> twitterField = (TextField<String>) get("twitter"); CheckBox photoPublicCheckbox = (CheckBox) get("public"); CheckBox skypePublicBox = (CheckBox) get("skypepublic"); TextArea<String> publicdescField = (TextArea<String>) get("publicdesc"); TextArea<String> privatedescField = (TextArea<String>) get("privatedesc"); String realname = realnameField.getModelObject(); Date birthDate = getSelectedDate(); String photoURL = photoURLField.getModelObject(); Boolean photoPublic = photoPublicCheckbox.getModelObject(); Boolean skypePublic = skypePublicBox.getModelObject(); String publicdesc = publicdescField.getModelObject(); String privatedesc = privatedescField.getModelObject(); String aimName = skypeField.getModelObject(); String twitter = twitterField.getModelObject(); if (profile == null) { profile = profileService.createProfile(u); } if (!isBothNullOrEquals(realname, profile.getRealName())) { profileService.setRealname(profile, realname); } if (!isBothNullOrEquals(birthDate, profile.getBirthDate())) { profileService.setBirthDate(profile, birthDate); } if (!isBothNullOrEquals(twitter, profile.getTwitterUID())) { profileService.setTwitterUID(profile, twitter); } if (!isBothNullOrEquals(aimName, profile.getInstantMessengerAddress()) || !isBothNullOrEquals(skypePublic, profile.isInstantMessengerPublic())) { profileService.setAIMAddress(profile, aimName, skypePublic); } if (!isBothNullOrEquals(photoURL, profile.getPhotoURL()) || !isBothNullOrEquals(photoPublic, profile.isPhotoPublic())) { profileService.setPhotoURL(profile, photoURL, photoPublic); } if (!isBothNullOrEquals(publicdesc, profile.getPublicDescription())) { profileService.setPublicDescription(profile, publicdesc); } if (!isBothNullOrEquals(privatedesc, profile.getPrivateDescription())) { profileService.setPrivateDescription(profile, privatedesc); } ProfilePanel.this.onUpdated(); } public <T> boolean isBothNullOrEquals(T value1, T value2) { if (value1 == null && value2 == null) { return true; } if (value1 == null) return false; if (value2 == null) return false; return value1.equals(value2); } }; Profile profile = user.getProfile(); profileForm.add( new TextField<String>("realname", new Model<String>(profile != null ? profile.getRealName() : ""))); Calendar cal = DateUtil.getCalendarInstance(); cal.add(Calendar.YEAR, -13); int year = cal.get(Calendar.YEAR); if (profile != null) { setSelectedDate(profile.getBirthDate()); } profileForm.add(new InlineDatePicker("birthdate", profile != null ? profile.getBirthDate() : null) { private static final long serialVersionUID = 1L; @Override protected void onDateSelected(Date date, AjaxRequestTarget target) { Label oldAge = getAge(); Label newAge = new Label("age", getAgeModel(date)); newAge.setOutputMarkupId(true); newAge.setOutputMarkupPlaceholderTag(true); oldAge.replaceWith(newAge); setAge(newAge); setSelectedDate(date); if (target != null) { target.add(newAge); } } }.setChangeMonth(true).setChangeYear(true).setYearRange("'1900:" + year + "'")); profileForm.add(new TextField<String>("twitter", new Model<String>(profile != null ? profile.getTwitterUID() : ""))); TextField<String> photoURLField = new TextField<String>("photoURL", new Model<String>(profile != null ? profile.getPhotoURL() : "")); photoURLField.setOutputMarkupId(true); photoURLField.setOutputMarkupPlaceholderTag(true); photoURLField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget) */ @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { TextField<String> urlComponent = (TextField<String>) getComponent(); String newURL = urlComponent.getModelObject(); WebMarkupContainer container = getImage(); if (newURL == null || newURL.isEmpty()) { container.setVisible(false); } else { container.add(AttributeModifier.replace("src", newURL)); container.setVisible(true); } if (target != null) { target.add(getImage()); } } }); String currentPhotoURL = profile != null ? profile.getPhotoURL() : null; image = new WebMarkupContainer("preview"); if (currentPhotoURL == null || currentPhotoURL.isEmpty()) { image.setVisible(false); } else { image.add(AttributeModifier.replace("src", currentPhotoURL)); } image.setOutputMarkupId(true); image.setOutputMarkupPlaceholderTag(true); age = new Label("age", getAgeModel(profile)); age.setOutputMarkupId(true); age.setOutputMarkupPlaceholderTag(true); profileForm.add(age); profileForm.add(image); profileForm .add(new CheckBox("public", new Model<Boolean>(profile != null ? profile.isPhotoPublic() : false))); profileForm.add(new ContextImage("skypeicon", "images/skype-icon.gif")); profileForm.add(new CheckBox("skypepublic", new Model<Boolean>(profile != null ? profile.isInstantMessengerPublic() : false))); profileForm.add(new TextField<String>("skypename", new Model<String>(profile != null ? profile.getInstantMessengerAddress() : ""))); profileForm.add(new BBCodeTextArea("publicdesc", profile != null ? profile.getPublicDescription() : "")); profileForm.add(new BBCodeTextArea("privatedesc", profile != null ? profile.getPrivateDescription() : "")); profileForm.add(photoURLField); add(profileForm); }