001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/msgcntr/trunk/messageforums-app/src/java/org/sakaiproject/tool/messageforums/jsf/HierDataTableRender.java $
003: * $Id: HierDataTableRender.java 9227 2006-05-15 15:02:42Z cwen@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.tool.messageforums.jsf;
021:
022: import com.sun.faces.util.Util;
023: import org.apache.commons.logging.Log;
024: import org.apache.commons.logging.LogFactory;
025:
026: import javax.faces.component.UIColumn;
027: import javax.faces.component.UIComponent;
028: import javax.faces.component.UIData;
029: import javax.faces.context.FacesContext;
030: import javax.faces.context.ResponseWriter;
031: import javax.faces.el.ValueBinding;
032:
033: import com.sun.faces.renderkit.html_basic.HtmlBasicRenderer;
034:
035: import java.io.IOException;
036: import java.util.ArrayList;
037: import java.util.Iterator;
038: import java.util.List;
039:
040: import org.sakaiproject.api.app.messageforums.Message;
041: import org.sakaiproject.api.app.messageforums.MessageForumsMessageManager;
042: import org.sakaiproject.tool.messageforums.ui.DiscussionMessageBean;
043: import org.sakaiproject.component.cover.ComponentManager;
044:
045: /**
046: * @author cwen
047: *
048: * TODO To change the template for this generated type comment go to
049: * Window - Preferences - Java - Code Style - Code Templates
050: */
051: public class HierDataTableRender extends HtmlBasicRenderer {
052: protected static Log log = LogFactory
053: .getLog(HierDataTableRender.class);
054:
055: private static final String RESOURCE_PATH;
056: private static final String BARIMG;
057: private static final String CURSOR;
058:
059: static {
060: RESOURCE_PATH = "/" + "sakai-messageforums-tool";
061: BARIMG = RESOURCE_PATH + "/" + "images/collapse.gif";
062: CURSOR = "cursor:pointer";
063: }
064:
065: public boolean getRendersChildren() {
066: return true;
067: }
068:
069: public void encodeBegin(FacesContext context, UIComponent component)
070: throws IOException {
071:
072: if ((context == null) || (component == null)) {
073: throw new NullPointerException(
074: Util
075: .getExceptionMessageString(Util.NULL_PARAMETERS_ERROR_MESSAGE_ID));
076: }
077: if (log.isTraceEnabled()) {
078: log.trace("Begin encoding component " + component.getId());
079: }
080:
081: // suppress rendering if "rendered" property on the component is
082: // false.
083: if (!component.isRendered()) {
084: if (log.isTraceEnabled()) {
085: log.trace("No encoding necessary " + component.getId()
086: + " since "
087: + "rendered attribute is set to false ");
088: }
089: return;
090: }
091: UIData data = (UIData) component;
092: data.setRowIndex(-1);
093:
094: // Render the beginning of the table
095: ResponseWriter writer = context.getResponseWriter();
096: writer.startElement("table", data);
097: writeIdAttributeIfNecessary(context, writer, component);
098: String noArrows = (String) data.getAttributes().get("noarrows");
099: if (noArrows == null) {
100: noArrows = "";
101: }
102: String styleClass = (String) data.getAttributes().get(
103: "styleClass");
104: if (styleClass != null) {
105: writer.writeAttribute("class", styleClass, "styleClass");
106: }
107: Util.renderPassThruAttributes(writer, component,
108: new String[] { "rows" });
109: writer.writeText("\n", null);
110:
111: // Render the header facets (if any)
112: UIComponent header = getFacet(data, "header");
113: int headerFacets = getFacetCount(data, "header");
114: String headerClass = (String) data.getAttributes().get(
115: "headerClass");
116: if ((header != null) || (headerFacets > 0)) {
117: writer.startElement("thead", data);
118: writer.writeText("\n", null);
119: }
120: if (header != null) {
121: writer.startElement("tr", header);
122: writer.startElement("th", header);
123: if (headerClass != null) {
124: writer.writeAttribute("class", headerClass,
125: "headerClass");
126: }
127: writer.writeAttribute("colspan", "" + getColumnCount(data),
128: null);
129: writer.writeAttribute("scope", "colgroup", null);
130: encodeRecursive(context, header);
131: writer.endElement("th");
132: writer.endElement("tr");
133: writer.writeText("\n", null);
134: }
135: if (headerFacets > 0) {
136: writer.startElement("tr", data);
137: writer.writeText("\n", null);
138: Iterator columns = getColumns(data);
139: UIColumn oldColumn = null;
140: while (columns.hasNext()) {
141: UIColumn column = (UIColumn) columns.next();
142: //write column for arrows... only if last column did not specify arrows
143: if (column.getId().endsWith("_msg_subject")
144: && !oldColumn.getId().endsWith("_toggle")
145: && !noArrows.equals("true")) {
146: writer.startElement("th", null);
147: writer.writeAttribute("scope", "col", null);
148: writer.endElement("th");
149: writer.writeText("\n", null);
150: }
151: writer.startElement("th", column);
152: if (headerClass != null) {
153: writer.writeAttribute("class", headerClass,
154: "headerClass");
155: }
156: writer.writeAttribute("scope", "col", null);
157: UIComponent facet = getFacet(column, "header");
158: if (facet != null) {
159: encodeRecursive(context, facet);
160: }
161: writer.endElement("th");
162: writer.writeText("\n", null);
163: oldColumn = column;
164: }
165: writer.endElement("tr");
166: writer.writeText("\n", null);
167: }
168: if ((header != null) || (headerFacets > 0)) {
169: writer.endElement("thead");
170: writer.writeText("\n", null);
171: }
172:
173: // Render the footer facets (if any)
174: UIComponent footer = getFacet(data, "footer");
175: int footerFacets = getFacetCount(data, "footer");
176: String footerClass = (String) data.getAttributes().get(
177: "footerClass");
178: if ((footer != null) || (footerFacets > 0)) {
179: writer.startElement("tfoot", data);
180: writer.writeText("\n", null);
181: }
182: if (footer != null) {
183: writer.startElement("tr", footer);
184: writer.startElement("td", footer);
185: if (footerClass != null) {
186: writer.writeAttribute("class", footerClass,
187: "footerClass");
188: }
189: writer.writeAttribute("colspan", "" + getColumnCount(data),
190: null);
191: encodeRecursive(context, footer);
192: writer.endElement("td");
193: writer.endElement("tr");
194: writer.writeText("\n", null);
195: }
196: if (footerFacets > 0) {
197: writer.startElement("tr", data);
198: writer.writeText("\n", null);
199: Iterator columns = getColumns(data);
200: while (columns.hasNext()) {
201: UIColumn column = (UIColumn) columns.next();
202: writer.startElement("td", column);
203: if (footerClass != null) {
204: writer.writeAttribute("class", footerClass,
205: "footerClass");
206: }
207: UIComponent facet = getFacet(column, "footer");
208: if (facet != null) {
209: encodeRecursive(context, facet);
210: }
211: writer.endElement("td");
212: writer.writeText("\n", null);
213: }
214: writer.endElement("tr");
215: writer.writeText("\n", null);
216: }
217: if ((footer != null) || (footerFacets > 0)) {
218: writer.endElement("tfoot");
219: writer.writeText("\n", null);
220: }
221:
222: }
223:
224: public void encodeChildren(FacesContext context,
225: UIComponent component) throws IOException {
226: MessageForumsMessageManager messageManager = (MessageForumsMessageManager) ComponentManager
227: .get("org.sakaiproject.api.app.messageforums.MessageForumsMessageManager");
228:
229: if ((context == null) || (component == null)) {
230: throw new NullPointerException(
231: Util
232: .getExceptionMessageString(Util.NULL_PARAMETERS_ERROR_MESSAGE_ID));
233: }
234: if (log.isTraceEnabled()) {
235: log.trace("Begin encoding children " + component.getId());
236: }
237: if (!component.isRendered()) {
238: if (log.isTraceEnabled()) {
239: log.trace("No encoding necessary " + component.getId()
240: + " since "
241: + "rendered attribute is set to false ");
242: }
243: return;
244: }
245: UIData data = (UIData) component;
246:
247: ValueBinding msgsBinding = component.getValueBinding("value");
248: List msgBeanList = (List) msgsBinding.getValue(context);
249:
250: String noArrows = (String) data.getAttributes().get("noarrows");
251: if (noArrows == null) {
252: noArrows = "";
253: }
254: // Set up variables we will need
255: String columnClasses[] = getColumnClasses(data);
256: int columnStyle = 0;
257: int columnStyles = columnClasses.length;
258: String rowClasses[] = getRowClasses(data);
259: int rowStyles = rowClasses.length;
260: ResponseWriter writer = context.getResponseWriter();
261: Iterator kids = null;
262: Iterator grandkids = null;
263:
264: // Iterate over the rows of data that are provided
265: int processed = 0;
266: int rowIndex = data.getFirst() - 1;
267: int rows = data.getRows();
268: int rowStyle = 0;
269:
270: writer.startElement("tbody", component);
271: writer.writeText("\n", null);
272: int hideDivNo = 0;
273: while (true) {
274: DiscussionMessageBean dmb = null;
275: if (msgBeanList != null
276: && msgBeanList.size() > (rowIndex + 1)
277: && rowIndex > -2) {
278: dmb = (DiscussionMessageBean) msgBeanList
279: .get(rowIndex + 1);
280: }
281: //remove from manager, get hasChild from msgBeanList List hasChild = null;
282: boolean hasChildBoolean = false;
283: if (dmb != null) {
284: //hasChild = messageManager.getFirstLevelChildMsgs(dmb.getMessage().getId());
285: for (int i = 0; i < msgBeanList.size(); i++) {
286: DiscussionMessageBean tempDmb = (DiscussionMessageBean) msgBeanList
287: .get(i);
288: if (tempDmb.getMessage().getInReplyTo() != null
289: && tempDmb.getMessage().getInReplyTo()
290: .getId().equals(
291: dmb.getMessage().getId())) {
292: hasChildBoolean = true;
293: break;
294: }
295: }
296: }
297: /* if(hasChild!=null && hasChild.size()>0)
298: {
299: hasChildBoolean = true;
300: }
301: */
302: // Have we displayed the requested number of rows?
303: if ((rows > 0) && (++processed > rows)) {
304: break;
305: }
306: // Select the current row
307: data.setRowIndex(++rowIndex);
308: if (!data.isRowAvailable()) {
309: break; // Scrolled past the last row
310: }
311:
312: // Render the beginning of this row
313: ////writer.startElement("tr", data);
314: //////
315: if (dmb.getDepth() > 0 && !noArrows.equals("true")) {
316: //////writer.write("<div style=\"display:none\" id=\"_id_" + new Integer(hideDivNo).toString() + "__hide_division_" + "\">");
317: writer.write("<tr style=\"display:none\" id=\"_id_"
318: + new Integer(hideDivNo).toString()
319: + "__hide_division_" + "\">");
320: } else if (dmb.getDepth() > 0) {
321: writer.write("<tr>");
322: } else {
323: writer.write("<tr class=\"hierItemBlock\">");
324: }
325:
326: if (rowStyles > 0) {
327: writer.writeAttribute("class", rowClasses[rowStyle++],
328: "rowClasses");
329: if (rowStyle >= rowStyles) {
330: rowStyle = 0;
331: }
332: }
333: writer.writeText("\n", null);
334:
335: // Iterate over the child UIColumn components for each row
336: columnStyle = 0;
337: kids = getColumns(data);
338: Boolean toggleWritten = false;
339: while (kids.hasNext()) {
340:
341: // Identify the next renderable column
342: UIColumn column = (UIColumn) kids.next();
343:
344: //check if we need the arraow column
345: // if this is the _msg_subject column, then quickly add an arrow column
346: if ((column.getId().endsWith("_msg_subject") || column
347: .getId().endsWith("_toggle"))
348: && !toggleWritten && !noArrows.equals("true")) {
349: writer.startElement("td", null);
350: if (columnStyles > 0) {
351: writer.writeAttribute("class",
352: columnClasses[columnStyle++],
353: "columnClasses");
354: if (columnStyle >= columnStyles) {
355: columnStyle = 0;
356: }
357: }
358: if (hasChildBoolean && dmb.getDepth() == 0) {
359: writer.write(" <img src=\"" + BARIMG
360: + "\" style=\"" + CURSOR
361: + "\" id=\"_id_"
362: + new Integer(hideDivNo).toString()
363: + "__img_hide_division_\""
364: + " onclick=\"");
365: int childNo = getTotalChildNo(dmb, msgBeanList);
366: String hideTr = "";
367: for (int i = 0; i < childNo; i++) {
368: hideTr += "javascript:showHideDiv('_id_"
369: + new Integer(hideDivNo + i)
370: .toString() + "', '"
371: + RESOURCE_PATH + "');";
372: }
373: writer.write(hideTr);
374: writer
375: .write("setMainFrameHeight('Main"
376: + org.sakaiproject.tool.cover.ToolManager
377: .getCurrentPlacement()
378: .getId().replace("-",
379: "x") + "');");
380: writer.write("\" />");
381: }
382: writer.endElement("td");
383: writer.writeText("\n", null);
384: toggleWritten = true;
385: }
386: if (column.getId().endsWith("_toggle")) {
387: continue;
388: }
389:
390: // Render the beginning of this cell
391: writer.startElement("td", column);
392: if (columnStyles > 0) {
393: writer.writeAttribute("class",
394: columnClasses[columnStyle++],
395: "columnClasses");
396: if (columnStyle >= columnStyles) {
397: columnStyle = 0;
398: }
399: }
400: if (dmb != null) // && dmb.getDepth() > 0)
401: {
402: if (column.getId().endsWith("_msg_subject")) {
403: // rjlowe: using padding-left: 1em instead of
404: writer.writeAttribute("style", "padding-left:"
405: + dmb.getDepth() + "em;", "style");
406:
407: //String indent = "";
408: //int indentInt = dmb.getDepth() * 4;
409: //for(int i=0; i<indentInt; i++)
410: //{
411: // indent += " ";
412: //}
413: //writer.write(indent);
414: }
415: }
416: // rjlowe: arrow is now in it's own column, see above
417: /***
418: if(dmb.getDepth() == 0)
419: {
420: if(column.getId().endsWith("_msg_subject"))
421: {
422: //if(hasChildBoolean)
423:
424:
425: if(hasChildBoolean && dmb.getDepth()==0)
426: {
427: writer.write(" <img src=\"" + BARIMG + "\" style=\"position:absolute;left:-1em;" + CURSOR + "\" id=\"_id_" + new Integer(hideDivNo).toString() + "__img_hide_division_\"" +
428: " onclick=\"");
429: int childNo = getTotalChildNo(dmb, msgBeanList);
430: String hideTr = "";
431: for(int i=0; i<childNo; i++)
432: {
433: hideTr += "javascript:showHideDiv('_id_" + new Integer(hideDivNo+i).toString() + "', '" + RESOURCE_PATH + "');";
434: }
435: writer.write(hideTr);
436: writer.write("setMainFrameHeight('Main" + org.sakaiproject.tool.cover.ToolManager.getCurrentPlacement().getId().replace("-","x") + "');");
437: writer.write("\" />");
438: }
439: }
440: }
441: ***/
442: // Render the contents of this cell by iterating over
443: // the kids of our kids
444: grandkids = getChildren(column);
445: while (grandkids.hasNext()) {
446: encodeRecursive(context, (UIComponent) grandkids
447: .next());
448: }
449:
450: // Render the ending of this cell
451: writer.endElement("td");
452: writer.writeText("\n", null);
453:
454: }
455:
456: // Render the ending of this row
457: writer.endElement("tr");
458: writer.writeText("\n", null);
459: if (dmb.getDepth() == 0 && hasChildBoolean) {
460: //////writer.write("<div style=\"display:none\" id=\"_id_" + new Integer(hideDivNo).toString() + "__hide_division_" + "\">");
461: }
462: if (dmb != null && dmb.getDepth() > 0) {
463: ValueBinding expandedBinding = component
464: .getValueBinding("expanded");
465: String expanded = "";
466: if (expandedBinding != null)
467: expanded = (String) expandedBinding
468: .getValue(context);
469:
470: if (expanded.equalsIgnoreCase("true")) {
471: writer.write("<script type=\"text/javascript\">");
472: writer.write(" showHideDiv('_id_"
473: + new Integer(hideDivNo).toString()
474: + "', '" + RESOURCE_PATH + "');");
475: writer.write("</script>");
476: }
477:
478: hideDivNo++;
479: /* get rid of div, tr - set display for every row of child msgs
480: DiscussionMessageBean nextBean = null;
481: if(msgBeanList !=null && msgBeanList.size()>(rowIndex+1))
482: {
483: nextBean = (DiscussionMessageBean)msgBeanList.get(rowIndex+1);
484: }
485: if(nextBean != null)
486: {
487: if(nextBean.getDepth() == 0)
488: {
489: //////writer.write("</div>");
490: writer.write("<script type=\"text/javascript\">");
491: writer.write(" showHideDiv('_id_" + new Integer(hideDivNo).toString() +
492: "', '" + RESOURCE_PATH + "');");
493: hideDivNo++;
494: writer.write("</script>");
495: }
496: }
497: else
498: {
499: //////writer.write("</div>");
500: writer.write("<script type=\"text/javascript\">");
501: writer.write(" showHideDiv('_id_" + new Integer(hideDivNo).toString() +
502: "', '" + RESOURCE_PATH + "');");
503: hideDivNo++;
504: writer.write("</script>");
505: }*/
506: }
507: }
508: writer.endElement("tbody");
509: writer.writeText("\n", null);
510:
511: // Clean up after ourselves
512: data.setRowIndex(-1);
513: if (log.isTraceEnabled()) {
514: log.trace("End encoding children " + component.getId());
515: }
516: }
517:
518: public void encodeEnd(FacesContext context, UIComponent component)
519: throws IOException {
520:
521: if ((context == null) || (component == null)) {
522: throw new NullPointerException(
523: Util
524: .getExceptionMessageString(Util.NULL_PARAMETERS_ERROR_MESSAGE_ID));
525: }
526: if (!component.isRendered()) {
527: if (log.isTraceEnabled()) {
528: log.trace("No encoding necessary " + component.getId()
529: + " since "
530: + "rendered attribute is set to false ");
531: }
532: return;
533: }
534: UIData data = (UIData) component;
535: data.setRowIndex(-1);
536: ResponseWriter writer = context.getResponseWriter();
537:
538: // Render the ending of this table
539: writer.endElement("table");
540: writer.writeText("\n", null);
541: if (log.isTraceEnabled()) {
542: log.trace("End encoding component " + component.getId());
543: }
544:
545: }
546:
547: private int getTotalChildNo(DiscussionMessageBean dmb, List beanList) {
548: int no = 0;
549: MessageForumsMessageManager messageManager = (MessageForumsMessageManager) ComponentManager
550: .get("org.sakaiproject.api.app.messageforums.MessageForumsMessageManager");
551: List allChild = new ArrayList();
552: messageManager.getChildMsgs(dmb.getMessage().getId(), allChild);
553:
554: //cwen: if every child is set to under some topic, no need to compare here.
555: // -- no such case: replyTo child is moved to another topic but still has the inReplyTo set to point to the old msg.
556: for (int i = 0; i < beanList.size(); i++) {
557: DiscussionMessageBean this Bean = (DiscussionMessageBean) beanList
558: .get(i);
559: for (int j = 0; j < allChild.size(); j++) {
560: Message child = (Message) allChild.get(j);
561: if (this Bean.getMessage().getId().equals(child.getId())) {
562: no++;
563: break;
564: }
565: }
566: }
567:
568: return no;
569: }
570:
571: // --------------------------------------------------------- Private Methods
572:
573: /**
574: * <p>Return an array of stylesheet classes to be applied to
575: * each column in the table in the order specified. Every column may or
576: * may not have a stylesheet.</p>
577: *
578: * @param data {@link UIData} component being rendered
579: */
580: private String[] getColumnClasses(UIData data) {
581:
582: String values = (String) data.getAttributes().get(
583: "columnClasses");
584: if (values == null) {
585: return (new String[0]);
586: }
587: values = values.trim();
588: ArrayList list = new ArrayList();
589: while (values.length() > 0) {
590: int comma = values.indexOf(",");
591: if (comma >= 0) {
592: list.add(values.substring(0, comma).trim());
593: values = values.substring(comma + 1);
594: } else {
595: list.add(values.trim());
596: values = "";
597: }
598: }
599: String results[] = new String[list.size()];
600: return ((String[]) list.toArray(results));
601:
602: }
603:
604: /**
605: * <p>Return the number of child <code>UIColumn</code> components
606: * that are nested in the specified {@link UIData}.</p>
607: *
608: * @param data {@link UIData} component being analyzed
609: */
610: private int getColumnCount(UIData data) {
611:
612: int columns = 0;
613: Iterator kids = getColumns(data);
614: while (kids.hasNext()) {
615: UIComponent kid = (UIComponent) kids.next();
616: columns++;
617: }
618: return (columns);
619:
620: }
621:
622: /**
623: * <p>Return an Iterator over the <code>UIColumn</code> children
624: * of the specified <code>UIData</code> that have a
625: * <code>rendered</code> property of <code>true</code>.</p>
626: *
627: * @param data <code>UIData</code> for which to extract children
628: */
629: private Iterator getColumns(UIData data) {
630:
631: List results = new ArrayList();
632: Iterator kids = data.getChildren().iterator();
633: while (kids.hasNext()) {
634: UIComponent kid = (UIComponent) kids.next();
635: if ((kid instanceof UIColumn) && kid.isRendered()) {
636: results.add(kid);
637: }
638: }
639: return (results.iterator());
640:
641: }
642:
643: /**
644: * <p>Return the number of child <code>UIColumn</code> components
645: * nested in the specified <code>UIData</code> that have a facet with
646: * the specified name.</p>
647: *
648: * @param data <code>UIData</code> component being analyzed
649: * @param name Name of the facet being analyzed
650: */
651: private int getFacetCount(UIData data, String name) {
652:
653: int n = 0;
654: Iterator kids = getColumns(data);
655: while (kids.hasNext()) {
656: UIComponent kid = (UIComponent) kids.next();
657: if (getFacet(kid, name) != null) {
658: n++;
659: }
660: }
661: return (n);
662:
663: }
664:
665: /**
666: * <p>Return an array of stylesheet classes to be applied to
667: * each row in the table, in the order specified. Every row may or
668: * may not have a stylesheet.</p>
669: *
670: * @param data {@link UIData} component being rendered
671: */
672: private String[] getRowClasses(UIData data) {
673:
674: String values = (String) data.getAttributes().get("rowClasses");
675: if (values == null) {
676: return (new String[0]);
677: }
678: values = values.trim();
679: ArrayList list = new ArrayList();
680: while (values.length() > 0) {
681: int comma = values.indexOf(",");
682: if (comma >= 0) {
683: list.add(values.substring(0, comma).trim());
684: values = values.substring(comma + 1);
685: } else {
686: list.add(values.trim());
687: values = "";
688: }
689: }
690: String results[] = new String[list.size()];
691: return ((String[]) list.toArray(results));
692:
693: }
694:
695: private void renderThread(ResponseWriter writer, UIData data,
696: int rows, Integer processed, int rowIndex, int rowStyles,
697: int rowStyle, int columnStyle, int columnStyles,
698: String columnClasses[], String rowClasses[],
699: FacesContext context, List msgs, Message currentMsg) {
700: Iterator kids = null;
701: Iterator grandkids = null;
702:
703: for (int i = 0; i < msgs.size(); i++) {
704: Message this Msg = (Message) msgs.get(i);
705: if (this Msg.getId().equals(currentMsg.getId())) {
706: msgs.remove(i);
707: break;
708: }
709: }
710:
711: try {
712: int processedInt = processed.intValue();
713: if ((rows > 0) && (++processedInt > rows)) {
714: processed = new Integer(processedInt);
715: return;
716: }
717: data.setRowIndex(++rowIndex);
718: if (!data.isRowAvailable()) {
719: return;
720: }
721:
722: writer.startElement("tr", data);
723: if (rowStyles > 0) {
724: writer.writeAttribute("class", rowClasses[rowStyle++],
725: "rowClasses");
726: if (rowStyle >= rowStyles) {
727: rowStyle = 0;
728: }
729: }
730: writer.writeText("\n", null);
731:
732: columnStyle = 0;
733: kids = getColumns(data);
734: while (kids.hasNext()) {
735: UIColumn column = (UIColumn) kids.next();
736:
737: writer.startElement("td", column);
738: if (columnStyles > 0) {
739: writer.writeAttribute("class",
740: columnClasses[columnStyle++],
741: "columnClasses");
742: if (columnStyle >= columnStyles) {
743: columnStyle = 0;
744: }
745: }
746:
747: grandkids = getChildren(column);
748: while (grandkids.hasNext()) {
749: encodeRecursive(context, (UIComponent) grandkids
750: .next());
751: }
752:
753: writer.endElement("td");
754: writer.writeText("\n", null);
755:
756: }
757:
758: writer.endElement("tr");
759: writer.writeText("\n", null);
760: } catch (Exception e) {
761: e.printStackTrace();
762: }
763:
764: MessageForumsMessageManager messageManager = (MessageForumsMessageManager) ComponentManager
765: .get("org.sakaiproject.api.app.messageforums.MessageForumsMessageManager");
766: List replyMsgs = messageManager
767: .getFirstLevelChildMsgs(currentMsg.getId());
768: if (replyMsgs != null) {
769: for (int i = 0; i < replyMsgs.size(); i++) {
770: Message childM = (Message) replyMsgs.get(i);
771: for (int j = 0; j < msgs.size(); j++) {
772: Message remainMsg = (Message) msgs.get(j);
773: if (childM.getId().equals(remainMsg.getId())) {
774: renderThread(writer, data, rows, processed,
775: rowIndex, rowStyles, rowStyle,
776: columnStyle, columnStyles,
777: columnClasses, rowClasses, context,
778: msgs, remainMsg);
779: }
780: }
781: }
782: }
783: }
784: }
|