01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.jsp.tag.uilib.list;
16:
17: import java.io.Writer;
18: import java.util.ListIterator;
19: import org.araneaframework.uilib.list.ListWidget;
20:
21: /**
22: * List widget rows tag.
23: *
24: * @author Oleg Mürk
25: *
26: * @jsp.tag
27: * name = "listRows"
28: * body-content = "JSP"
29: * description = "Iterating tag that gives access to each row on the UiLib list current page."
30: */
31: public class ListRowsTag extends BaseListRowsTag {
32: protected String var = "row";
33: protected ListWidget.ViewModel viewModel;
34:
35: public int doStartTag(Writer out) throws Exception {
36: // Get list data
37: viewModel = (ListWidget.ViewModel) requireContextEntry(ListTag.LIST_VIEW_MODEL_KEY);
38: return super .doStartTag(out);
39: }
40:
41: protected void doForEachRow(Writer out) throws Exception {
42: super .doForEachRow(out);
43: addContextEntry(var, currentRow);
44: }
45:
46: /**
47: * @jsp.attribute
48: * type = "java.lang.String"
49: * required = "false"
50: * description = "Name of variable that represents individual row (by default "row")."
51: */
52: public void setVar(String var) {
53: this .var = var;
54: }
55:
56: protected ListIterator getIterator() {
57: return viewModel.getItemRange().listIterator();
58: }
59: }
|