KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > improve > struts > taglib > layout > collection > BaseCollectionTag


1 package fr.improve.struts.taglib.layout.collection;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Collection JavaDoc;
5 import java.util.HashMap JavaDoc;
6 import java.util.Iterator JavaDoc;
7 import java.util.List JavaDoc;
8 import java.util.Map JavaDoc;
9
10 import javax.servlet.http.HttpServletRequest JavaDoc;
11 import javax.servlet.jsp.JspException JavaDoc;
12 import javax.servlet.jsp.PageContext JavaDoc;
13
14 import org.apache.struts.Globals;
15 import org.apache.struts.taglib.html.Constants;
16
17 import fr.improve.struts.taglib.layout.BodyLayoutTagSupport;
18 import fr.improve.struts.taglib.layout.collection.header.CollectionItemEvent;
19 import fr.improve.struts.taglib.layout.collection.header.MultiLevelHeader;
20 import fr.improve.struts.taglib.layout.collection.header.MultiLevelTitleHandler;
21 import fr.improve.struts.taglib.layout.el.Expression;
22 import fr.improve.struts.taglib.layout.event.EndLayoutEvent;
23 import fr.improve.struts.taglib.layout.event.StartLayoutEvent;
24 import fr.improve.struts.taglib.layout.field.AbstractModeFieldTag;
25 import fr.improve.struts.taglib.layout.pager.PagerContainer;
26 import fr.improve.struts.taglib.layout.sort.JavascriptSortUtil;
27 import fr.improve.struts.taglib.layout.sort.SortUtil;
28 import fr.improve.struts.taglib.layout.util.CollectionInterface;
29 import fr.improve.struts.taglib.layout.util.FormUtilsInterface;
30 import fr.improve.struts.taglib.layout.util.IMultiLevelHeaderRenderer;
31 import fr.improve.struts.taglib.layout.util.LayoutUtils;
32 import fr.improve.struts.taglib.layout.util.NestedHelper;
33 import fr.improve.struts.taglib.layout.util.TagUtils;
34 import fr.improve.struts.taglib.layout.util.WidgetUtils;
35
36 /**
37  * Base class for tags that can display the content of a collection.
38  * Support the iteration on two collections.
39  *
40  * @see CollectionActionTag CollectionActionTag
41  * @see CollectionLineTag CollectionLineTag
42  * @see CollectionTag CollectionTag
43  * @see NewsTag NewsTag
44  *
45  * @author: Jean-Noel Ribette
46  */

47 public abstract class BaseCollectionTag extends BodyLayoutTagSupport implements PagerContainer, MultiLevelTitleHandler {
48     
49     /**
50      * This class is here for compatibility reason only and will be removed.
51      * @deprecated use ItemContext instead.
52      */

53     public static class Header extends SimpleItemContext {
54         public String JavaDoc key;
55         /**
56          * @param in_context
57          */

58         public Header(ItemContext in_context) {
59             super(in_context);
60             key = in_context.getTitle();
61         }
62     }
63     
64     protected ArrayList JavaDoc headers = new ArrayList JavaDoc();
65
66     /**
67      * Panel class to use.
68      */

69     protected static CollectionInterface defaultPanel;
70     /**
71      * Instance if the panel interface.
72      */

73     protected CollectionInterface panel;
74     /**
75      * Name of the bean containing the first collection
76      */

77     protected String JavaDoc name = Constants.BEAN_KEY;
78     /**
79      * Property of the bean giving the first collection
80      */

81     protected String JavaDoc property;
82     
83     /**
84      * Name of the bean containing the second collection
85      */

86     protected String JavaDoc name2;
87     /**
88      * Property of the bean giving the second collection
89      */

90     protected String JavaDoc property2;
91     
92     protected CollectionsIterator iterator;
93     protected Iterator JavaDoc iterator2;
94     protected String JavaDoc id;
95     protected String JavaDoc id2;
96     protected String JavaDoc mathOperationId;
97
98     protected String JavaDoc indexId;
99     protected String JavaDoc oddId;
100     protected String JavaDoc offsetIndexId;
101
102     /**
103      * Title to display
104      */

105     protected String JavaDoc title;
106     protected String JavaDoc arg0Name;
107     
108     /**
109      * The bundle to use.
110      */

111     protected String JavaDoc bundle = Globals.MESSAGES_KEY;
112
113     /**
114      * The css class to use
115      */

116     protected String JavaDoc styleClass;
117     
118     /**
119      * Alternative styleClass
120      */

121     protected String JavaDoc styleClass2;
122     
123     protected boolean first = true;
124
125     protected Object JavaDoc bean;
126     protected Object JavaDoc bean2;
127     
128     /**
129      * When iteration are done on nested collections, this map contains
130      * the id of the changed elements and their span.
131      */

132     protected Map JavaDoc span = new HashMap JavaDoc();
133
134     protected int index = 0;
135     
136     protected int offset = 0;
137     
138     protected int length = 0;
139     
140     protected int size = 0;
141     
142     protected int nbOfColumns = 0;
143     protected int column = 0;
144     
145     /**
146      * No collection sorting.
147      */

148     public static final int SORT_NO = 0;
149     /**
150      * Struts-layout default collection sorting.
151      */

152     public static final int SORT_LAYOUT = 1;
153     /**
154      * Custom collection sorting.
155      */

156     public static final int SORT_CUSTOM = 2;
157     /**
158      * Client collection sorting with javascript.
159      */

160     public static final int SORT_JAVASCRIPT = 3;
161     /**
162      * Used by the pager tag to indicate a sort is required,
163      * but that it is up to the collection tag to choose the sort type.
164      */

165     public static final int SORT_PAGER = 4;
166     
167     /**
168      * Current sorting mode.
169      */

170     protected int sortType = SORT_NO;
171     /**
172      * The action to invoke to sort the table
173      */

174     protected String JavaDoc sortAction;
175     /**
176      * The param to add to specify which column to sort
177      */

178     protected String JavaDoc sortParam;
179     /**
180      * The pictogram key to use to display the sort action
181      */

182     protected String JavaDoc sortPictogram ="layout.sort";
183     /**
184      * The pictogram alt key
185      */

186     protected String JavaDoc sortLabel = "layout.sort.label";
187     
188     /**
189      * The panel width
190      */

191     protected String JavaDoc width;
192     
193     /**
194      * The panel height
195      */

196     protected String JavaDoc height;
197     
198     /**
199      * The panel alignment.
200      */

201     protected String JavaDoc align = "CENTER";
202
203     //----------------------------------------------------------------------------------
204
// the following attributes are used to compute wich rows of the list are selected
205

206     /**
207      * If not null, add a column with checkboxes to select lines.
208      * the name of the checkboxes are set to the value of this field.
209      */

210     protected String JavaDoc selectName;
211     /**
212      * Property to use to set the value of the checkboxes
213      */

214     protected String JavaDoc selectProperty;
215     /**
216      * Type of select: default is checkbox, other possibility is radio
217      */

218     protected String JavaDoc selectType = "checkbox";
219     /**
220      * True if the checkboxes / radio buttons indicating if a row is selected should not be displayed.
221      */

222     protected boolean selectHidden = false;
223     /**
224      * Do we need to display a checkbox to select a line in this current processing of the tag body
225      */

226     protected boolean needSelect = false;
227     /**
228      * Additional property to add after the index when selecting multiple values from checoboxes.<br>
229      * selectName="select" and selectInex="value" wil render names like name="select[5].value
230      */

231     protected String JavaDoc selectIndex;
232     
233     protected String JavaDoc selectId;
234     
235     //--------------------------------------------------
236

237     protected short fieldDisplayMode = AbstractModeFieldTag.MODE_EDIT;
238
239     /**
240      * Temp styleClass for designed columns / line.
241      */

242     protected String JavaDoc tempStyleClass;
243     
244     /**
245      * Temp styles.
246      */

247     protected List JavaDoc tempStyles = new ArrayList JavaDoc();
248
249     /**
250      * Message to display of the collection is empty.
251      */

252     protected String JavaDoc emptyKey;
253     
254     /**
255      * Javascript function to call when a row is selected.
256      */

257     protected String JavaDoc onRowClick;
258     
259     /**
260      * Javascript function to call when a row is selected.
261      */

262     protected String JavaDoc onRowDblClick;
263     
264     /**
265      * Javascript function to call when a row is selected.
266      */

267     protected String JavaDoc onRowMouseOver;
268     protected String JavaDoc onRowMouseOut;
269     
270     protected String JavaDoc jspOnRowMouseOver;
271     protected String JavaDoc jspOnRowMouseOut;
272     protected String JavaDoc jspProperty;
273     protected String JavaDoc jspStyleClass;
274     
275     /**
276      * Javascript function to call when a row checkbox is selected.
277      */

278     protected String JavaDoc onClick;
279     
280     /**
281      * Id of the table containing the data.
282      */

283     protected String JavaDoc styleId;
284     
285     /**
286      * Model to use.
287      */

288     protected String JavaDoc model;
289     
290     
291     protected abstract void renderBlankCollection(StringBuffer JavaDoc out_buffer) throws JspException JavaDoc;
292     protected abstract void renderStart(StringBuffer JavaDoc out_buffer) throws JspException JavaDoc;
293     protected void renderHeader(StringBuffer JavaDoc buffer, ItemContext in_header) throws JspException JavaDoc {
294         renderHeader(buffer, (Header)in_header);
295     }
296     
297     /**
298      * @deprecated
299      */

300     protected void renderHeader(StringBuffer JavaDoc buffer, Header in_header) throws JspException JavaDoc {
301         // Shoud be overrided in CollectionTag for old implementation.
302
}
303     protected abstract void renderEnd(StringBuffer JavaDoc out_buffer) throws JspException JavaDoc;
304     
305     public void addItem(StringBuffer JavaDoc in_buffer, ItemContext in_context) throws JspException JavaDoc {
306         if (first) {
307             // This is the first time the collection is iterated over, display the table header label.
308

309             // For compatibility reason.
310
Header lc_header = new Header(in_context);
311             lc_header.key = in_context.getTitle();
312             headers.add(lc_header);
313             nbOfColumns++;
314             if (in_context.getSortProperty()!=null && (sortType==SORT_NO || sortType==SORT_PAGER)) {
315                 findSortType();
316             }
317         } else {
318             addItem(in_buffer, in_context.getItem(), in_context.getUrl(), in_context.getTarget(), in_context.getOnclick());
319         }
320         column++;
321     }
322     
323     protected List JavaDoc multiLevelHeaders;
324     protected int headersLevel;
325     
326     
327     private void findSortType() {
328         if (sortAction==null || sortAction.equals("") || sortType==SORT_PAGER && "client".equals(sortAction)) {
329             sortType = SORT_LAYOUT;
330         } else if (sortAction.equals("client")) {
331             sortType = SORT_JAVASCRIPT;
332             sortParam = JavascriptSortUtil.getId((HttpServletRequest JavaDoc)pageContext.getRequest());
333         } else {
334             sortType = SORT_CUSTOM;
335         }
336     }
337     
338     public void incrementColumn() {
339         column++;
340     }
341     
342     protected abstract void addItem(StringBuffer JavaDoc in_buffer, String JavaDoc in_item, String JavaDoc in_url, String JavaDoc in_target, String JavaDoc in_onlick) throws JspException JavaDoc;
343     public int doAfterBody() throws JspException JavaDoc {
344         if (first) {
345             // Initialize the iteration
346

347             if (sortType==SORT_LAYOUT) {
348                 // store any nested iterator : the creation of the iterator for paging/iteration loose the nested iterator.
349
CollectionsIterator lc_nestedIterator = iterator.getNestedIterator();
350                 
351                 // get the first collection and iterator
352
Collection JavaDoc lc_collection1 = LayoutUtils.getCollection( LayoutUtils.getBeanFromPageContext(pageContext, name, property), false);
353                 SortUtil.addCollection( lc_collection1, (javax.servlet.http.HttpServletRequest JavaDoc) pageContext.getRequest());
354                 SortUtil lc_sortUtil = (SortUtil) pageContext.getRequest().getAttribute(SortUtil.SORTUTIL_KEY);
355                 if (lc_sortUtil != null) {
356                     // sort util devrait ?tre null si on ne vient pas de la m?me page.
357
lc_collection1 = lc_sortUtil.getSortedCollection();
358
359                 }
360                 
361                 iterator = new CollectionsIterator(lc_collection1, null, id, indexId);
362
363                 // get the second collection and iterator
364
if (name2 != null)
365                     iterator2 = LayoutUtils.getIterator(pageContext, name2, property2);
366                 
367                 // restore the nested iterator.
368
iterator.addLastIterator(lc_nestedIterator);
369                 
370                 size = lc_collection1.size();
371             }
372             
373             Map JavaDoc lc_map = new HashMap JavaDoc();
374             for (int i=0;i<offset;i++) {
375                 if (iterator.hasNext(pageContext)) iterator.skip(pageContext, lc_map);
376                 if (iterator2!=null && iterator2.hasNext()) iterator2.next();
377             }
378
379             TagUtils.write(pageContext, renderHeaders().toString());
380         } else {
381             // End the previous iteration.
382
StringBuffer JavaDoc lc_buffer = new StringBuffer JavaDoc();
383             renderEndLine(lc_buffer);
384             TagUtils.write(pageContext, lc_buffer.toString());
385         }
386         
387         // Flush the tag content.
388
if (bodyContent != null) {
389             TagUtils.writePrevious(pageContext, bodyContent.getString());
390             bodyContent.clearBody();
391         }
392         
393         // Prepare the next iteration.
394

395         if (iterator.hasNext(pageContext) && (length==0 || index < length || iterator.getNestedIterator()!=null && iterator.getNestedIterator().hasNext(pageContext))) {
396             
397             span.clear();
398             bean = iterator.next(pageContext, span);
399
400             if (iterator2!=null && iterator2.hasNext()) {
401                 bean2 = iterator2.next();
402                 if (id2!=null) {
403                     span.put(id2, new Integer JavaDoc(1));
404                     if (bean2!=null) pageContext.setAttribute(id2, bean2);
405                     else pageContext.removeAttribute(id2);
406                 }
407             }
408             
409             int lc_oldIndex = index;
410             index = iterator.getIndex();
411             
412             if (oddId!=null) pageContext.setAttribute(oddId, new Boolean JavaDoc((index-1)%2==0));
413             if (offsetIndexId!=null) pageContext.setAttribute(offsetIndexId, new Integer JavaDoc(index-1+offset));
414             if ((selectName!=null && selectName.length()>0 || selectProperty!=null && selectProperty.length()!=0)&&
415                     (fieldDisplayMode!=FormUtilsInterface.CREATE_MODE) &&
416                     lc_oldIndex!=index) {
417                 needSelect = true;
418             }
419             
420             // support for alternating row styleClass.
421
if (styleClass2!=null) {
422                 String JavaDoc temp = styleClass2;
423                 styleClass2 = styleClass;
424                 styleClass = temp;
425             }
426             
427             StringBuffer JavaDoc lc_buffer = new StringBuffer JavaDoc();
428             renderStartLine(lc_buffer);
429             TagUtils.write(pageContext, lc_buffer.toString());
430
431             first = false;
432             return EVAL_BODY_TAG;
433             
434         } else {
435             first = false;
436             if (id!=null) pageContext.removeAttribute(id);
437             if (id2!=null) pageContext.removeAttribute(id2);
438             if (indexId!=null) pageContext.removeAttribute(indexId);
439             if (oddId!=null) pageContext.removeAttribute(oddId);
440             if (offsetIndexId!=null) pageContext.removeAttribute(offsetIndexId);
441             return SKIP_BODY;
442         }
443     }
444     /**
445      * Returns the current bean in the first collection during an iteration.
446      */

447     public Object JavaDoc getBean() {
448         return bean;
449     }
450     /**
451      * Insert the method's description here.
452      * Creation date: (29/10/2001 10:59:59)
453      * @return java.lang.String
454      */

455     public java.lang.String JavaDoc getEmptyKey() {
456         return emptyKey;
457     }
458     /**
459      * Returns the index of the current bean when iterating.
460      */

461     public int getIndex() {
462         return index - 1;
463     }
464     /**
465      * Insert the method's description here.
466      * Creation date: (17/06/2001 18:33:28)
467      * @return java.lang.String
468      */

469     public java.lang.String JavaDoc getIndexId() {
470         return indexId;
471     }
472     /**
473      * Creation date: (15/06/01 13:23:16)
474      * @return java.lang.String
475      */

476     public java.lang.String JavaDoc getName() {
477         return name;
478     }
479     /**
480      * Creation date: (15/06/01 13:23:16)
481      * @return java.lang.String
482      */

483     public java.lang.String JavaDoc getProperty() {
484         return property;
485     }
486     /**
487      * Insert the method's description here.
488      * Creation date: (24/07/2001 18:19:23)
489      * @return java.lang.String
490      */

491     public java.lang.String JavaDoc getSelectProperty() {
492         return selectProperty;
493     }
494     /**
495      * Insert the method's description here.
496      * Creation date: (24/07/2001 19:08:15)
497      * @return java.lang.String
498      */

499     public java.lang.String JavaDoc getSelectType() {
500         return selectType;
501     }
502     /**
503      * Insert the method's description here.
504      * Creation date: (17/07/2001 11:36:29)
505      * @return java.lang.String
506      */

507     public java.lang.String JavaDoc getSortAction() {
508         return sortAction;
509     }
510     /**
511      * Insert the method's description here.
512      * Creation date: (17/07/2001 12:34:15)
513      * @return java.lang.String
514      */

515     public java.lang.String JavaDoc getSortParam() {
516         return sortParam;
517     }
518     /**
519      * Insert the method's description here.
520      * Creation date: (17/07/2001 11:36:29)
521      * @return java.lang.String
522      */

523     public java.lang.String JavaDoc getSortPictogram() {
524         String JavaDoc lc_property = ((ItemContext)headers.get(getColumn())).getProperty();
525         if (sortType==SORT_LAYOUT && !"none".equals(sortPictogram)) {
526             switch (SortUtil.getSortState((HttpServletRequest JavaDoc)pageContext.getRequest(), lc_property)) {
527                 case -1:
528                     return sortPictogram + ".forward";
529                 case 1:
530                     return sortPictogram + ".reverse";
531                 default:
532                     return sortPictogram;
533             }
534         } else {
535             return sortPictogram;
536         }
537     }
538     public String JavaDoc getSortLabel() {
539         return sortLabel;
540     }
541     /**
542      * Creation date: (15/06/01 13:24:33)
543      * @return java.lang.String
544      */

545     public java.lang.String JavaDoc getStyleClass() {
546         return styleClass;
547     }
548     /**
549      * Insert the method's description here.
550      * Creation date: (09/10/2001 16:28:12)
551      * @return java.lang.String
552      */

553     public java.lang.String JavaDoc getTempStyleClass() {
554         return tempStyleClass;
555     }
556     public String JavaDoc getId() {
557         return id;
558     }
559     public String JavaDoc getId2() {
560         return id2;
561     }
562     public String JavaDoc getName2() {
563         return name2;
564     }
565     public String JavaDoc getProperty2() {
566         return property2;
567     }
568
569     public boolean isFirst() {
570         return first;
571     }
572     public void release() {
573         super.release();
574
575         title = null;
576         arg0Name = null;
577         align = "CENTER";
578         width = null;
579         height = null;
580         bundle = Globals.MESSAGES_KEY;
581         
582         onClick = null;
583         onRowClick = null;
584         onRowDblClick = null;
585         onRowMouseOver = null;
586         onRowMouseOut = null;
587         
588         name = Constants.BEAN_KEY;
589         property = null;
590         id = null;
591         
592         name2 = null;
593         property2 = null;
594         id2 = null;
595         
596         styleClass = null;
597         styleClass2 = null;
598         
599         indexId = null;
600         oddId = null;
601         offsetIndexId = null;
602         
603         sortAction = null;
604         sortPictogram = "layout.sort";
605         sortLabel = "layout.sort.label";
606         
607         selectName = null;
608         selectProperty = null;
609         selectIndex = null;
610         selectId = null;
611         selectType = "checkbox";
612         selectHidden = false;
613         
614         emptyKey = null;
615         
616         model = null;
617     }
618     /**
619      * Reset the variable used internally.
620      */

621     protected void reset() {
622         iterator = null;
623         iterator2 = null;
624         
625         first = true;
626         
627         bean = null;
628         bean2 = null;
629         
630         index = 0;
631         
632         nbOfColumns = 0;
633         column = 0;
634         
635         sortType = SORT_NO;
636         
637         needSelect = false;
638         
639         mathOperationId = null;
640             
641         // these last ones can also be set externally. This can lead to problems with tag pooling.
642
sortParam = null;
643         onRowClick = null;
644         styleId = null;
645         offset = 0;
646         length = 0;
647         
648         headers.clear();
649         tempStyles.clear();
650         
651         span.clear();
652         panel = null;
653         
654         onRowMouseOver = jspOnRowMouseOver; jspOnRowMouseOver = null;
655         onRowMouseOut = jspOnRowMouseOut; jspOnRowMouseOut = null;
656         property = jspProperty; jspProperty = null;
657         
658         styleClass = jspStyleClass;
659         jspStyleClass = null;
660         multiLevelHeaders = null;
661     }
662     /**
663      * Insert the method's description here.
664      * Creation date: (29/10/2001 10:59:59)
665      * @param newEmptyKey java.lang.String
666      */

667     public void setEmptyKey(java.lang.String JavaDoc newEmptyKey) {
668         emptyKey = newEmptyKey;
669     }
670     public void setId(String JavaDoc id) {
671         this.id = id;
672     }
673     public void setId2(String JavaDoc id2) {
674         this.id2 = id2;
675     }
676     /**
677      * Insert the method's description here.
678      * Creation date: (17/06/2001 18:33:28)
679      * @param newIndexId java.lang.String
680      */

681     public void setIndexId(java.lang.String JavaDoc newIndexId) {
682         indexId = newIndexId;
683     }
684     /**
685      * Set the display mode
686      * format is XX,XX,XX where XX can be N (not displayed), E (editable), I (inspectable). Order is create mode, edit mode, inspect mode
687      */

688     public void setMode(String JavaDoc mode) throws JspException JavaDoc {
689         fieldDisplayMode = LayoutUtils.getSkin(pageContext.getSession()).getFormUtils().computeFieldDisplayMode(pageContext, mode);
690     }
691     /**
692      * Creation date: (15/06/01 13:23:16)
693      * @param newName java.lang.String
694      */

695     public void setName(java.lang.String JavaDoc newName) {
696         name = newName;
697     }
698     public void setName2(String JavaDoc name2) {
699         this.name2 = name2;
700     }
701     /**
702      * Creation date: (15/06/01 13:23:16)
703      * @param newProperty java.lang.String
704      */

705     public void setProperty(java.lang.String JavaDoc newProperty) {
706         property = newProperty;
707     }
708     public void setProperty2(String JavaDoc property2) {
709         this.property2 = property2;
710     }
711     public void setSelectName(String JavaDoc name) {
712         selectName = name;
713     }
714     public String JavaDoc getSelectName() {
715         return selectName;
716     }
717     /**
718      * Insert the method's description here.
719      * Creation date: (24/07/2001 18:19:23)
720      * @param newSelectProperty java.lang.String
721      */

722     public void setSelectProperty(java.lang.String JavaDoc newSelectProperty) {
723         selectProperty = newSelectProperty;
724     }
725     /**
726      * Insert the method's description here.
727      * Creation date: (24/07/2001 19:08:15)
728      * @param newSelectType java.lang.String
729      */

730     public void setSelectType(java.lang.String JavaDoc newSelectType) {
731         if (newSelectType == null) {
732             selectType = "checkbox";
733             selectHidden = false;
734         } else {
735             String JavaDoc lc_lower = newSelectType.toLowerCase();
736             if (lc_lower.startsWith("radio")) {
737                 selectType = "radio";
738             } else {
739                 selectType = "checkbox";
740             }
741             if (lc_lower.endsWith("hidden")) {
742                 selectHidden = true;
743             } else {
744                 selectHidden = false;
745             }
746         }
747     }
748     /**
749      * Insert the method's description here.
750      * Creation date: (17/07/2001 11:36:29)
751      * @param newSortAction java.lang.String
752      */

753     public void setSortAction(java.lang.String JavaDoc newSortAction) {
754         sortAction = newSortAction;
755     }
756     /**
757      * Insert the method's description here.
758      * Creation date: (17/07/2001 12:34:15)
759      * @param newSortParam java.lang.String
760      */

761     public void setSortParam(java.lang.String JavaDoc newSortParam) {
762         sortParam = newSortParam;
763     }
764     /**
765      * Insert the method's description here.
766      * Creation date: (17/07/2001 11:36:29)
767      * @param newSortPictogram java.lang.String
768      */

769     public void setSortPictogram(java.lang.String JavaDoc newSortPictogram) {
770         sortPictogram = newSortPictogram;
771     }
772     public void setSortLabel(String JavaDoc newSortLabel) {
773         sortLabel = newSortLabel;
774     }
775     /**
776      * Creation date: (15/06/01 13:24:33)
777      * @param newStyleClass java.lang.String
778      */

779     public void setStyleClass(java.lang.String JavaDoc newStyleClass) {
780         styleClass = newStyleClass;
781     }
782     /**
783      * Insert the method's description here.
784      * Creation date: (09/10/2001 16:28:12)
785      * @param newTempStyleClass java.lang.String
786      */

787     void setTempStyleClass(java.lang.String JavaDoc newTempStyleClass) {
788         tempStyleClass = newTempStyleClass;
789     }
790     void addTempStyle(String JavaDoc in_tempStyle) {
791         tempStyles.add(in_tempStyle);
792     }
793     void removeTempStyle() {
794         tempStyles.remove(tempStyles.size()-1);
795     }
796     /**
797      * Creation date: (15/06/01 13:23:16)
798      * @param newTitle java.lang.String
799      */

800     public void setTitle(java.lang.String JavaDoc newTitle) {
801         title = newTitle;
802     }
803     public void setArg0Name(String JavaDoc in_arg0Name) {
804         arg0Name = in_arg0Name;
805     }
806     public String JavaDoc getArg0Name() {
807         return arg0Name;
808     }
809     public String JavaDoc getTitle() {
810         return title;
811     }
812     public void setWidth(String JavaDoc width) {
813         this.width = width;
814     }
815     public String JavaDoc getWidth() {
816         return width;
817     }
818     /**
819      * Gets the styleClass2.
820      * @return Returns a String
821      */

822     public String JavaDoc getStyleClass2() {
823         return styleClass2;
824     }
825
826     /**
827      * Sets the styleClass2.
828      * @param styleClass2 The styleClass2 to set
829      */

830     public void setStyleClass2(String JavaDoc styleClass2) {
831         this.styleClass2 = styleClass2;
832     }
833
834     /**
835      * Gets the align.
836      * @return Returns a String
837      */

838     public String JavaDoc getAlign() {
839         return align;
840     }
841
842     /**
843      * Sets the align.
844      * @param align The align to set
845      */

846     public void setAlign(String JavaDoc align) {
847         this.align = align;
848     }
849
850     protected void initPanel(PageContext JavaDoc in_pageContext) {
851         try {
852             defaultPanel = (CollectionInterface) LayoutUtils.getSkin(in_pageContext.getSession()).getCollectionClass(model).newInstance();
853         } catch (Exception JavaDoc e) {
854             defaultPanel = new fr.improve.struts.taglib.layout.util.BasicCollection();
855         }
856         panel = defaultPanel;
857     }
858
859     /**
860      * Gets the length.
861      * @return Returns a int
862      */

863     public int getLength() {
864         return length;
865     }
866
867     /**
868      * Sets the length.
869      * @param length The length to set
870      */

871     public void setLength(int length) {
872         this.length = length;
873     }
874
875     /**
876      * Gets the offset.
877      * @return Returns a int
878      */

879     public int getOffset() {
880         return offset;
881     }
882
883     /**
884      * Sets the offset.
885      * @param offset The offset to set
886      */

887     public void setOffset(int offset) {
888         this.offset = offset;
889     }
890     
891     public int getSize() {
892         return size;
893     }
894
895     /**
896      * Gets the selectIndex.
897      * @return Returns a String
898      */

899     public String JavaDoc getSelectIndex() {
900         return selectIndex;
901     }
902     
903     public String JavaDoc getSelectId() {
904         return selectId;
905     }
906
907     /**
908      * Sets the selectIndex.
909      * @param selectIndex The selectIndex to set
910      */

911     public void setSelectIndex(String JavaDoc selectIndex) {
912         this.selectIndex = selectIndex;
913     }
914     public void setSelectId(String JavaDoc selectId) {
915         this.selectId = selectId;
916     }
917     public int doStartLayoutTag() throws JspException JavaDoc {
918         
919         if (fieldDisplayMode == AbstractModeFieldTag.MODE_NODISPLAY)
920             return SKIP_BODY;
921         
922         // inform your parent layout tag we are starting.
923
new StartLayoutEvent(this, new StringBuffer JavaDoc("<td colspan=\"").append(LayoutUtils.getSkin(pageContext.getSession()).getFieldInterface().getColumnNumber()).append("\" valign=\"top\">")).send();
924
925         // get the first collection and iterator
926
Object JavaDoc lc_bean = LayoutUtils.getBeanFromPageContext(pageContext, name, property);
927         Collection JavaDoc lc_collection = LayoutUtils.getCollection(lc_bean);
928         Object JavaDoc lc_mainBean = LayoutUtils.getBeanFromPageContext(pageContext, name, null);
929         iterator = new CollectionsIterator(lc_mainBean, property, id, indexId); //lc_collection.iterator();
930

931         size = lc_collection.size();
932         
933         // get the second collection and iterator
934
if (name2 != null)
935             iterator2 = LayoutUtils.getIterator(pageContext, name2, property2);
936
937         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
938
939         // Init the panel
940
if (panel==null) {
941             initPanel(pageContext);
942         }
943         panel.init(pageContext, styleClass, this);
944
945         // If the collection is empty, display the specified error message.
946
// if (!iterator.hasNext(pageContext) && emptyKey!=null) {
947
// renderBlankCollection(buffer);
948
// TagUtils.write(pageContext, buffer.toString());
949
// return SKIP_BODY;
950
// } else {
951
renderStart(buffer);
952         TagUtils.write(pageContext, buffer.toString());
953         return EVAL_BODY_TAG;
954 // }
955
}
956     
957     /**
958      * Save and computed dynamic values (EL, nested context)
959      */

960     protected void initDynamicValues() {
961         jspOnRowMouseOut = onRowMouseOut;
962         jspOnRowMouseOver = onRowMouseOver;
963         jspProperty = property;
964         jspStyleClass = styleClass;
965         if (styleClass==null) {
966             styleClass = LayoutUtils.getSkin(pageContext.getSession()).getProperty("styleclass.collection", null);
967         }
968         property = NestedHelper.getAdjustedProperty(jspProperty, pageContext);
969         property = Expression.evaluate(property, pageContext);
970         mathOperationId = WidgetUtils.generateId(pageContext.getRequest(),"MATHOP");
971     }
972     
973     public int doEndLayoutTag() throws JspException JavaDoc {
974         if (fieldDisplayMode==AbstractModeFieldTag.MODE_NODISPLAY) return SKIP_BODY;
975         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
976         
977         if (index==0 && emptyKey!=null) {
978             renderBlankCollection(buffer);
979         }
980         
981         renderEnd(buffer);
982         TagUtils.write(pageContext,buffer.toString());
983         
984         new EndLayoutEvent(this, "</td>").send();
985         return EVAL_PAGE;
986     }
987     protected StringBuffer JavaDoc renderHeaders() throws JspException JavaDoc {
988         StringBuffer JavaDoc lc_buffer = new StringBuffer JavaDoc();
989         if (panel instanceof IMultiLevelHeaderRenderer) {
990             renderMultiLevelHeaders(lc_buffer, multiLevelHeaders, headersLevel);
991             column = 0;
992         } else {
993             column = 0;
994             panel.doStartHeaders(lc_buffer);
995             for (int i=0;i<headers.size();i++) {
996                 ItemContext lc_header = (ItemContext) headers.get(i);
997                 renderHeader(lc_buffer, lc_header);
998                 column++;
999             }
1000            column = 0;
1001            panel.doEndHeaders(lc_buffer);
1002        }
1003        column = 0;
1004        return lc_buffer;
1005    }
1006        
1007    /**
1008     * @param lc_buffer
1009     * @param multiLevelHeaders2
1010     * @param headersLevel2
1011     */

1012    protected abstract void renderMultiLevelHeaders(StringBuffer JavaDoc lc_buffer, List JavaDoc multiLevelHeaders2, int headersLevel2) throws JspException JavaDoc;
1013
1014    public void renderEndLine(StringBuffer JavaDoc in_buffer) throws JspException JavaDoc{
1015        panel.doEndItems(in_buffer);
1016        column = 0;
1017    }
1018    public void renderStartLine(StringBuffer JavaDoc in_buffer) throws JspException JavaDoc {
1019        panel.doStartItems(in_buffer);
1020    }
1021
1022    void addIterator(CollectionsIterator in_iterator) {
1023        iterator.addLastIterator(in_iterator);
1024    }
1025    /**
1026     * Returns the column.
1027     * @return int
1028     */

1029    public int getColumn() {
1030        return column;
1031    }
1032
1033    /**
1034     * Returns the nbOfColumns.
1035     * @return int
1036     */

1037    public int getNbOfColumns() {
1038        return nbOfColumns;
1039    }
1040
1041    /**
1042     * Sets the onRowClick.
1043     * @param onRowClick The onRowClick to set
1044     */

1045    public void setOnRowClick(String JavaDoc onRowClick) {
1046        this.onRowClick = onRowClick;
1047    }
1048
1049    /**
1050     * Returns the onRowClick.
1051     * @return String
1052     */

1053    public String JavaDoc getOnRowClick() {
1054        return onRowClick;
1055    }
1056
1057    /**
1058     * Returns the styleId.
1059     * @return String
1060     */

1061    public String JavaDoc getStyleId() {
1062        return styleId;
1063    }
1064
1065    /**
1066     * Sets the styleId.
1067     * @param styleId The styleId to set
1068     */

1069    public void setStyleId(String JavaDoc styleId) {
1070        this.styleId = styleId;
1071    }
1072
1073    /**
1074     * Returns the height.
1075     * @return String
1076     */

1077    public String JavaDoc getHeight() {
1078        return height;
1079    }
1080
1081    /**
1082     * Sets the height.
1083     * @param height The height to set
1084     */

1085    public void setHeight(String JavaDoc height) {
1086        this.height = height;
1087    }
1088    /**
1089     * Returns the oddId.
1090     * @return String
1091     */

1092    public String JavaDoc getOddId() {
1093        return oddId;
1094    }
1095
1096    /**
1097     * Sets the oddId.
1098     * @param oddId The oddId to set
1099     */

1100    public void setOddId(String JavaDoc oddId) {
1101        this.oddId = oddId;
1102    }
1103
1104    /**
1105     * Returns the sortType.
1106     * @return int
1107     */

1108    public int getSortType() {
1109        return sortType;
1110    }
1111
1112    /**
1113     * Sets the sortType. Should be called before do start tag.
1114     * @param sortType The sortType to set
1115     */

1116    public void setSortType(int sortType) {
1117        this.sortType = sortType;
1118        if (sortType==SORT_PAGER) {
1119            findSortType();
1120        }
1121    }
1122
1123    /**
1124     * Returns the onRowDblClick.
1125     * @return String
1126     */

1127    public String JavaDoc getOnRowDblClick() {
1128        return onRowDblClick;
1129    }
1130
1131    /**
1132     * Sets the onRowDblClick.
1133     * @param onRowDblClick The onRowDblClick to set
1134     */

1135    public void setOnRowDblClick(String JavaDoc onRowDblClick) {
1136        this.onRowDblClick = onRowDblClick;
1137    }
1138    public List JavaDoc getHeaders() {
1139        return headers;
1140    }
1141
1142    /**
1143     * Returns the onClick.
1144     * @return String
1145     */

1146    public String JavaDoc getOnClick() {
1147        return onClick;
1148    }
1149
1150    /**
1151     * Sets the onClick.
1152     * @param onClick The onClick to set
1153     */

1154    public void setOnClick(String JavaDoc onClick) {
1155        this.onClick = onClick;
1156    }
1157    public Map JavaDoc getSpans() {
1158        return span;
1159    }
1160    public boolean isNestedIteration() {
1161        return iterator.hasNestedIterator();
1162    }
1163
1164    /**
1165     * @return
1166     */

1167    public String JavaDoc getOnRowMouseOver() {
1168        return onRowMouseOver;
1169    }
1170
1171    /**
1172     * @param string
1173     */

1174    public void setOnRowMouseOver(String JavaDoc string) {
1175        onRowMouseOver = string;
1176    }
1177
1178    /**
1179     * Returns the model.
1180     * @return String
1181     */

1182    public String JavaDoc getModel() {
1183        return model;
1184    }
1185
1186    /**
1187     * Sets the model.
1188     * @param model The model to set
1189     */

1190    public void setModel(String JavaDoc model) {
1191        this.model = model;
1192    }
1193
1194    public String JavaDoc getOnRowMouseOut() {
1195        return onRowMouseOut;
1196}
1197    public void setOnRowMouseOut(String JavaDoc in_onRowMouseOut) {
1198        onRowMouseOut = in_onRowMouseOut;
1199    }
1200
1201    /**
1202     * @param offsetIndexId The offsetIndexId to set.
1203     */

1204    public void setOffsetIndexId(String JavaDoc offsetIndexId) {
1205        this.offsetIndexId = offsetIndexId;
1206    }
1207    /**
1208     * @return Returns the mathOperationId.
1209     */

1210    public String JavaDoc getMathOperationId() {
1211        return mathOperationId;
1212    }
1213    public Object JavaDoc addCollectionTitle(CollectionItemEvent in_event) {
1214        MultiLevelHeader lc_header = (MultiLevelHeader) in_event.getValue();
1215        if (multiLevelHeaders==null) {
1216            multiLevelHeaders = new ArrayList JavaDoc();
1217        }
1218        multiLevelHeaders.add(lc_header);
1219        headersLevel = Math.max(headersLevel, lc_header.getLevel());
1220        return null;
1221    }
1222    /**
1223     * @return Returns the bundle.
1224     */

1225    public String JavaDoc getBundle() {
1226        return bundle;
1227    }
1228    /**
1229     * @param bundle The bundle to set.
1230     */

1231    public void setBundle(String JavaDoc bundle) {
1232        this.bundle = bundle;
1233    }
1234}
1235
Popular Tags