Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/Attic/ApplicationResources.properties,v
diff -u -r1.1 -r1.2
--- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ApplicationResources.properties 7 Jun 2005 05:50:05 -0000 1.1
+++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ApplicationResources.properties 15 Jun 2005 05:40:42 -0000 1.2
@@ -12,8 +12,8 @@
basic.content=Content:
#Instructions Page
-instructions.onlineInstructions=Online Instructions
-instructions.offlineInstructions=Offline Instructions
+instructions.onlineInstructions=Online Instructions:
+instructions.offlineInstructions=Offline Instructions:
#buttons
button.cancel=Cancel
Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java,v
diff -u -r1.1 -r1.2
--- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 7 Jun 2005 05:50:05 -0000 1.1
+++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 15 Jun 2005 05:40:42 -0000 1.2
@@ -21,7 +21,6 @@
package org.lamsfoundation.lams.tool.noticeboard.web;
-import java.util.Date;
import java.util.Map;
import java.util.HashMap;
@@ -39,6 +38,7 @@
import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService;
import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy;
+import org.lamsfoundation.lams.tool.noticeboard.util.NbAuthoringUtil;
@@ -69,14 +69,18 @@
map.put(NoticeboardConstants.BUTTON_INSTRUCTIONS, "instructions");
map.put(NoticeboardConstants.BUTTON_DONE, "done");
map.put(NoticeboardConstants.BUTTON_SAVE, "save");
+
return map;
}
/**
* Forwards to the basic page.
*/
public ActionForward basic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
- return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
+
+ copyRichTextOnlineInstrnValue(request, (NbAuthoringForm)form);
+ copyRichTextOfflineInstrnValue(request, (NbAuthoringForm)form);
+ return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
}
/**
@@ -92,15 +96,19 @@
*/
public ActionForward instructions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
- return mapping.findForward(NoticeboardConstants.INSTRUCTIONS_PAGE);
+ copyRichTextContentValue(request, (NbAuthoringForm)form);
+
+ return mapping.findForward(NoticeboardConstants.INSTRUCTIONS_PAGE);
}
/**
* Online/Offline instructions entered, form values saved and forward to the basic page.
*/
public ActionForward done(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
- return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
+ copyRichTextOnlineInstrnValue(request, (NbAuthoringForm)form);
+ copyRichTextOfflineInstrnValue(request, (NbAuthoringForm)form);
+ return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
}
/**
@@ -116,43 +124,91 @@
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException {
NbAuthoringForm nbForm = (NbAuthoringForm)form;
-
- //retrieve the service
INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
-
- //retrieve the id
Long content_id = (Long)request.getSession().getAttribute(NoticeboardConstants.TOOL_CONTENT_ID);
- if (content_id == null)
- {
- String error = "Tool content id missing. Unable to continue.";
-
- throw new NbApplicationException(error);
- }
+ copyRichTextContentValue(request, nbForm);
+ copyRichTextOnlineInstrnValue(request, nbForm);
+ copyRichTextOfflineInstrnValue(request, nbForm);
- // retrieve the content
- NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id);
-
- //update the noticeboard object
- /* nbContent.setNbContentId(content_id);
- nbContent.setTitle(nbForm.getTitle());
- nbContent.setContent(nbForm.getContent());
- nbContent.setOnlineInstructions(nbForm.getOnlineInstructions());
- nbContent.setOfflineInstructions(nbForm.getOfflineInstructions());
- nbContent.setDateUpdated(new Date(System.currentTimeMillis()));
- */
+ //throws exception if the content id does not exist
+ checkContentId(content_id);
+ NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id);
nbForm.copyValuesIntoNbContent(nbContent);
- //save the noticeboard object into the db
nbService.updateNoticeboard(nbContent);
return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
}
+ /**
+ * The form bean property content
is set
+ * with the value of richTextContent
+ * @param request
+ * @param form
+ */
+ private void copyRichTextContentValue(HttpServletRequest request, NbAuthoringForm form)
+ {
+ String content = (String)request.getParameter(NoticeboardConstants.RICH_TEXT_CONTENT);
+ if(content != null)
+ {
+ form.setContent(content);
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_CONTENT, content);
+
+ }
+ }
+ /**
+ * The form bean property onlineInstructions
is set
+ * with the value of richTextOnlineInstructions
+ * @param request
+ * @param form
+ */
+ private void copyRichTextOnlineInstrnValue(HttpServletRequest request, NbAuthoringForm form)
+ {
+ String onlineInstruction = (String)request.getParameter(NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN);
+ if(onlineInstruction != null)
+ {
+ form.setOnlineInstructions(onlineInstruction);
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN, onlineInstruction);
+
+ }
+ }
+ /**
+ * The form bean property offlineInstructions
is set
+ * with the value of richTextOfflineInstructions
+ * @param request
+ * @param form
+ */
+ private void copyRichTextOfflineInstrnValue(HttpServletRequest request, NbAuthoringForm form)
+ {
+ String offlineInstruction = (String)request.getParameter(NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN);
+ if(offlineInstruction != null)
+ {
+ form.setOfflineInstructions(offlineInstruction);
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN, offlineInstruction);
+
+ }
+ }
+ /**
+ * It is assumed that the contentId is passed as a http parameter
+ * if the contentId is null, an exception is thrown, otherwise proceed as normal
+ *
+ * @param contentId the toolContentId
to check
+ */
+ private void checkContentId(Long contentId)
+ {
+ if (contentId == null)
+ {
+ String error = "Tool content id missing. Unable to continue.";
+
+ throw new NbApplicationException(error);
+ }
+ }
+
@@ -162,4 +218,5 @@
+
}
\ No newline at end of file
Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java,v
diff -u -r1.2 -r1.3
--- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java 8 Jun 2005 03:56:52 -0000 1.2
+++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java 15 Jun 2005 05:40:42 -0000 1.3
@@ -31,7 +31,6 @@
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent;
-import org.lamsfoundation.lams.tool.noticeboard.util.NbAuthoringUtil;
//import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants;
@@ -62,10 +61,6 @@
private String method;
private String toolContentId;
-
-
-
-
/**
* @return Returns the content.
*/
Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/Attic/NbAuthoringStarterAction.java,v
diff -u -r1.1 -r1.2
--- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringStarterAction.java 7 Jun 2005 05:50:05 -0000 1.1
+++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringStarterAction.java 15 Jun 2005 05:40:42 -0000 1.2
@@ -49,6 +49,8 @@
import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException;
+
+
/**
* Creation Date: 19-05-05
*
@@ -89,9 +91,10 @@
throw new NbApplicationException(error);
}
- request.getSession().setAttribute(NoticeboardConstants.TOOL_CONTENT_ID, contentId);
+ NbAuthoringUtil.cleanSession(request);
-
+ request.getSession().setAttribute(NoticeboardConstants.TOOL_CONTENT_ID, contentId);
+
/*
* Retrieve the Service
*/
@@ -118,6 +121,9 @@
//initialise the values in the form, so the values will be shown in the jsp
nbForm.populateFormWithNbContentValues(nbContentNew);
+ setValueForRichTextContent(request, nbForm);
+ setValueForRichTextOnlineInstrn(request, nbForm);
+ setValueForRichTextOfflineInstrn(request, nbForm);
}
else
{
@@ -126,6 +132,10 @@
nbForm.populateFormWithNbContentValues(nb);
+ setValueForRichTextContent(request, nbForm);
+ setValueForRichTextOnlineInstrn(request, nbForm);
+ setValueForRichTextOfflineInstrn(request, nbForm);
+
}
return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
@@ -146,7 +156,48 @@
return true;
}
+ /**
+ * If the content
attribute of the noticeboard object is NULL
+ * then the session attribute richTextContent
is set to an empty string.
+ * Otherwise, richTextContent
takes on the the value of content
+ * and is stored in the session
+ * @param request
+ * @param form
+ */
+ private void setValueForRichTextContent(HttpServletRequest request, NbAuthoringForm form)
+ {
+ if (form.getContent() != null)
+ {
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_CONTENT, form.getContent());
+ }
+ else
+ {
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_CONTENT, "");
+ }
+ }
+ private void setValueForRichTextOnlineInstrn(HttpServletRequest request, NbAuthoringForm form)
+ {
+ if (form.getOnlineInstructions() != null)
+ {
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN, form.getOnlineInstructions());
+ }
+ else
+ {
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN, "");
+ }
+ }
+ private void setValueForRichTextOfflineInstrn(HttpServletRequest request, NbAuthoringForm form)
+ {
+ if (form.getOfflineInstructions() != null)
+ {
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN, form.getOfflineInstructions());
+ }
+ else
+ {
+ request.getSession().setAttribute(NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN, "");
+ }
+ }
}
\ No newline at end of file