Rejecting Friendship Requests

On a community site, a user may not wish to accept all friendship requests to keep some privacy. VCE lets a developer implement this functionality through yet another Struts framework action.

The action declaration can be as follows:

<form-bean name="friendshipForm" type="com.ndc.community.struts.actions.forms.FriendshipForm"/>

<action path="/friendship/decline"
        name="friendshipForm"
        scope="request"
        type="com.ndc.community.struts.actions.friendship.DeclineFriendship">
        <forward name="error" path="/decline-friendship-error.jsp" />
        <forward name="success" path="/" redirect="true" />
</action>

An example JSP that can allow a user to decline a friendship request can be as follows:

<html:form action="/friendship/decline">
  <community:user id="currentUser"/>
  <community:user id="requestingUser" userId="${param.userId}"/>

  <html:hidden property="userId" value="${currentUser.id}"/>
  <html:hidden property="friendId" value="${requestingUser.id}"/>
  <html:submit value="Decline"/>
</html:form>