Template for flagging

Forum provides an action class com.escenic.forum.qual.presentation.SubmitPostingQualification to flag a posting. A JSP tag is also provided to determine whether the user has flagged this posting. Here is an example template to use this Action and JSP tag.

Configuring struts-config.xml

<form-beans>
  <form-bean
      name="com.escenic.forum.qual.presentation.QualificationForm"
      type="com.escenic.forum.qual.presentation.QualificationForm"/>
  </form-beans>

<actions>
  <action
      path="/flag/posting"
      type="com.escenic.forum.qual.presentation.SubmitPostingQualification"
      name="com.escenic.forum.qual.presentation.QualificationForm">
  </action>
</actions>
        

Template for using flagging action

<%@ taglib prefix="qual" uri="http://www.escenic.com/taglib/escenic-content-qualification" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>

<!-- To check whether the user has flagged this posting already -->
<qual:qualInfo id="qualInfoBean"
               objectId="${posting.id}"
               objectType="posting"
               userId="${user.id}"
               qualificationType="flag" />
<c:choose>
    <c:when test="${qualInfoBean != null}">
        This posting is flagged by you!
    </c:when>
    <c:otherwise>

      <!-- Using the action to flag the posting -->
      <html:form action="/flag/posting">
        <html:hidden property="contentId" value="${posting.id}"/>
        <html:hidden property="qualificationType" value="flag"/>
        <html:hidden property="qualificationValue" value="1"/>
        <html:submit value="Flag This!"/>
      </html:form>
    </c:otherwise>
</c:choose>