Sign in

E-mail *, (xx@domain.com)
Password *

Register | Forgot password

Number of forum topics is cached, is SSI the solution?

The "WCB: JSP front-end design" forum contains threads on issues that are related to JSP front-end design while programming a WCB (WebManager Component Bundle). The Presentation & Element component contain JSPs that will be used for front-end rendering. Ask your questions related to these JSPs here. Some example topics: integration of AJAX, use of the taglibs, how to handle multiple websites, and so forth.

Answered
Not marked as answered yet

Forums  >  WCB: JSP Front-end design  >  Number of forum topics is cached, is SSI the solution?


Author Number of forum topics is cached, is SSI the solution?
Jan van Rossum


Posts: 4

Posted: 11-01-2010 14:25

We are allowing users to post comments to articles / media items.
Posting comments is made possible by the discussion / forum functionality in GX.
When displaying a mediaItem, we are also showing the number of comments posted to it.

This is currently done by getting the length of the forum topics for the current mediaItem:

$--accolade open--fn:length(mediaItem.current.forum.topics)--accolade close--


This works perfectly.... without caching.

When caching is enabled the following happens:
1. User posts a new comment to an article
2. The new comment is shown in the articles discussion / forum section
3. The number of comments is not updated in the article / media item content itself
4. The number of comments is also not updated in media collection overviews

This behavior is expected: the media item content and media collection are only rebuilt (thrown out of the cache) when a media item changes. Still the number of comments should be updated when a new comment is posted.

How can you let this “forum topic counter” be updated when a new comment is posted?

Should the whole media item be removed from cache when a new comment is posted? This would have some performance impact...

A more elegant solution would be that only the counter is removed from cache. Can this be achieved by making the counter a SSI that listens to the cache updates for the forum?

We have tried the following SSI solution:
1. Create a “topic count” presentation which only displays the number of topics
2. Set a SSI presentation for this “topic count” presentation
3. Render this presentation in the media item content or media collection presentations

After some code wrestling we came with the following...

mediaCollectionElement.jspf

...
<c:set var="currentMediaItem" value="$--accolade open--mediaCollectionElement.mediaItems[index]--accolade close--" ></c>
...
<wm:render presentationName="WPG Forum Topic Count" mediaItem="$--accolade open--currentMediaItem--accolade close--" ></wm>
...



mediaItemContent.jspf

...
<c:set var="mediaItem" value="$--accolade open--presentationcontext.mediaItem--accolade close--" ></c>
...
<wm:render presentationName="Forum Topic Count" mediaItem="$--accolade open--mediaItem--accolade close--" ></wm>
...



forumTopicCount.xml

<presentation>
<name>Forum Topic Count</name>
<display-name>Forum Topic Count</display-name>
<scope>Forum</scope>
<ssi>
<presentation>forumTopicCountSsi</presentation>
</ssi>
</presentation>



forumTopicCountSsi.jspf

<%@ page language="java" session="false" buffer="none" %>
<%@ taglib uri="http://www.gx.nl/taglib/wm" prefix="wm" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<c:set var="passOn" value="cachetimeout,forum" ></c>

<wm:link var="ssiLink"
ssiObjectId="$--accolade open--mediaItem.current.forumSettings.id--accolade close--" ssiObjectClassName="nl.gx.webmanager.cms. forum.ForumSettings"
cachetimeout="1" forum="$--accolade open--mediaItem.current.forum.id--accolade close--"
passOn="$--accolade open--passOn--accolade close--" ></wm>

$--accolade open--ssiLink.ssiTag--accolade close--



forumTopicCount.jspf

<%@ page language="java" session="false" buffer="none" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.gx.nl/taglib/wm" prefix="wm" %>

<wm:object var="forum" objectId="$--accolade open--param.forum--accolade close--" objectType="Forum" ></wm>

$--accolade open--fn:length(forum.topics)--accolade close--



The mediaItem variable should be passed down to the SSI presentation which in turn passes the mediaItem ID on to the forumTopicCount presentation.

Without the SSI presentation, the number of topics displays perfectly.
With SSI, it doesn’t display anything.

We have tried SSI debug on the article page / media item content page. The counter is called by the following SSI url:

/web/show?id=83433&langid=43&cachetimeout=1&elementHolder=83435&forum=4&ssiObjectClassName=nl.gx.webmanager.cms.forum.ForumSettings&ssiObjectId=83431

83433 is the id of the “Article Show on” page.
cachetimeout=1 is added for debugging reasons, in the end the cache should be timed out by the ssiObject right?

Getting this SSI URL with the browser returns a totally empty page.
The system log does not print any error stack traces while getting this URL, not even on the Finest Log Level.

We get the same results when caching is turned on and when it’s off.
We are using WebManager 9.8.2

How can we proceed debugging?
Are we building the right SSI link here?

Above all: thanks for reading this and hopefully you can help a fellow developer out.

Jan van Rossum


Posts: 4

Posted: 11-01-2010 15:14

Sorry for the messy code.
Can't seem to post accolades ({) (}) in my previous post...
I've used --accolade open-- and --accolade close-- instead.

Back to top

New message: "Number of forum topics is cached, is SSI the solution?"
Message:
bold boitalicd underline url quote code smile cool eek grin mad razz sad wink
 
© 2012 GX Software B.V.

Disclaimer

This website (Connect.gxsoftware.com) may discuss or contain opinions, (sample) coding, software or other information that does not include GX official interfaces, instructions or guidelines and therefore is not supported by GX. Changes made based on this information are not supported.  GX will not be held liable for any damages caused by using or misusing the information, software, instructions, code or methods suggested on this website, and anyone using these methods does so at his/her own risk. GX offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this website, including any liability resulting from incompatibility between the content of this website and the materials and services offered by GX. By using this website you will not hold, or seek to hold, GX responsible or liable with respect to the content of this website.