001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020 package org.apache.myfaces.tobago.taglib.component; 021 022 import org.apache.myfaces.tobago.component.ComponentUtil; 023 import org.apache.myfaces.tobago.component.UIData; 024 import org.apache.myfaces.tobago.util.Deprecation; 025 026 import javax.faces.component.UIComponent; 027 028 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_COLUMNS; 029 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_DIRECT_LINK_COUNT; 030 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FIRST; 031 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_FORCE_VERTICAL_SCROLLBAR; 032 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ROWS; 033 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SELECTABLE; 034 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DIRECT_LINKS; 035 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_HEADER; 036 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_PAGE_RANGE; 037 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_ROW_RANGE; 038 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STATE; 039 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE; 040 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VAR; 041 042 043 public class SheetTag extends TobagoTag implements SheetTagDeclaration { 044 045 private String var; 046 private String showRowRange = "none"; 047 private String showPageRange = "none"; 048 private String showDirectLinks = "none"; 049 private String directLinkCount = "9"; 050 private String showHeader; 051 private String first = "0"; 052 private String rows = "100"; 053 private String columns; 054 private String value; 055 private String forceVerticalScrollbar; 056 private String state; 057 private String stateChangeListener; 058 private String sortActionListener; 059 private String selectable; 060 061 public String getComponentType() { 062 // TODO: implement uidata with overridden processUpdates to store state 063 return UIData.COMPONENT_TYPE; 064 } 065 066 public void release() { 067 super.release(); 068 var = null; 069 showRowRange = "none"; 070 showPageRange = "none"; 071 showDirectLinks = "none"; 072 directLinkCount = "9"; 073 showHeader = null; 074 first = "0"; 075 rows = "100"; 076 columns = null; 077 value = null; 078 forceVerticalScrollbar = null; 079 state = null; 080 stateChangeListener = null; 081 sortActionListener = null; 082 selectable = null; 083 } 084 085 protected void setProperties(UIComponent component) { 086 super.setProperties(component); 087 UIData data = (UIData) component; 088 ComponentUtil.setStringProperty(data, ATTR_SHOW_ROW_RANGE, showRowRange); 089 ComponentUtil.setStringProperty(data, ATTR_SHOW_PAGE_RANGE, showPageRange); 090 ComponentUtil.setStringProperty(data, ATTR_SHOW_DIRECT_LINKS, showDirectLinks); 091 ComponentUtil.setIntegerProperty(data, ATTR_DIRECT_LINK_COUNT, directLinkCount); 092 ComponentUtil.setBooleanProperty(data, ATTR_SHOW_HEADER, showHeader); 093 ComponentUtil.setIntegerProperty(data, ATTR_FIRST, first); 094 ComponentUtil.setIntegerProperty(data, ATTR_ROWS, rows); 095 ComponentUtil.setStringProperty(data, ATTR_COLUMNS, columns); 096 ComponentUtil.setStringProperty(data, ATTR_VALUE, value); 097 ComponentUtil.setStringProperty(data, ATTR_FORCE_VERTICAL_SCROLLBAR, forceVerticalScrollbar); 098 ComponentUtil.setStringProperty(data, ATTR_VAR, var); 099 ComponentUtil.setValueBinding(component, ATTR_STATE, state); 100 ComponentUtil.setStateChangeListener(data, stateChangeListener); 101 ComponentUtil.setSortActionListener(data, sortActionListener); 102 ComponentUtil.setStringProperty(data, ATTR_SELECTABLE, selectable); 103 } 104 105 public String getColumns() { 106 return columns; 107 } 108 109 public void setColumns(String columns) { 110 this.columns = columns; 111 } 112 113 public String getShowHeader() { 114 return showHeader; 115 } 116 117 public void setShowHeader(String showHeader) { 118 this.showHeader = showHeader; 119 } 120 121 public String getPagingLength() { 122 return rows; 123 } 124 125 public void setPagingLength(String pagingLength) { 126 Deprecation.LOG.error("The attribute 'pagingLength' of 'UISheet' is deprecated, please use 'rows' instead. " 127 + "Refer the documentation for further information."); 128 this.rows = pagingLength; 129 } 130 131 public void setRows(String pagingLength) { 132 this.rows = pagingLength; 133 } 134 135 public String getPagingStart() { 136 return first; 137 } 138 139 public String getStateChangeListener() { 140 return stateChangeListener; 141 } 142 143 public void setPagingStart(String pagingStart) { 144 Deprecation.LOG.error("The attribute 'pagingStart' of 'UISheet' is deprecated, please use 'first' instead. " 145 + "Refer the documentation for further information."); 146 this.first = pagingStart; 147 } 148 149 public void setFirst(String pagingStart) { 150 this.first = pagingStart; 151 } 152 153 public String getValue() { 154 return value; 155 } 156 157 public void setValue(String value) { 158 this.value = value; 159 } 160 161 public String getVar() { 162 return var; 163 } 164 165 public void setVar(String var) { 166 this.var = var; 167 } 168 169 public void setDirectLinkCount(String directLinkCount) { 170 this.directLinkCount = directLinkCount; 171 } 172 173 public void setForceVerticalScrollbar(String forceVerticalScrollbar) { 174 this.forceVerticalScrollbar = forceVerticalScrollbar; 175 } 176 177 public void setShowDirectLinks(String showDirectLinks) { 178 this.showDirectLinks = showDirectLinks; 179 } 180 181 public void setShowPageRange(String showPageRange) { 182 this.showPageRange = showPageRange; 183 } 184 185 public void setShowRowRange(String showRowRange) { 186 this.showRowRange = showRowRange; 187 } 188 189 public void setState(String state) { 190 this.state = state; 191 } 192 193 public void setStateChangeListener(String stateChangeListener) { 194 this.stateChangeListener = stateChangeListener; 195 } 196 197 public void setSortActionListener(String sortActionListener) { 198 this.sortActionListener = sortActionListener; 199 } 200 201 public void setSelectable(String selectable) { 202 this.selectable = selectable; 203 } 204 } 205