List of usage examples for org.apache.wicket.model PropertyModel of
public static <Z> PropertyModel<Z> of(Object parent, String property)
From source file:biz.turnonline.ecosystem.origin.frontend.myaccount.page.MyAccountBasics.java
License:Apache License
public MyAccountBasics() { add(new FirebaseAppInit(firebaseConfig)); final MyAccountModel accountModel = new MyAccountModel(); final IModel<Map<String, Country>> countriesModel = new CountriesModel(); setModel(accountModel);/*from w w w. j a v a2s . co m*/ // form Form<Account> form = new Form<Account>("form", accountModel) { private static final long serialVersionUID = -938924956863034465L; @Override protected void onSubmit() { Account account = getModelObject(); send(getPage(), Broadcast.BREADTH, new AccountUpdateEvent(account)); } }; add(form); PropertyModel<Boolean> companyModel = new PropertyModel<>(accountModel, "company"); form.add(new CompanyPersonSwitcher("isCompanyRadioGroup", companyModel)); // account email fieldset form.add(new Label("email", new PropertyModel<>(accountModel, "email"))); // company basic info final CompanyBasicInfo<Account> basicInfo = new CompanyBasicInfo<Account>("companyData", accountModel) { private static final long serialVersionUID = -2992960490517951459L; @Override protected DropDownChoice<LegalForm> provideLegalForm(String componentId) { LegalFormListModel choices = new LegalFormListModel(); return new IndicatingAjaxDropDown<>(componentId, new LegalFormCodeModel(accountModel, "legalForm", choices), choices, new LegalFormRenderer()); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(account.getCompany()); } }; form.add(basicInfo); // company basic info panel behaviors basicInfo.addLegalForm(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 6948210639258798921L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); basicInfo.addVatId(new Behavior() { private static final long serialVersionUID = 100053137512632023L; @Override public void onConfigure(Component component) { super.onConfigure(component); Account account = basicInfo.getModelObject(); boolean visible; if (account == null || account.getBusiness() == null) { visible = true; } else { Boolean vatPayer = account.getBusiness().getVatPayer(); visible = vatPayer == null ? Boolean.FALSE : vatPayer; } component.setVisible(visible); } }); final TextField taxId = basicInfo.getTaxId(); final TextField vatId = basicInfo.getVatId(); final CheckBox vatPayer = basicInfo.getVatPayer(); basicInfo.addVatPayer(new AjaxFormSubmitBehavior(OnChangeAjaxBehavior.EVENT_NAME) { private static final long serialVersionUID = -1238082494184937003L; @Override protected void onSubmit(AjaxRequestTarget target) { Account account = (Account) basicInfo.getDefaultModelObject(); String rawTaxIdValue = taxId.getRawInput(); AccountBusiness business = account.getBusiness(); if (rawTaxIdValue != null && Strings.isEmpty(business == null ? null : business.getVatId())) { // VAT country prefix proposal String country = business == null ? "" : business.getDomicile(); country = country.toUpperCase(); //noinspection unchecked vatId.getModel().setObject(country + rawTaxIdValue); } // must be set manually as getDefaultProcessing() returns false vatPayer.setModelObject(!(business == null ? Boolean.FALSE : business.getVatPayer())); if (target != null) { target.add(vatId.getParent()); } } @Override public boolean getDefaultProcessing() { return false; } }); // personal data panel PersonalDataPanel<Account> personalData = new PersonalDataPanel<Account>("personalData", accountModel) { private static final long serialVersionUID = -2808922906891760016L; @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(!account.getCompany()); } }; form.add(personalData); // personal address panel PersonalAddressPanel<Account> address = new PersonalAddressPanel<Account>("personalAddress", accountModel) { private static final long serialVersionUID = 3481146248010938807L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new PersonalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(!account.getCompany()); } }; form.add(address); address.addCountry(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -1016447969591778948L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); // company address panel CompanyAddressPanel<Account> companyAddress; companyAddress = new CompanyAddressPanel<Account>("companyAddress", accountModel, false, false) { private static final long serialVersionUID = -6760545061622186549L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new CompanyDomicileModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } @Override protected void onConfigure() { super.onConfigure(); Account account = getModelObject(); this.setVisible(account.getCompany()); } }; form.add(companyAddress); companyAddress.addCountry(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -5476413125490349124L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); IModel<AccountPostalAddress> postalAddressModel = new PropertyModel<>(accountModel, "postalAddress"); IModel<Boolean> hasAddress = new PropertyModel<>(accountModel, "hasPostalAddress"); PostalAddressPanel<AccountPostalAddress> postalAddress; postalAddress = new PostalAddressPanel<AccountPostalAddress>("postal-address", postalAddressModel, hasAddress) { private static final long serialVersionUID = -930960688138308527L; @Override protected DropDownChoice<Country> provideCountry(String componentId) { return new IndicatingAjaxDropDown<>(componentId, new PostalAddressCountryModel(accountModel, countriesModel), new CountryRenderer(), countriesModel); } }; form.add(postalAddress); postalAddress.addStreet(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 4050800366443676166L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); PropertyModel<Object> billingContactModel = PropertyModel.of(accountModel, "billingContact"); form.add(new SimplifiedContactFieldSet<>("contact", billingContactModel)); // save button form.add(new IndicatingAjaxButton("save", new I18NResourceModel("button.save"), form)); }
From source file:de.alpharogroup.wicket.components.i18n.dropdownchoice.panels.DoubleDropDownPanel.java
License:Apache License
/** * Factory method for creating the new child {@link DropDownChoice}. This method is invoked in * the constructor from the derived classes and can be overridden so users can provide their own * version of a new child {@link DropDownChoice}. * * @param id//from w ww .ja va2 s. c o m * the id * @param model * the model * @return the new child {@link DropDownChoice}. */ protected DropDownChoice<T> newChildChoice(final String id, final IModel<TwoDropDownChoicesBean<T>> model) { final IModel<T> selectedChildOptionModel = new PropertyModel<>(model, "selectedChildOption"); final IModel<List<T>> childChoicesModel = PropertyModel.of(model, "childChoices"); final DropDownChoice<T> cc = new LocalisedDropDownChoice<T>(id, selectedChildOptionModel, childChoicesModel, this.childRenderer) { @Override protected void onSelectionChanged(Object newSelection) { DoubleDropDownPanel.this.onChildSelectionChanged(newSelection); } @Override protected boolean wantOnSelectionChangedNotifications() { return true; } @Override public void convertInput() { T convertedInput = getConvertedInput(); if (convertedInput == null) { String[] inputArray = getInputAsArray(); convertedInput = convertChoiceValue(inputArray); DoubleDropDownPanel.this.getModelObject().setSelectedChildOption(convertedInput); setConvertedInput(DoubleDropDownPanel.this.getModelObject().getSelectedChildOption()); } else { setConvertedInput(convertedInput); } } @SuppressWarnings("unchecked") protected T convertChoiceValue(String[] value) { return (T) (value != null && value.length > 0 && value[0] != null ? trim(value[0]) : null); } }; cc.setOutputMarkupId(true); cc.add(new AjaxFormComponentUpdatingBehavior("change") { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { DoubleDropDownPanel.this.onChildChoiceError(target, e); } /** * {@inheritDoc} */ @Override protected void onUpdate(final AjaxRequestTarget target) { DoubleDropDownPanel.this.onChildChoiceUpdate(target); } }); return cc; }
From source file:de.alpharogroup.wicket.components.i18n.dropdownchoice.panels.DoubleDropDownPanel.java
License:Apache License
/** * Factory method for creating the new root {@link DropDownChoice}. This method is invoked in * the constructor from the derived classes and can be overridden so users can provide their own * version of a new root {@link DropDownChoice}. * * @param id//from w ww.j a v a 2s . co m * the id * @param model * the model * @return the new root {@link DropDownChoice}. */ protected DropDownChoice<T> newRootChoice(final String id, final IModel<TwoDropDownChoicesBean<T>> model) { final IModel<T> selectedRootOptionModel = PropertyModel.of(model, "selectedRootOption"); final IModel<List<T>> rootChoicesModel = PropertyModel.of(model, "rootChoices"); final DropDownChoice<T> rc = new LocalisedDropDownChoice<T>(id, selectedRootOptionModel, rootChoicesModel, this.rootRenderer) { @Override protected void onSelectionChanged(Object newSelection) { DoubleDropDownPanel.this.onRootSelectionChanged(newSelection); } @Override protected boolean wantOnSelectionChangedNotifications() { return true; } @Override public void convertInput() { T convertedInput = getConvertedInput(); if (convertedInput == null) { String[] inputArray = getInputAsArray(); convertedInput = convertChoiceValue(inputArray); DoubleDropDownPanel.this.getModelObject().setSelectedRootOption(convertedInput); setConvertedInput(DoubleDropDownPanel.this.getModelObject().getSelectedRootOption()); } else { setConvertedInput(convertedInput); } } @SuppressWarnings("unchecked") protected T convertChoiceValue(String[] value) { return (T) (value != null && value.length > 0 && value[0] != null ? trim(value[0]) : null); } }; rc.add(new AjaxFormComponentUpdatingBehavior("change") { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { DoubleDropDownPanel.this.onRootChoiceError(target, e); } /** * {@inheritDoc} */ @Override protected void onUpdate(final AjaxRequestTarget target) { DoubleDropDownPanel.this.onRootChoiceUpdate(target); } }); return rc; }
From source file:de.alpharogroup.wicket.data.provider.examples.datatable.DataTablePanel.java
License:Apache License
public DataTablePanel(final String id) { super(id);//from ww w. j a v a2 s. com final SortableFilterPersonDataProvider dataProvider = new SortableFilterPersonDataProvider( PersonDatabaseManager.getInstance().getPersons()) { private static final long serialVersionUID = 1L; @Override public List<Person> getData() { final List<Person> persons = PersonDatabaseManager.getInstance().getPersons(); setData(persons); return persons; } }; dataProvider.setSort("firstname", SortOrder.ASCENDING); final List<IColumn<Person, String>> columns = new ArrayList<>(); columns.add(new AbstractColumn<Person, String>(new Model<>("Actions")) { /** * The serialVersionUID */ private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ @Override public void populateItem(final Item<ICellPopulator<Person>> cellItem, final String componentId, final IModel<Person> model) { final ActionPanel<Person> editActionPanel = new ActionPanel<Person>(componentId, model) { /** * The serialVersionUID */ private static final long serialVersionUID = 1L; /** * {@inheritDoc} */ @Override protected IModel<String> newActionLinkLabelModel() { return ResourceModelFactory.newResourceModel("global.main.button.edit.label"); } /** * {@inheritDoc} */ @Override protected void onAction(final AjaxRequestTarget target) { DataTablePanel.this.onEdit(target); } }; cellItem.add(editActionPanel); } }); columns.add(new PropertyColumn<Person, String>(Model.of("First name"), "firstname", "firstname")); columns.add(new PropertyColumn<Person, String>(Model.of("Last Name"), "lastname", "lastname") { private static final long serialVersionUID = 1L; @Override public String getCssClass() { return "last-name"; } }); columns.add(new PropertyColumn<Person, String>(Model.of("Date of birth"), "dateOfBirth", "dateOfBirth")); final DataTable<Person, String> tableWithFilterForm = new DataTable<>("tableWithFilterForm", columns, dataProvider, 10); tableWithFilterForm.setOutputMarkupId(true); final FilterForm<PersonFilter> filterForm = new FilterForm<>("filterForm", dataProvider); filterForm.add(new TextField<>("dateFrom", PropertyModel.of(dataProvider, "filterState.dateFrom"))); filterForm.add(new TextField<>("dateTo", PropertyModel.of(dataProvider, "filterState.dateTo"))); add(filterForm); final FilterToolbar filterToolbar = new FilterToolbar(tableWithFilterForm, filterForm); tableWithFilterForm.addTopToolbar(filterToolbar); tableWithFilterForm.addTopToolbar(new NavigationToolbar(tableWithFilterForm)); tableWithFilterForm.addTopToolbar(new HeadersToolbar<>(tableWithFilterForm, dataProvider)); filterForm.add(tableWithFilterForm); }
From source file:de.alpharogroup.wicket.data.provider.examples.datatable.DefaultDataTablePanel.java
License:Apache License
public DefaultDataTablePanel(final String id) { super(id);/*w ww . ja v a2 s.c o m*/ final List<Person> persons = PersonDatabaseManager.getInstance().getPersons(); final SortableFilterPersonDataProvider dataProvider = new SortableFilterPersonDataProvider(persons) { private static final long serialVersionUID = 1L; @Override public List<Person> getData() { return PersonDatabaseManager.getInstance().getPersons(); } }; final List<IColumn<Person, String>> columns = new ArrayList<>(); columns.add(new TextFilteredPropertyColumn<Person, PersonFilter, String>(Model.of("First name"), "firstname", "firstname")); columns.add(new TextFilteredPropertyColumn<Person, PersonFilter, String>(Model.of("Last Name"), "lastname", "lastname")); columns.add(new PropertyColumn<Person, String>(Model.of("Date of birth"), "dateOfBirth", "dateOfBirth")); final FilterForm<PersonFilter> form = new FilterForm<>("form", dataProvider); form.add(new TextField<>("firstname", PropertyModel.of(dataProvider, "filterState.firstname"))); final DefaultDataTable<Person, String> dataTable = new DefaultDataTable<>("dataTable", columns, dataProvider, 10); dataTable.addTopToolbar(new FilterToolbar(dataTable, form)); form.add(dataTable); add(form); }
From source file:net.ftlines.wicket.validation.bean.examples.basic.FileSearchPage.java
License:Apache License
public FileSearchPage() { add(new FeedbackPanel("feedback")); IModel<FileSearch> model = PropertyModel.of(this, "search"); model = CompoundPropertyModel.of(model); Form<?> form = new ValidationForm<FileSearch>("form", model) { @Override/*from ww w . j a va 2 s. c om*/ protected void onSubmit() { info("Validated successfully"); } }; add(form); form.add(new TextField<String>("filename")); form.add(new TextField<Integer>("minSize")); form.add(new TextField<Integer>("maxSize")); }
From source file:org.apache.nutch.webui.pages.AbstractBasePage.java
License:Apache License
protected Component addInstancesMenuMenu() { IModel<String> instanceName = PropertyModel.of(currentInstance, "name"); DropDownButton instancesMenu = new NavbarDropDownButton(instanceName) { @Override//from ww w . ja v a 2s . c o m protected List<AbstractLink> newSubMenuButtons(String buttonMarkupId) { List<NutchInstance> instances = instanceService.getInstances(); List<AbstractLink> subMenu = Lists.newArrayList(); for (NutchInstance instance : instances) { subMenu.add(new Link<NutchInstance>(buttonMarkupId, Model.of(instance)) { @Override public void onClick() { currentInstance.setObject(getModelObject()); setResponsePage(DashboardPage.class); } }.setBody(Model.of(instance.getName()))); } return subMenu; } }.setIconType(FontAwesomeIconType.gears); return instancesMenu; }
From source file:org.cyclop.web.panels.queryeditor.result.QueryResultPanel.java
License:Apache License
@Override protected final void onInitialize() { super.onInitialize(); rowDataProvider.setElementsLimit(config.queryEditor.rowsLimit); cqlResultText = initClqReslutText(); resultTable = initResultsTable();// w w w .ja v a2s . co m IModel<CqlRowMetadata> metadataModel = PropertyModel.of(queryResultModel, "rowMetadata"); IPageableItems pagable = initTableHeader(resultTable, columnsModel, rowDataProvider, metadataModel); pager = createPager(pagable); if (showResultsTableOnInit) { blendInResultsTable(); } }
From source file:org.dcak.sample.panel.EditSampleBeanPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); add(new FeedbackPanel("feedback").setOutputMarkupId(true)); Form form = new Form("form", getDefaultModel()); form.add(new TextField("nodeId", PropertyModel.of(getDefaultModel(), "id")).setRequired(true)); form.add(new TextField("nodeValue", PropertyModel.of(getDefaultModel(), "value")).setRequired(true)); form.add(new AjaxSubmitLink("save", form) { @Override// w ww .j av a2 s . co m protected void onError(AjaxRequestTarget target, Form<?> form) { super.onError(target, form); error("It's an error!"); target.add(EditSampleBeanPanel.this.get("feedback")); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { super.onSubmit(target, form); target.add(getPage().get("tree")); } }); form.add(new AjaxLink("cancel") { @Override public void onClick(AjaxRequestTarget art) { getSampleBeanModel().setObject(new SampleBean()); art.add(EditSampleBeanPanel.this); art.add(getPage().get("tree")); } }); add(form); }
From source file:org.efaps.ui.wicket.components.search.DimValuePanel.java
License:Apache License
/** * Instantiates a new dim value panel./* ww w .ja v a2 s . com*/ * * @param _id the id * @param _model the model */ public DimValuePanel(final String _id, final IModel<DimTreeNode> _model) { super(_id, _model); final WebMarkupContainer cont = new WebMarkupContainer("triStateDiv"); cont.setOutputMarkupId(true); if (_model.getObject().getStatus() != null) { cont.add(new AttributeAppender("class", _model.getObject().getStatus() ? "on" : "off", " ")); } add(cont); final AjaxButton btn = new AjaxButton("triStateBtn") { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(final AjaxRequestAttributes _attributes) { super.updateAjaxAttributes(_attributes); final AjaxCallListener lstnr = new AjaxCallListener(); lstnr.onBefore(getJavaScript()); _attributes.getAjaxCallListeners().add(lstnr); } }; cont.add(btn); cont.add(new Label("label", _model.getObject().getLabel())); cont.add(new Label("value", String.valueOf(((DimValue) _model.getObject().getValue()).getValue()))); cont.add(new HiddenField<Boolean>("triStateValue", PropertyModel.of(_model.getObject(), "status")) { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Override public boolean isInputNullable() { return true; }; @Override protected String getModelValue() { final Boolean val = (Boolean) getDefaultModelObject(); final String ret; if (BooleanUtils.isFalse(val)) { ret = "off"; } else if (BooleanUtils.isTrue(val)) { ret = "on"; } else { ret = ""; } return ret; }; }.setOutputMarkupId(true)); }