Last active
December 19, 2015 11:59
Revisions
-
wizche renamed this gist
Jul 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wizche created this gist
Jul 8, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ LinkLabel myLabel = new LinkLabel("description", "First ${link} second", "my link", new ILinkListener() { private static final long serialVersionUID = 1L; @Override public void onLinkClicked() { // Your desired onClick action } }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ <wicket:panel> <span wicket:id="first"></span> <a wicket:id="link"><span wicket:id="linkLabel"></span></a> <span wicket:id="second"></span> </wicket:panel> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ public class LinkLabel extends Panel { private static final long serialVersionUID = 1L; public LinkLabel(String id, String model, String linkName, ILinkListener linkListener) { super(id); setRenderBodyOnly(true); String[] split = model.split("\\$\\{link\\}"); if (split.length == 2) { Label first = new Label("first", split[0]); Label second = new Label("second", split[1]); add(first); add(second); add(generateLink(linkListener, linkName)); } else if (split.length == 1) { Label first = new Label("first", split[0]); Label second = new Label("second"); second.setVisible(false); add(first); add(second); add(generateLink(linkListener, linkName)); } else { throw new UnsupportedOperationException( "LinkLabel needs the ${link} placeholder!"); } } private Link<?> generateLink(final ILinkListener linkListener, String linkName) { Label linkLabel = new Label("linkLabel", linkName); Link<String> link = new Link<String>("link") { private static final long serialVersionUID = 1L; @Override public void onClick() { linkListener.onLinkClicked(); } }; link.add(linkLabel); return link; } }