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.component; 021 022 import org.apache.myfaces.tobago.TobagoConstants; 023 024 import javax.faces.context.FacesContext; 025 026 027 public class UICell extends UIPanelBase { 028 029 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Cell"; 030 031 private Integer spanX; 032 private Integer spanY; 033 private String scrollbars; 034 035 public Integer getSpanX() { 036 if (spanX != null) { 037 return spanX; 038 } 039 javax.faces.el.ValueBinding vb = getValueBinding(TobagoConstants.ATTR_SPAN_X); 040 if (vb != null) { 041 Number number = (Number) vb.getValue(getFacesContext()); 042 if (number != null) { 043 return number.intValue(); 044 } 045 } 046 return 1; 047 } 048 049 public void setSpanX(Integer spanX) { 050 this.spanX = spanX; 051 } 052 053 public Integer getSpanY() { 054 if (spanY != null) { 055 return spanY; 056 } 057 javax.faces.el.ValueBinding vb = getValueBinding(TobagoConstants.ATTR_SPAN_Y); 058 if (vb != null) { 059 Number number = (Number) vb.getValue(getFacesContext()); 060 if (number != null) { 061 return number.intValue(); 062 } 063 } 064 return 1; 065 } 066 067 public void setSpanY(Integer spanY) { 068 this.spanY = spanY; 069 } 070 071 public String getScrollbars() { 072 if (scrollbars != null) { 073 return scrollbars; 074 } 075 javax.faces.el.ValueBinding vb = getValueBinding(TobagoConstants.ATTR_SCROLLBARS); 076 if (vb != null) { 077 java.lang.String scrollbars = (java.lang.String) vb.getValue(getFacesContext()); 078 if (scrollbars != null) { 079 return scrollbars; 080 } 081 } 082 return "false"; 083 } 084 085 public void setScrollbars(String scrollbars) { 086 this.scrollbars = scrollbars; 087 } 088 089 public void restoreState(FacesContext context, Object state) { 090 Object[] values = (Object[]) state; 091 super.restoreState(context, values[0]); 092 spanX = (Integer) values[1]; 093 spanY = (Integer) values[2]; 094 scrollbars = (String) values[3]; 095 } 096 097 public Object saveState(FacesContext context) { 098 Object[] values = new Object[4]; 099 values[0] = super.saveState(context); 100 values[1] = spanX; 101 values[2] = spanY; 102 values[3] = scrollbars; 103 return values; 104 } 105 }