Skip to content

Commit 2bb4168

Browse files
author
Jan Vorwerk
committed
Added support for href in the MaterialLink so that an app can embrace the GWT history scheme.
1 parent f1ef9c2 commit 2bb4168

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/main/java/gwt/material/design/client/ui/MaterialLink.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class MaterialLink extends FocusPanel {
3030

3131
protected HTMLPanel panel = new HTMLPanel("");
3232
private String text = "";
33+
private String href;
3334
private String icon = "";
3435
private String iconPosition = "";
3536
private String textColor = "";
@@ -98,6 +99,15 @@ public void setText(String text) {
9899
generateLink();
99100
}
100101

102+
public String getHref() {
103+
return href;
104+
}
105+
106+
public void setHref(String href) {
107+
this.href = href;
108+
generateLink();
109+
}
110+
101111
public String getFontSize() {
102112
return fontSize;
103113
}
@@ -119,10 +129,14 @@ public void setIconPosition(String iconPosition) {
119129
public void generateLink() {
120130
this.clear();
121131
String iconMarkup = "";
132+
String hrefMarkup = "";
122133
if (!icon.isEmpty()) {
123134
iconMarkup = "<i class='" + icon + " " + iconPosition + "'></i>";
124135
}
125-
panel = new HTMLPanel("<a class='" + textColor + "-text'>" + iconMarkup + " " + text + "</a>");
136+
if (this.href != null) {
137+
hrefMarkup = "href='" + href + "' ";
138+
}
139+
panel = new HTMLPanel("<a " + hrefMarkup + "class='" + textColor + "-text'>" + iconMarkup + text + "</a>");
126140
panel.getElement().getStyle().setCursor(Cursor.POINTER);
127141
this.add(panel);
128142
}

0 commit comments

Comments
 (0)