Hi,
I would like to count forum entries every time they are seen by users.
I currently made the count in pages.xml:
<page view-id="/entry.show.xhtml" action="#{forumEntryAction.countView()}">
</page>
and bean:
@RequestParameter
private Integer entryId;
@Create
public void init()
{
if (entryId != null)
{
forumEntry = forumDAO.getForumEntry(entryId);
}
else
{
forumEntry = new ForumEntry();
}
}
public void countView()
{
forumEntry.setViews(forumEntry.getViews() + 1);
myDB.persist(forumEntry);
}
My problem is that, this page has ajax regions causing it to be re-rendered many times. I need to avoid the count on a postback (like ajax requests).
Is there a way to tell the action method not to be called on a postback?
Is there a way of detecting postback in Seam?
Is there a better way of doing what I want to achieve?
Thanks,
Guy.