Final question..sorry before the wknd. I see limits to how many conversations are shown on load? Is pagination available too? We'd like to limit it to ten comments visible at a time, but have the ability to page through comments in case there's more than 10 posted.
thanks.
Lambert
Hi Lambert,
I do not believe that pagination is supported out of the box. The external display was kept relatively simple to allow for faster delivery of the content. I will take a look at the code to see if this is a simple or complex customization, and let you know what I find next week.
Have a good weekend,
sorry one more question. how can we change the "date posted" to "minutes ago" in community everywhere?
thanks,
lambert
You'd have to customize the freemarker template community-everywhere-content.ftl and change ${message.modificationDate?date} to ${StringUtils.getTimeFromLong(message.modificationDate.time?long, 1)}
It complains that StringUtils isn't available to this template. Do I have to add it to the communityeverywhere servlet?
thanks,
lambert
Ah, yes. StringUtils is a static class that is automatically added to the freemarker context by webwork. Since community everywhere is its own servlet (outside of webwork), it will have to be added to your properties. Check out JiveFreemarkerManager (populateStatics) method to see how this is done. Basically, you will add the static class StringUtils to your model in the loadProperties method. Alternately, you might be able to load it up using the syntax ${statics['com.jivesoftware.util.StringUtils']}.
Can I just replace FreemarkerManager with JiveFreemarkerManager in the servlet?
=)
Lambert
I've added:
// to get a wrapper around the statics
private static BeansWrapper wrapper = new JiveBeansWrapper();
TemplateHashModel staticModels = wrapper.getStaticModels();
properties.put("StringUtils", staticModels.get("com.jivesoftware.util.StringUtils"));
properties.put("statics", BeansWrapper.getDefaultInstance().getStaticModels());
so that we can grab these utils on the template. adding the calls to:
${statics['com.jivesoftware.util.StringUtils']}.
or
${StringUtils.getTimeFromLong(message.modificationDate.time?long, 1)}
throws an error
Caused by: java.lang.NullPointerException
at com.jivesoftware.base.AuthFactory.getSessionAuthToken(AuthFactory.java:661)
at com.jivesoftware.base.AuthFactory.getSessionUser(AuthFactory.java:678)
at com.jivesoftware.util.DateUtils.<init>(DateUtils.java:69)
at com.jivesoftware.util.StringUtils.getTimeFromLong(StringUtils.java:1583)
I am a currently logged in user. though.. when I remove this call. the comments return correctly.
lambert
You might need to create an auth token and stick it in the session so date utils can be accessed (it's dependent on the user's locale information). You should have the user information in the servlet, so its just a matter of creating a new auth token and sticking it in the session for date utils.
Nick,
Right underneath the props being set for the statics there's this call which set the authtoken into
// Get the user's auth token
AuthToken authToken;
try {
authToken = AuthFactory.getAuthToken(request, response);
}
catch (UnauthorizedException ue) {
authToken = AuthFactory.getAnonymousAuthToken();
}
JiveContext jiveContext = JiveApplication.getContext(authToken);
// load the user from the authtoken
User user = null;
if (!authToken.isAnonymous()) {
try {
user = jiveContext.getUserManager().getUser(authToken.getUserID());
properties.put("user", user);
}
catch (UserNotFoundException e) {
Log.error(
"Could not load user from authToken with userID: " + authToken.getUserID(),
e);
}
}
into the props bag as well. Is this what date util's is looking for?
Lambert
The default constructor for DateUtils looks like this:
public DateUtils() {
HttpServletRequest request = ServletActionContext.getRequest();
User user = AuthFactory.getSessionUser(request);
timeZone = LocaleUtils.getTimeZone(request, user);
locale = LocaleUtils.getUserLocale(request, user);
}
and AuthFactory.getSessionUser(request) simply gets the session for the request and checks for an auth token, which is where the NPE is happening from your previous log.
Starting over, we might be able to do this much easier. What if you ignore StringUtils all together. Since you already have a request object and a user, try simply creating a new DateUtils object with the constructor (request, user). Then add that initialized date utils object to your properties in the community everywhere servlet. From the ftl, simply call the method displayFriendly(date). Together, it would look something like this in the loadProperties method of CommunityEverywhereSerlvet:
properties.put("dateUtils", new DateUtils(request, user));
and in community-everywhere-content.ftl
${dateUtils.displayFriendly(message.modificationDate?date)}
Let me know if that works for you.
this worked fine. thanks. I left the statics beans wrapper just in case we needed any other utils. unless all utils require authentication first.
Lambert
Hi Will,
Any updates on whether pagination is supported for CE?
Thanks!
Hi,
This is still logged as a new feature request internally, but is not currently scheduled for a release.