Skip to content

Commit b8b0f02

Browse files
authored
Merge pull request #17 from wet-boew/13-add-support-for-new-footer
Adding support for new footer
2 parents ef06065 + ef28791 commit b8b0f02

18 files changed

Lines changed: 543 additions & 82 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
## v2.6.0
66

7+
- **IMPORTANT** The GCWeb site footer has been updated to reflect the changes introduced in WET footer version 4. These changes will be applied automatically. For more information, please visit the WET documentation: https://wet-boew.github.io/GCWeb/sites/footers/footers-en.html
78
- [CDTS](https://github.com/wet-boew/cdts-sgdc/) v4.0.47 & [wet-boew](https://github.com/wet-boew/wet-boew) v4.0.56.5
89
- Updated static fallback files
910
- Bug Fixes
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package goc.webtemplate;
2+
3+
public class BannerLink extends Link{
4+
private static final long serialVersionUID = 1L;
5+
6+
private boolean newWindow;
7+
8+
public BannerLink() {}
9+
10+
public BannerLink(String href)
11+
{
12+
this(href, "");
13+
}
14+
15+
public BannerLink(String href, String text)
16+
{
17+
this(href, text, false);
18+
}
19+
20+
public BannerLink(String href, String text, boolean newWindow)
21+
{
22+
super(href, text);
23+
this.newWindow = newWindow;
24+
}
25+
26+
public boolean isNewWindow() {
27+
return newWindow;
28+
}
29+
30+
public void setNewWindow(boolean newWindow) {
31+
this.newWindow = newWindow;
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package goc.webtemplate;
2+
3+
import java.util.List;
4+
5+
public class ContextualFooter {
6+
7+
private String title;
8+
private List<FooterLink> links;
9+
10+
public ContextualFooter() {}
11+
12+
public ContextualFooter(String title, List<FooterLink> links)
13+
{
14+
this.title = title;
15+
this.links = links;
16+
}
17+
18+
public String getTitle() {
19+
return title;
20+
}
21+
22+
public void setTitle(String title) {
23+
this.title = title;
24+
}
25+
26+
public List<FooterLink> getLinks() {
27+
return links;
28+
}
29+
30+
public void setLinks(List<FooterLink> links) {
31+
this.links = links;
32+
}
33+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/InfoBanner.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
public class InfoBanner {
44
private String mainHTML;
5-
private Link link;
6-
private Link button;
5+
private BannerLink link;
6+
private BannerLink button;
77

88
public InfoBanner() {}
99

10-
public InfoBanner(String mainHTML, Link link, Link button)
10+
public InfoBanner(String mainHTML, BannerLink link, BannerLink button)
1111
{
1212
this.mainHTML = mainHTML;
1313
this.link = link;
@@ -22,19 +22,19 @@ public void setMainHTML(String mainHTML) {
2222
this.mainHTML = mainHTML;
2323
}
2424

25-
public Link getLink() {
25+
public BannerLink getLink() {
2626
return link;
2727
}
2828

29-
public void setLink(Link link) {
29+
public void setLink(BannerLink link) {
3030
this.link = link;
3131
}
3232

33-
public Link getButton() {
33+
public BannerLink getButton() {
3434
return button;
3535
}
3636

37-
public void setButton(Link button) {
37+
public void setButton(BannerLink button) {
3838
this.button = button;
3939
}
4040
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/AbstractCoreBean.java

Lines changed: 75 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import goc.webtemplate.Breadcrumb;
1818
import goc.webtemplate.Constants;
19+
import goc.webtemplate.ContextualFooter;
1920
import goc.webtemplate.CustomSearch;
2021
import goc.webtemplate.FooterLink;
2122
import goc.webtemplate.FooterSection;
@@ -32,6 +33,8 @@
3233
import goc.webtemplate.Utility;
3334
import goc.webtemplate.WebAnalyticsInfo;
3435

36+
import static goc.webtemplate.component.JsonRenderer.gson;
37+
3538
import goc.webtemplate.component.jsonentities.AppFooter;
3639
import goc.webtemplate.component.jsonentities.AppTop;
3740
import goc.webtemplate.component.jsonentities.CDTSEnvironment;
@@ -60,19 +63,6 @@
6063
*
6164
*/
6265
public abstract class AbstractCoreBean {
63-
/**
64-
* Object used for JSON serialization. (https://github.com/google/gson)
65-
*
66-
* According to documentation (http://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0)
67-
* and source code, Gson objects are thread-safe.
68-
*/
69-
//NOTE: Doesn't render null values by default, which is what we want
70-
//NOTE: Escapes HTML by default, which is what we want (though URLs still need to be encoded)
71-
//NOTE: Indented output can be obtained by chaining a call to setPrettyPrinting()
72-
private static Gson gson = new com.google.gson.GsonBuilder()
73-
.setFieldNamingPolicy(com.google.gson.FieldNamingPolicy.IDENTITY)
74-
.create();
75-
7666
/**
7767
* Hold the table of CDTS environment configuration objects (loaded the first time it is accessed).
7868
*/
@@ -154,6 +144,9 @@ private enum Themes { GCWEB, GCINTRANET }
154144
private String footerPath = null;
155145
private boolean hidePlaceholderMenu = false;
156146
private InfoBanner infoBanner = null;
147+
private ContextualFooter contextualFooter = null;
148+
private boolean hideMainFooter = false;
149+
private boolean hideCorporateFooter = false;
157150
//-------------------------------------------------------
158151

159152
//-------------------------------------------------------
@@ -1494,6 +1487,63 @@ public void setInfoBanner(InfoBanner value) {
14941487
this.infoBanner = value;
14951488
}
14961489

1490+
/**
1491+
* Returns whether to display a contextual footer band that can display up to 3 links
1492+
*
1493+
* can be overriden programatically.
1494+
*/
1495+
public ContextualFooter getContextualFooter() {
1496+
this.initializeOnce();
1497+
return this.contextualFooter;
1498+
}
1499+
1500+
/**
1501+
* Sets whether to display a contextual footer band that can display up to 3 links
1502+
*
1503+
* can be overriden programatically.
1504+
*/
1505+
public void setContextualFooter(ContextualFooter value) {
1506+
this.contextualFooter = value;
1507+
}
1508+
1509+
/**
1510+
* Returns whether to hide the main footer
1511+
*
1512+
* can be overriden programatically.
1513+
*/
1514+
public boolean getHideMainFooter() {
1515+
this.initializeOnce();
1516+
return this.hideMainFooter;
1517+
}
1518+
1519+
/**
1520+
* Sets whether to hide the main footer
1521+
*
1522+
* can be overriden programatically.
1523+
*/
1524+
public void setHideMainFooter(boolean value) {
1525+
this.hideMainFooter = value;
1526+
}
1527+
1528+
/**
1529+
* Returns whether to hide corporate footer links
1530+
*
1531+
* can be overriden programatically.
1532+
*/
1533+
public boolean getHideCorporateFooter() {
1534+
this.initializeOnce();
1535+
return this.hideCorporateFooter;
1536+
}
1537+
1538+
/**
1539+
* Sets whether to hide corporate footer links
1540+
*
1541+
* can be overriden programatically.
1542+
*/
1543+
public void setHideCorporateFooter(boolean value) {
1544+
this.hideCorporateFooter = value;
1545+
}
1546+
14971547
/**
14981548
* Returns a copy of the breadcrumb list, ready for JSON serialization
14991549
*/
@@ -2010,9 +2060,12 @@ public String getRenderFooter() {
20102060
true, //showFooter,
20112061
this.getShowFeatures(),
20122062
this.buildContactLinks(),
2013-
null, //privacyLink
2014-
null, //termsLink
2015-
JsonValueUtils.getNonEmptyString(this.getLocalPath())
2063+
JsonValueUtils.getFooterLinkContext(this.getPrivacyLink(), true),
2064+
JsonValueUtils.getFooterLinkContext(this.getTermsConditionsLink(), true),
2065+
JsonValueUtils.getNonEmptyString(this.getLocalPath()),
2066+
this.contextualFooter,
2067+
this.hideMainFooter,
2068+
this.hideCorporateFooter
20162069
));
20172070
}
20182071

@@ -2027,9 +2080,12 @@ public String getRenderTransactionalFooter() {
20272080
false, //showFooter
20282081
this.getShowFeatures(),
20292082
this.buildContactLinks(),
2030-
JsonValueUtils.getNonEmptySingleItemLinkList(this.getPrivacyLink()),
2031-
JsonValueUtils.getNonEmptySingleItemLinkList(this.getTermsConditionsLink()),
2032-
JsonValueUtils.getNonEmptyString(this.getLocalPath())
2083+
JsonValueUtils.getFooterLinkContext(this.getPrivacyLink(), false),
2084+
JsonValueUtils.getFooterLinkContext(this.getTermsConditionsLink(), false),
2085+
JsonValueUtils.getNonEmptyString(this.getLocalPath()),
2086+
null, //contextualFooter
2087+
false, //hideMainFooter
2088+
false //hideCorporateFooter
20332089
));
20342090
}
20352091

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package goc.webtemplate.component;
2+
3+
import com.google.gson.Gson;
4+
5+
public final class JsonRenderer {
6+
/**
7+
* Object used for JSON serialization. (https://github.com/google/gson)
8+
*
9+
* According to documentation (http://www.javadoc.io/doc/com.google.code.gson/gson/2.8.0)
10+
* and source code, Gson objects are thread-safe.
11+
*/
12+
//NOTE: Doesn't render null values by default, which is what we want
13+
//NOTE: Escapes HTML by default, which is what we want (though URLs still need to be encoded)
14+
//NOTE: Indented output can be obtained by chaining a call to setPrettyPrinting()
15+
public static Gson gson = new com.google.gson.GsonBuilder()
16+
.setFieldNamingPolicy(com.google.gson.FieldNamingPolicy.IDENTITY)
17+
.create();
18+
}

gocwebtemplate-core/gocwebtemplate-core-base/src/main/java/goc/webtemplate/component/JsonValueUtils.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import goc.webtemplate.Link;
99
import goc.webtemplate.Utility;
1010

11+
import goc.webtemplate.component.jsonentities.FooterLinkContext;
12+
1113
public final class JsonValueUtils {
1214

1315
/**
@@ -107,4 +109,12 @@ public static boolean getBooleanValue(String value, boolean defaultValue)
107109
{
108110
return Utility.isNullOrEmpty(value)? defaultValue: Boolean.parseBoolean(value);
109111
}
112+
113+
/**
114+
* Returns FooterLinkContext value depending on the value of showFooter
115+
* If the link href if null, then a null value is returned
116+
*/
117+
public static FooterLinkContext getFooterLinkContext(FooterLink link, boolean showFooter) {
118+
return Utility.isNullOrEmpty(link.getHref())? null: new FooterLinkContext(showFooter, link);
119+
}
110120
}

0 commit comments

Comments
 (0)