001    package net.databinder.components;
002    
003    import org.apache.wicket.Component;
004    import org.apache.wicket.markup.html.link.Link;
005    import org.apache.wicket.model.IModel;
006    
007    /**
008     * Displays a list of links to set the model of a target component. The panel renders to an
009     * unordered list of class <tt>source-list</tt>. 
010     * @author Nathan Hamblen
011     */
012    public class ModelSourceListPanel extends SourceListPanel {
013            private Component target;
014            /**
015             * Creates list panel.
016             * @param id component id
017             * @param target sets model of this component
018             * @param bodyProperty object property for link body text
019             * @param listModel list of entities to render
020             */
021            public ModelSourceListPanel(String id, Component target, String bodyProperty, IModel listModel ) {
022                    super(id, bodyProperty, listModel);
023                    this.target = target;
024            }
025            /** Called from super-class to construct source links. Note: subclasses my override
026             * to add attribute modifiers to the ModelSourceLink object constructed here, for example. */
027            @Override
028            protected Link sourceLink(String id, IModel model) {
029                    return new ModelSourceLink("link", target, model) {
030                            @Override
031                            public void onClick() {
032                                    ModelSourceListPanel.this.onClick(this);
033                                    super.onClick();
034                            }
035                    };
036            }
037            
038            /**
039             * Called before the default ModelSourceLink's onClick. Base impl does nothing.
040             * @param link component that was clicked
041             */
042            protected void onClick(ModelSourceLink link) { }
043    }