Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.cdlflex.ui.markup.html.badge;
 
 import java.util.List;
 
A org.apache.wicket.markup.html.panel.GenericPanel that holds a ListView of BadgeListItem. By default, it wraps the link created by BadgeListItem.createLink(java.lang.String) around the Label and Badge created by the other factory methods in BadgeListItem.

By default, the BadgeListItem.createLink(java.lang.String) creates a org.cdlflex.ui.markup.html.link.DummyLink to disable the Link. You can control the link creation by overwriting that method of a specific item.

     <li wicket:id="badges">
       <a wicket:id="link" class="badge-item-link">
         <span wicket:id="label" class="badge-item-label"></span> <span wicket:id="badge"></span>
       </a>
     </li>
 
 
 public class BadgeList extends GenericPanel<List<? extends BadgeListItem>> {
     private static final long serialVersionUID = 1L;
 
     public BadgeList(String id) {
         super(id);
     }
 
     @SuppressWarnings("unchecked")
     public BadgeList(String idList<? extends BadgeListItemlist) {
         super(id, (IModel<List<? extends BadgeListItem>>) new ListModel(list));
     }
 
     public BadgeList(String idIModel<List<? extends BadgeListItem>> model) {
         super(idmodel);
     }
 
     @Override
     protected void onInitialize() {
         super.onInitialize();
 
         add(newBadgeListView("badges"getModel()));
         add(new CssClassNameAppender("badge-list"));
     }
 
     @SuppressWarnings("unchecked")
     public BadgeList add(BadgeListItem item) {
         List<BadgeListItemlist = (List<BadgeListItem>) getModelObject();
         list.add(item);
 
         return this;
     }

    
Factory method for the ListView that uses the given BadgeList instance model (a list of BadgeListItem to render a list of bootstrap badges.

Parameters:
id the component id
model The list model if BadgeListItem to render
Returns:
a new ListView
 
     protected ListView<BadgeListItemnewBadgeListView(String idIModel<List<? extends BadgeListItem>> model) {
         return new ListView<BadgeListItem>(idmodel) {
             private static final long serialVersionUID = 1L;
 
             @Override
             protected void populateItem(ListItem<BadgeListItemitem) {
                 BadgeList.this.populateItem(item);
             }
         };
     }

    
Called by the ListView created by default via newBadgeListView(java.lang.String,org.apache.wicket.model.IModel). It populates the item with the link returned by BadgeListItem.createLink(java.lang.String), to which subsequently the Badge and Label is added.

Parameters:
item the specific list item.
    protected void populateItem(ListItem<BadgeListItemitem) {
        BadgeListItem model = item.getModelObject();
        AbstractLink link = item.getModelObject().createLink("link");
        link.add(model.createBadge("badge"));
        link.add(model.createLabel("label"));
        item.add(link);
    }
New to GrepCode? Check out our FAQ X