Using Wicket Repeater with Card Support

Therefore, I want to use Wicket 1.5 to display the item and the quantity associated with it. The data structure that I use to support this map is a map (new HashMap ()), where Item is a POJ whose data does not matter. In fact, I would like to use one of the repeater gates, but I have experience using ListView. Is there a repeater that will work well with the Card, or will I need to encode my own? If I need to encode my own, what is the best class to override?

I would like the relay output to be something like this:

QuantityX: ItemName (ItemNum)

for example:

2x: someItem (255609)

The map may change through user input, but I am familiar with updating component layouts using AJAX through Wicket. Your help is greatly appreciated.

+3
source share
3 answers

I ended up using ListView, which contained Map.Entry in the ListView model, as suggested by Thorsten above. He works as intended, and thanks to Thorsten.

+1
source

- ListView , , Arrays.asList(HashMap#values#toArray) Loop Reapeat, , AbstractReadOnlyModel, . . , AbstractRepeater, Loop.

0

See article: Wicket Model Mask: Supported MapView ListView

public CustomFieldsPanel( String id, final IModel<Map<String,ProductCustomField>> fieldMapModel, final FeedbackPanel feedbackPanel ) {

    super( id, fieldMapModel );
    this.feedbackPanel = feedbackPanel;

    this.setOutputMarkupId( true ); // AJAX JavaScript code needs to have some id="...".

    IModel<List<ProductCustomField>> listModel = new LoadableDetachableModel() {
        @Override protected List<ProductCustomField> load() {
            Map<String,ProductCustomField> map = (Map) CustomFieldsPanel.this.getDefaultModelObject();
            return new ArrayList(map.values());
        }
    };

    ListView<ProductCustomField> listView;
    add( listView = new ListView<ProductCustomField>("fieldsRows", listModel){
        @Override
        protected void populateItem( final ListItem<ProductCustomField> item ) {
            item.add( new CustomFieldRowPanel("fieldRow", item.getModel()){
                // Delete icon was clicked.
                @Override
                protected void onDelete( AjaxRequestTarget target ) {
                    Map<String,ProductCustomField> fieldsMap = (Map) CustomFieldsPanel.this.getDefaultModelObject();
                    fieldsMap.remove( item.getModelObject().getName() );
                    target.add( CustomFieldsPanel.this ); // Update UI.
                    try {
                        CustomFieldsPanel.this.onChange( target ); // Persists.
                    } catch (Exception ex){
                        feedbackPanel.error( ex.toString() );
                    }
                }
            });
        }
    });
    ...
}
0
source

All Articles