Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r7fd19e98ed4243d9308a3de32c66c765dc78b886 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 Binary files differ Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -rdae3132565c3c78f450020b352f8f21e98e202a2 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision dae3132565c3c78f450020b352f8f21e98e202a2) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -677,4 +677,6 @@ label.like=Like label.dislike=Dislike label.no.comments=No Comments +label.newest.first=Newest First +label.top.comments=Top Comments #======= End labels: Exported 439 labels for en AU ===== Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rf65bf8d775c89d19993d672813a4af9f95266267 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision f65bf8d775c89d19993d672813a4af9f95266267) +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -668,4 +668,6 @@ label.like=Like label.dislike=Dislike label.no.comments=No Comments +label.newest.first=Newest First +label.top.comments=Top Comments #======= End labels: Exported 439 labels for en AU ===== Index: lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java =================================================================== diff -u -r25e1ec09bef9772ea3a274a6ba5127cbc70d4f16 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java (.../CommentConstants.java) (revision 25e1ec09bef9772ea3a274a6ba5127cbc70d4f16) +++ lams_central/src/java/org/lamsfoundation/lams/comments/CommentConstants.java (.../CommentConstants.java) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -42,11 +42,12 @@ public static final String ATTR_STATUS = "status"; public static final String ATTR_LIKE_AND_DISLIKE = "likeAndDislike"; public static final String ATTR_READ_ONLY = "readOnly"; - + public static final String ATTR_SORT_BY = "sortBy"; // 0 date, 1 likes + // for paging long topics & inlining reply public static final String PAGE_LAST_ID = "pageLastId"; - public static final String PAGE_SIZE = "size"; - public static final int DEFAULT_PAGE_SIZE = 2; + public static final String PAGE_SIZE = "pageSize"; + public static final int DEFAULT_PAGE_SIZE = 5; public static final String ATTR_NO_MORE_PAGES = "noMorePages"; public static final int MAX_BODY_LENGTH = 5000; Index: lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java =================================================================== diff -u -r25e1ec09bef9772ea3a274a6ba5127cbc70d4f16 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java (.../CommentAction.java) (revision 25e1ec09bef9772ea3a274a6ba5127cbc70d4f16) +++ lams_central/src/java/org/lamsfoundation/lams/comments/web/CommentAction.java (.../CommentAction.java) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -141,6 +141,8 @@ String mode; boolean likeAndDislike; boolean readOnly; + Integer pageSize; + Integer sortBy; // refresh forum page, not initial enter if (sessionMapID != null) { @@ -149,6 +151,8 @@ externalType = (Integer) sessionMap.get(CommentConstants.ATTR_EXTERNAL_TYPE); externalSignature = (String) sessionMap.get(CommentConstants.ATTR_EXTERNAL_SIG); mode = (String) sessionMap.get(AttributeNames.ATTR_MODE); + pageSize = (Integer) sessionMap.get(CommentConstants.PAGE_SIZE); + sortBy = (Integer) sessionMap.get(CommentConstants.ATTR_SORT_BY); } else { sessionMap = new SessionMap(); @@ -159,12 +163,21 @@ externalSignature = WebUtil.readStrParam(request, CommentConstants.ATTR_EXTERNAL_SIG); likeAndDislike = WebUtil.readBooleanParam(request, CommentConstants.ATTR_LIKE_AND_DISLIKE); readOnly = WebUtil.readBooleanParam(request, CommentConstants.ATTR_READ_ONLY); + pageSize = WebUtil.readIntParam(request, CommentConstants.PAGE_SIZE, true); + if ( pageSize == null ) + pageSize = CommentConstants.DEFAULT_PAGE_SIZE; + sortBy = (Integer) WebUtil.readIntParam(request, CommentConstants.ATTR_SORT_BY, true); + if ( sortBy == null ) + sortBy = ICommentService.SORT_BY_DATE; + sessionMap.put(CommentConstants.ATTR_EXTERNAL_ID, externalId); sessionMap.put(CommentConstants.ATTR_EXTERNAL_TYPE, externalType); sessionMap.put(CommentConstants.ATTR_EXTERNAL_SIG, externalSignature); sessionMap.put(CommentConstants.ATTR_LIKE_AND_DISLIKE, likeAndDislike); sessionMap.put(CommentConstants.ATTR_READ_ONLY, readOnly); - + sessionMap.put(CommentConstants.PAGE_SIZE, pageSize); + sessionMap.put(CommentConstants.ATTR_SORT_BY, sortBy); + mode = request.getParameter(AttributeNames.ATTR_MODE); sessionMap.put(AttributeNames.ATTR_MODE, mode != null ? mode : ToolAccessMode.LEARNER.toString()); } @@ -175,7 +188,7 @@ Comment rootComment = getCommentService().createOrGetRoot(externalId, externalType, externalSignature, user); sessionMap.put(CommentConstants.ATTR_ROOT_COMMENT_UID, rootComment.getUid()); - return viewTopicImpl(mapping, form, request, response, sessionMap); + return viewTopicImpl(mapping, form, request, response, sessionMap, pageSize, sortBy); } private void throwException(String msg, String loginName, Long externalId, Integer externalType, String externalSignature) throws ServletException { @@ -196,7 +209,8 @@ /** * Display the comments for a given external id (usually tool session id). The session comments will be - * arranged by Tree structure and loaded thread by thread (with paging). + * arranged by Tree structure and loaded thread by thread (with paging). This may set a new value of sort by, so + * make sure the session is updated. * * @param mapping * @param form @@ -210,12 +224,16 @@ String sessionMapID = WebUtil.readStrParam(request, CommentConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); - return viewTopicImpl(mapping, form, request, response, sessionMap); + Integer pageSize = WebUtil.readIntParam(request, CommentConstants.PAGE_SIZE, true); + Integer sortBy = WebUtil.readIntParam(request, CommentConstants.ATTR_SORT_BY, true); + if ( sortBy != null ) + sessionMap.put( CommentConstants.ATTR_SORT_BY, sortBy); + return viewTopicImpl(mapping, form, request, response, sessionMap, pageSize, sortBy); } private ActionForward viewTopicImpl(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response, SessionMap sessionMap) { + HttpServletResponse response, SessionMap sessionMap, Integer pageSize, Integer sortBy) { Long externalId = (Long) sessionMap.get(CommentConstants.ATTR_EXTERNAL_ID); Integer externalType = (Integer) sessionMap.get(CommentConstants.ATTR_EXTERNAL_TYPE); @@ -228,12 +246,20 @@ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); Long lastMsgSeqId = WebUtil.readLongParam(request, CommentConstants.PAGE_LAST_ID, true); - Integer pageSize = WebUtil.readIntParam(request, CommentConstants.PAGE_SIZE, true); - if ( pageSize == null || pageSize == 0 ) - pageSize = CommentConstants.DEFAULT_PAGE_SIZE; - - setupViewTopicPagedDTOList(request, externalId, externalType, externalSignature, sessionMap, user, lastMsgSeqId, pageSize); + String currentLikeCount = WebUtil.readStrParam(request, CommentConstants.ATTR_LIKE_COUNT, true); + if ( pageSize == null ) + pageSize = (Integer) sessionMap.get(CommentConstants.PAGE_SIZE); + if ( sortBy == null ) + sortBy = (Integer) sessionMap.get(CommentConstants.ATTR_SORT_BY); + + List msgDtoList = commentService.getTopicThread(externalId, externalType, externalSignature, lastMsgSeqId, pageSize, sortBy, currentLikeCount, user.getUserID()); + updateMessageFlag(msgDtoList, user.getUserID()); + request.setAttribute(CommentConstants.ATTR_COMMENT_THREAD, msgDtoList); + + // transfer SessionMapID as well + request.setAttribute(CommentConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + return mapping.findForward("success"); } @@ -243,18 +269,6 @@ return (SessionMap) request.getSession().getAttribute(sessionMapId); } - private void setupViewTopicPagedDTOList(HttpServletRequest request, Long externalId, Integer externalType, String externalSignature, - SessionMap sessionMap, UserDTO user, Long lastMsgSeqId, Integer pageSize) { - - // get root topic list - List msgDtoList = commentService.getTopicThread(externalId, externalType, externalSignature, lastMsgSeqId, pageSize, user.getUserID()); - updateMessageFlag(msgDtoList, user.getUserID()); - request.setAttribute(CommentConstants.ATTR_COMMENT_THREAD, msgDtoList); - - // transfer SessionMapID as well - request.setAttribute(CommentConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); - } - /** * Display the messages for a particular thread in a particular topic. Returns all messages for this thread - does not need paging. * @@ -275,7 +289,11 @@ // get forum user and forum UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); Long threadId = WebUtil.readLongParam(request, CommentConstants.ATTR_THREAD_ID, true); - List msgDtoList = commentService.getThread(threadId, user.getUserID()); + Integer sortBy = WebUtil.readIntParam(request, CommentConstants.ATTR_SORT_BY, true); + if ( sortBy != null ) + sessionMap.put( CommentConstants.ATTR_SORT_BY, sortBy); + + List msgDtoList = commentService.getThread(threadId, sortBy, user.getUserID()); updateMessageFlag(msgDtoList, user.getUserID()); request.setAttribute(CommentConstants.ATTR_COMMENT_THREAD, msgDtoList); Index: lams_central/web/WEB-INF/tags/Comments.tag =================================================================== diff -u -rf65bf8d775c89d19993d672813a4af9f95266267 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/web/WEB-INF/tags/Comments.tag (.../Comments.tag) (revision f65bf8d775c89d19993d672813a4af9f95266267) +++ lams_central/web/WEB-INF/tags/Comments.tag (.../Comments.tag) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -1,3 +1,5 @@ +<%@ tag import="org.lamsfoundation.lams.comments.CommentConstants"%> + <%@ taglib uri="tags-core" prefix="c"%> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> @@ -7,7 +9,12 @@ <%@ attribute name="height" required="false" rtexprvalue="true"%> <%@ attribute name="width" required="false" rtexprvalue="true"%> <%@ attribute name="mode" required="false" rtexprvalue="true"%> +<%@ attribute name="likeAndDislike" required="false" rtexprvalue="true"%> +<%@ attribute name="readOnly" required="false" rtexprvalue="true"%> +<%@ attribute name="pageSize" required="false" rtexprvalue="true"%> +<%@ attribute name="sortBy" required="false" rtexprvalue="true"%> + @@ -21,8 +28,24 @@ &mode=${mode} - + + + + + + + + + + + + + + + + + + + Index: lams_central/web/WEB-INF/tlds/lams/lams.tld =================================================================== diff -u -r46bcb6ea758a272250071d1a571d008c6745e593 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 46bcb6ea758a272250071d1a571d008c6745e593) +++ lams_central/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -481,9 +481,13 @@ head /WEB-INF/tags/Head.tag - + Comments /WEB-INF/tags/Comments.tag + + CommentsAuthor + /WEB-INF/tags/CommentsAuthor.tag + Index: lams_central/web/comments/comments.jsp =================================================================== diff -u -r25e1ec09bef9772ea3a274a6ba5127cbc70d4f16 -r1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5 --- lams_central/web/comments/comments.jsp (.../comments.jsp) (revision 25e1ec09bef9772ea3a274a6ba5127cbc70d4f16) +++ lams_central/web/comments/comments.jsp (.../comments.jsp) (revision 1c6cd416ca3946f49e0bb6cb2cecc7107887d7f5) @@ -39,9 +39,28 @@
@@ -76,7 +71,7 @@