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