-
Re: Hello World Widget tutorial
donaldrivard Feb 28, 2011 6:23 AM (in response to DoughBoy526)Are you getting any errors logged? Are you sure that the template is not being loaded?
If you are not sure, I would make the template as simple as possible to make sure that it is at least being loaded.
<#-- Use the widget's greetUser property to define the greeting style. -->
<#if greetUser>
<#assign greeting = "Hello " + userName + "!">
<#else>
<#assign greeting = "Hello World!">
</#if><p class="gobig">${greeting} Welcome to the ${communityName} community!</p>
-
Re: Hello World Widget tutorial
DoughBoy526 Feb 28, 2011 8:04 AM (in response to donaldrivard)Thank you for the response. My log does return errors:Feb 2011 09:38:30,535 [http-127.0.0.1-9001-1] [096FE0EFE6D770671395080EB0FA19AA.:admin] ERROR freemarker.runtime -Method public abstract java.lang.String com.jivesoftware.community.widget.view.WidgetRenderer.renderPreview(com.jivesoftware.community.widget.WidgetContext,com.jivesoftware.community.widget.Widget$ContainerSize) threw an exception when invoked on com.jivesoftware.community.widget.ext.impl.DefaultExtWidgetProvider$DefaultWidgetRenderer@632843c7The problematic instruction:----------==> ${widgetRenderer.renderPreview(widgetContext, enums["com.jivesoftware.community.widget.Widget$ContainerSize"].SMALL)} [on line 6, column 5 in template/global/include/preview-widget.ftl]----------Java backtrace for programmers:----------freemarker.template.TemplateModelException: Method public abstract java.lang.String com.jivesoftware.community.widget.view.WidgetRenderer.renderPreview(com.jivesoftware.community.widget.WidgetContext,com.jivesoftware.community.widget.Widget$ContainerSize) threw an exception when invoked on com.jivesoftware.community.widget.ext.impl.DefaultExtWidgetProvider$DefaultWidgetRenderer@632843c7Thank you for the response. My log does return errors:
--
Feb 2011 09:38:30,535 [http-127.0.0.1-9001-1] [096FE0EFE6D770671395080EB0FA19AA.:admin] ERROR freemarker.runtime -
Method public abstract java.lang.String com.jivesoftware.community.widget.view.WidgetRenderer.renderPreview(com.jivesoftware.community.widget.WidgetContext,com.jivesoftware.community.widget.Widget$ContainerSize) threw an exception when invoked on com.jivesoftware.community.widget.ext.impl.DefaultExtWidgetProvider$DefaultWidgetRenderer@632843c7
The problematic instruction:
----------
==> ${widgetRenderer.renderPreview(widgetContext, enums["com.jivesoftware.community.widget.Widget$ContainerSize"].SMALL)} [on line 6, column 5 in template/global/include/preview-widget.ftl]
----------
Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public abstract java.lang.String com.jivesoftware.community.widget.view.WidgetRenderer.renderPreview(com.jivesoftware.community.widget.WidgetContext,com.jivesoftware.community.widget.Widget$ContainerSize) threw an exception when invoked on com.jivesoftware.community.widget.ext.impl.DefaultExtWidgetProvider$DefaultWidgetRenderer@632843c7
--
I also tried the simple ftl file code that you included in your response. Same error.
-
Re: Hello World Widget tutorial
donaldrivard Feb 28, 2011 11:32 AM (in response to DoughBoy526)The error:
The problematic instruction:
----------
==> ${widgetRenderer.renderPreview(widgetContext, enums["com.jivesoftware.community.widget.Widget$ContainerSize"].SMALL)} [on line 6, column 5 in template/global/include/preview-widget.ftl]
----------
Indicates that there is an issue with the line:
<#if containerSize == enums['com.jivesoftware.community.widget.Widget$ContainerSize'].SMALL>
If you want to check the container size in a template I would add the ContainerSize to the properties
Map props.put("size", size);
Map props.put("ContainerSize", ContainerSize);
and check
<#if size == ContainerSize.LARGE>
I am not sure but I do not see where containerSize is added to the template scope. I can see where this code is used in some of the Jive core templates. They must be adding that object to the scope.
Also for my test example are you sure that you removed that line from the simple template that i suggested?
<#-- Use the widget's greetUser property to define the greeting style. -->
<#if greetUser>
<#assign greeting = "Hello " + userName + "!">
<#else>
<#assign greeting = "Hello World!">
</#if><p class="gobig">${greeting} Welcome to the ${communityName} community!</p>
If so it maybe possible that your instance is caching the template, as that line was removed.
-
Re: Hello World Widget tutorial
DoughBoy526 Feb 28, 2011 11:42 AM (in response to donaldrivard)I am willing to believe anything, but based on the problematic instruction:
----------
==> ${widgetRenderer.renderPreview(widgetContext, enums["com.jivesoftware.community.widget.Widget$ContainerSize"].SMALL)} [on line 6, column 5 in template/global/include/preview-widget.ftl]
----------
it appears to be using a completely different ftl file than the one I provided (mine was called "HelloWorldWidget.ftl"). I presume this is a generic ftl that the widget defers to in the event of not having an ftl (since ftl's are optional). Is this presumption correct?
I have managed to achieve some results by completely ignoring the ftl and doing all the logic in the java method, but I would really like to get this working "the right way."
and yes, I am absolutely sure that I removed that line... it could be cached, but I would think that the apprestart would clear that out... I have also tried refreshing the page and different browsers to confirm the local cache is not the problem.
-
Re: Hello World Widget tutorial
donaldrivard Feb 28, 2011 12:34 PM (in response to DoughBoy526)You are 100% correct. Disregard all the useless typing I added . I have not seen that error in my widget development.
What I can tell you from my experiences is that if the plugin cannot find the template I get an error indicating that it cannot load the template.
I have never built a widget without an UI / template so I am not sure about the fallback. I have also never checked for the container size in a template, I have done the check in the widget code, 1 template for each size.
if(widgetContext.isEdit()){
output.append(applyFreemarkerTemplate(widgetContext, size, EDIT_TEMPLATE));
return output.toString();
}
//choose the appropriate render template according to the size
if (size == ContainerSize.LARGE) {
output.append(applyFreemarkerTemplate(widgetContext, size, LARGE_FREEMARKER_TEMPLATE));
} else {
output.append(applyFreemarkerTemplate(widgetContext, size, SMALL_FREEMARKER_TEMPLATE));
}
Are you building this with maven? Under the target directory do you see the example/resources/HelloWorldWidget.ftl? Have you debugged into the HelloWorldWidget class, setting a break point on the render method tosee if you template is being loaded?
Also my 2 cents, putting all the logic in a java class is not necessarily wrong, and putting the logic in the template is not necessarily the "right way". I prefer to put as much logic in java and let the template code be as simple as possible. Rendering UI objects, instead of determinig which UI objects to render. Just my 2 cents.
-
Re: Hello World Widget tutorial
DoughBoy526 Mar 1, 2011 2:46 PM (in response to donaldrivard)I never did figure this out. I was eventually able to work around ftl's completely. I can't use the big/small, but meh, it's not that big a deal to me. The web services were my real goal and those are working just fine.
Thanks Donald for helping me work through (or around) the issue.
-
Re: Hello World Widget tutorial
NathanielElliott Nov 12, 2011 4:25 PM (in response to DoughBoy526)Any new solution?
-
Re: Hello World Widget tutorial
462739 Nov 4, 2014 10:59 PM (in response to NathanielElliott)Hi,
Can anyone please give the same example with soy template instead of Freemarker
-
-
-
-
-
-
-