Hi, You are using "cellItem.add(new AjaxEditableLabel<Integer>(componentId)" i.e. the AEL has no its own model but uses IComponentInheritedModel from its parents. Try by using a model for AEL: cellItem.add(new AjaxEditableLabel<Integer>(componentId, Model.of(0))
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Wed, May 17, 2017 at 6:02 PM, Ehsan <[email protected]> wrote: > Hello every one, > I have recently started to work with Wicket. > Currently I am having a problem with AjaxEditableLabel. I am adding objects > from my defined class "TechnicalService" to an > AjaxFallBackDefaultDataTable. > This Object simply contains a String which is the first column of the > datatable. The second column is AjaxEditableLabel which I use to set a > number for each of technical services in the first column. Now the problem > I > am having is that I can not retrieve the values which are entered in each > of > the generated textFields. I tried to add them to a list in the bean object > by Overriding onSubmit method, but it does not work. Could any one help me > about this problem and let me know how to retrieve the values of the > dynamically generated AjaxEditableLabels? > > Here is my code: > > private class DataProvider extends SortableDataProvider<TechnicalService, > String> { > > /** > * > */ > private static final long serialVersionUID = > 7590206250581220823L; > > public DataProvider() { > super(); > this.setSort("id", > org.apache.wicket.extensions.markup.html.repeater.data. > sort.SortOrder.ASCENDING); > } > > public IModel<TechnicalService> model(TechnicalService > object) { > return Model.of(object); > } > > public Iterator<? extends TechnicalService> iterator(long > offset, long > count) { > return searchForm.getTechnicalServices(). > iterator(); > } > > public long size() { > return searchForm.getTechnicalServices().size(); > } > } > > private List<IColumn<TechnicalService, String>> getColumns() { > logger.debug("About to evaluate columns"); > > List<IColumn<TechnicalService, String>> lReturn = new > LinkedList<IColumn<TechnicalService, String>>(); > > lReturn.add(new PropertyColumn<TechnicalService, String>( > new > StringResourceModel("table.col.header.tecnicalServiceName", > this, > null), "ts", "ts")); > > lReturn.add(new PropertyColumn<TechnicalService, String>( > new > StringResourceModel("table.col.header.quantity", > this, null), > "technicalServiceNumber", > "technicalServiceNumber") { > private static final long serialVersionUID = > 8344520291257227470L; > > /** > * > */ > > @Override > public void populateItem(Item<ICellPopulator< > TechnicalService>> > cellItem, String componentId, > IModel<TechnicalService> rowModel) > { > > final int index = cellItem.getIndex(); > > cellItem.add(new > AjaxEditableLabel<Integer>(componentId) { > /** > * > */ > private static final long > serialVersionUID = -3528327724800319532L; > > TextField<Integer> editor; > > @Override > protected FormComponent<Integer> > newEditor(MarkupContainer parent, > String componentId, > IModel<Integer> > model) { > editor = > (TextField<Integer>) super.newEditor(parent, componentId, > model); > editor.setVisible(true); > return editor; > } > > @Override > protected Component > newLabel(MarkupContainer parent, String > componentId, IModel<Integer> model) { > return > super.newLabel(parent, componentId, model).setVisible(false); > } > > @Override > protected void > onSubmit(AjaxRequestTarget target) { > super.onSubmit(target); > > rolloutBean.getListOfCells().set(index, getModelObject()); > > } > > }); > } > > }); > > return lReturn; > } > > > > > I also attach the photo of the GUI: > <http://apache-wicket.1842946.n4.nabble.com/file/n4677886/ > Screen_Shot_2017-05-17_at_18.png> > > > > > > > > > -- > View this message in context: http://apache-wicket.1842946. > n4.nabble.com/Access-to-Dynamically-Generated-AjaxEditableLabel-Value- > tp4677886.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
