Removing Friends

A community user may desire to remove someone from his friend list. This can be easily implemented through the following Struts action and JSP template:

<form-bean name="friendshipForm" type="com.ndc.community.struts.actions.forms.FriendshipForm"/>
<action path="/friendship/resign"
        name="friendshipForm"
        scope="request"
        type="com.ndc.community.struts.actions.friendship.ResignFriendship">
        <forward name="error" path="/" />
        <forward name="success" path="/" redirect="true" />
</action>

An example JSP template can be as follows:

<html:form action="/friendship/resign">
  <community:user id="currentUser"/>
  <community:user id="targetUser" userId="${param.userId}"/>
  <html:hidden property="userId" value="${currentUser.id}"/>
  <html:hidden property="friendId" value="${targetUser.id}"/>
  <html:submit value="Remove"/>
</html:form>

It may be desirable that the removed person does not get any notification of removal. A different Struts Action can be used to achieve this feature.

<form-bean name="friendshipForm" type="com.ndc.community.struts.actions.forms.FriendshipForm"/>
<action path="/friendship/remove"
        name="friendshipForm"
        scope="request"
        type="com.ndc.community.struts.actions.friendship.RemoveFriendship">
        <forward name="error" path="/" />
        <forward name="success" path="/" redirect="true" />
</action>

The action expects the same set of form properties and thus, the same JSP template can be used with the name of the action.

<html:form action="/friendship/remove">
  <community:user id="currentUser"/>
  <community:user id="targetUser" userId="${param.userId}"/>
  <html:hidden property="userId" value="${currentUser.id}"/>
  <html:hidden property="friendId" value="${targetUser.id}"/>
  <html:submit value="Remove"/>
</html:form>