yep I did it like that and it works

public class Editor extends FormComponentPanel<List<String>> {
    private ListView<String> item;

    /**
     * If you dont have ArrayList you can always copy your collection to new
ArrayList.
     *
     * @param id of the control
     * @param accounts a list of all accounts assigned to the peron.
     */
    public Editor(String id, IModel items) {
        super(id, items);
        buildComponents();
    }

    private void buildComponents()
    {
        setOutputMarkupPlaceholderTag(false);
        add(new SimpleAttributeModifier("class", "editor-panel"));

        final List<String> items = getModelObject();
        item = new ListView<String>("item", items){

            @Override
            protected void populateItem(ListItem<String> listItem)
            {
                String number = listItem.getModelObject();
                listItem.add(new NumberInput("number", number));
                listItem.add(new RemoveButton("remove", number, items));
            }
        };
        item.setReuseItems(true);
        Link addButton = new Link("add"){

            @Override
            public void onClick() {
                items.add("");
                item.detach();
            }
        };
        add(addButton);
        add(item);
    }

    @Override
    protected void onComponentTag(ComponentTag tag) {
        tag.setName("section");
        super.onComponentTag(tag);
    }

    @Override
    protected void convertInput()
    {
        setConvertedInput(saveConvertedData());
    }

    private List<String> saveConvertedData()
    {
        final List<String> items = new ArrayList<String>();
        item.visitChildren(NumberInput.class, new
Component.IVisitor<NumberInput>(){
            @Override
            public Object component(NumberInput component) {
                String number = component.getConvertedInput();
                items.add(number);

                return Component.IVisitor.CONTINUE_TRAVERSAL;
            }
        });
        return items;
    }
}

thanks for help

pozdrawiam
Paweł Kamiński

kami...@gmail.com
pkaminski....@gmail.com
______________________

Reply via email to