Adding Postings/Comments/Complaints
Here is a template for displaying form that allows users to add
postings to a forum. The template is at
/template/v0/components/forum/post.jsp
:
<c:if test="${!empty param.forumId}"> <h2>Post a message to forum with ID ${param.forumId}</h2> </c:if> <c:if test="${!empty posting}"> <h3>Post a follow up to this post</h3> </c:if> <html:form action="/insert/posting"> <html:hidden property="com.escenic.context.path.initial" value="/" /> <html:hidden property="targetUrl" value="${pageContext.request.requestURL}"/> <html:hidden property="errorUrl" value="${pageContext.request.requestURL}"/> <html:hidden property="cancelUrl" value="${pageContext.request.requestURL}"/> <html:hidden property="relatedArticleId" value="-1" /> <html:textarea property="body" rows="5" cols="40" /> <html:hidden property="title" value="no title"/> <html:hidden property="email" value="john@example.com"/> <html:hidden property="typeName" value="posting" /> <c:if test="${!empty param.forumId}"> <html:hidden property="forumId" value="${param.forumId}" /> <html:hidden property="parentId" value="-1" /> </c:if> <c:if test="${!empty posting}"> <html:hidden property="forumId" value="${posting.forum.id}" /> <html:hidden property="parentId" value="${posting.id}" /> </c:if> <html:errors property="body" /> <br/> <html:submit /> </html:form>
Here is a template for displaying form that allows users to add
complaints to a posting. The template is at
/template/index.jsp
:
<c:if test="${!empty param.forumId}"> <h2>Post a message to forum with ID ${param.forumId}</h2> </c:if> <c:if test="${!empty posting}"> <h3>Post a complaint to this posting </h3> </c:if> <html:form action="/insert/complaint"> <html:hidden property="com.escenic.context.path.initial" value="/" /> <html:hidden property="targetUrl" value="${pageContext.request.requestURL}"/> <html:hidden property="errorUrl" value="${pageContext.request.requestURL}"/> <html:hidden property="cancelUrl" value="${pageContext.request.requestURL}"/> <html:hidden property="relatedArticleId" value="-1" /> <html:textarea property="body" rows="5" cols="40" /> <html:hidden property="title" value="no title"/> <html:hidden property="email" value="john@example.com"/> <html:hidden property="typeName" value="complaint" /> <c:if test="${!empty param.forumId}"> <html:hidden property="forumId" value="${param.forumId}" /> <html:hidden property="parentId" value="-1" /> </c:if> <c:if test="${!empty posting}"> <html:hidden property="forumId" value="${posting.forum.id}" /> <html:hidden property="parentId" value="${posting.id}" /> </c:if> <html:errors property="body" /> <br/> <html:submit /> </html:form>
The most significant points in the above listing are highlighted and described below:
<html:form action="/insert/posting">
-
The
action
attribute here associates the form with a Struts action path. Thestruts-config-forum.xml
file (see Editing struts-config-forum.xml) specifies that these action paths require aPostingForm
to be submitted for processing by anInsertPostingAction
orAuthenticatedInsertPostingAction
. The rest of the form defines the fields specified byCommentForm
. <html:hidden property="relatedArticleId">
-
The
relatedArticleId
determines whether or not this form is an article comment form. For an ordinary posting, it should be set to-1
as above. For a comment posting, it should be set to the ID of the relevant article.