掲示板
Freemarker getThemeSetting Errors
7年前 に Gilad Reich によって更新されました。
Freemarker getThemeSetting Errors
New Member 投稿: 10 参加年月日: 16/07/21 最新の投稿
Hey everyone,
So I've been doing some code conversion from velocity to freemarker to a theme template and encounter some weird issue while retrieving setting.
This is how it looks like:
Getting error while trying to access the themeDisplay object:
What's wrong here?
In the init.ftl the theme_display already has been intialized:
theme_display = themeDisplay
which is themeDisplay object that has 2 methods inside for retrieving setting(liferay 7 source code):
I also tried accessing directly into themeDisplay object by:
Thanks in advance for the help!
Regards,
Gilad Reich
So I've been doing some code conversion from velocity to freemarker to a theme template and encounter some weird issue while retrieving setting.
This is how it looks like:
<#assign myObject = theme_display.getThemeSetting("some-string") />
<#-- My Booleans -->
<#assign myObjectFlag = getterUtil.getBoolean(myObject) />
Getting error while trying to access the themeDisplay object:
Caused by: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:_==> theme_display.getThemeSetting("some-string") [in template "lets-theme_SERVLET_CONTEXT_/templates/init_custom.ftl" at line 35, column 31]__----_Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??_----__----_FTL stack trace ("~" means nesting-related):_ - Failed at: userbarCartLink = theme_display.getTh... [in template "lets-theme_SERVLET_CONTEXT_/templates/init_custom.ftl" at line 35, column 5]_ - Reached through: #assign-container [in template "lets-theme_SERVLET_CONTEXT_/templates/init_custom.ftl" at line 33, column 1]_ - Reached through: #include "${full_templates_path}/init... [in template "lets-theme_SERVLET_CONTEXT_/templates/init.ftl" at line 355, column 1]_ - Reached through: #include init [in template "lets-theme_SERVLET_CONTEXT_/templates/portal_normal.ftl" at line 3, column 1]_---- [Sanitized]
What's wrong here?
In the init.ftl the theme_display already has been intialized:
theme_display = themeDisplay
which is themeDisplay object that has 2 methods inside for retrieving setting(liferay 7 source code):
public String getThemeSetting(String key) {
Theme theme = getTheme();
String device = theme.getDevice();
Layout layout = getLayout();
return layout.getThemeSetting(key, device);
}
public Properties getThemeSettings() {
Theme theme = getTheme();
Properties properties = new Properties();
Map<string, themesetting> themeSettings = theme.getSettings();
for (Map.Entry<string, themesetting> entry : themeSettings.entrySet()) {
String key = entry.getKey();
ThemeSetting themeSetting = entry.getValue();
String value = null;
if (themeSetting.isConfigurable()) {
value = getThemeSetting(key);
}
else {
value = themeSetting.getValue();
}
if (value != null) {
properties.put(key, value);
}
}
return properties;
}</string,></string,>
I also tried accessing directly into themeDisplay object by:
<#assign myObject = themeDisplay.getThemeSetting("some-string") />
And that didn't work too.Thanks in advance for the help!
Regards,
Gilad Reich
7年前 に Gilad Reich によって更新されました。
RE: Freemarker getThemeSetting Errors
New Member 投稿: 10 参加年月日: 16/07/21 最新の投稿
I forgot to mention that I'm modifying the init_custom.ftl template file using Liferay 7 and this is how the code looks like as velocity and I'm trying to get it work as freemarker:
Note that it works as velocity, but as freemarker throws an error.
#set($myObject = $theme.getSetting("some-string"))
#set($myObjectFlag = $getterUtil.getBoolean($myObject))
Note that it works as velocity, but as freemarker throws an error.
7年前 に Gilad Reich によって更新されました。
RE: Freemarker getThemeSetting Errors
New Member 投稿: 10 参加年月日: 16/07/21 最新の投稿
Strangely though, but i solved it by inserting the settings that are defined in init_custom.ftl inside the liferay-look-and-feel.xml under settings.
Seems as freemarker does not allow referencing variables to null comparing to velocity which is explaining why i got this exception:
freemarker.core.InvalidReferenceException
Hopefully that helps someone.
Seems as freemarker does not allow referencing variables to null comparing to velocity which is explaining why i got this exception:
freemarker.core.InvalidReferenceException
Hopefully that helps someone.
6年前 に Marwen Bta によって更新されました。
RE: Freemarker getThemeSetting Errors
New Member 投稿: 9 参加年月日: 17/10/15 最新の投稿Gilad Reich:
Strangely though, but i solved it by inserting the settings that are defined in init_custom.ftl inside the liferay-look-and-feel.xml under settings.
Seems as freemarker does not allow referencing variables to null comparing to velocity which is explaining why i got this exception:
freemarker.core.InvalidReferenceException
Hopefully that helps someone.
Hello,
I am facing the same problem. what Theme did you use and how did you get this error?
The issue I have freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
FreeMarker template error:The following has evaluated to null or missing:==> taglibLiferay [in template "inspinia-theme_SERVLET_CONTEXT_/templates/top_header.ftl" at line 36, column 35]
----Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??----
----FTL stack trace ("~" means nesting-related): - Failed at: ${taglibLiferay.language("fm", null, ... [in template "inspinia-theme_SERVLET_CONTEXT_/templates/top_header.ftl" at line 36, column 33] - Reached through: #include "${full_templates_path}/top_... [in template "inspinia-theme_SERVLET_CONTEXT_/templates/portal_normal.ftl" at line 96, column 49]----
...
Caused by: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:_==> taglibLiferay [in template "inspinia-theme_SERVLET_CONTEXT_/templates/top_header.ftl" at line 36, column 35]__----_Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??_----__----_FTL stack trace ("~" means nesting-related):_ - Failed at: ${taglibLiferay.language("fm", null, ... [in template "inspinia-theme_SERVLET_CONTEXT_/templates/top_header.ftl" at line 36, column 33]_ - Reached through: #include "${full_templates_path}/top_... [in template "inspinia-theme_SERVLET_CONTEXT_/templates/portal_normal.ftl" at line 96, column 49]_----
Is this an issue in the theme it self?