001 package org.apache.myfaces.tobago.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 static org.apache.myfaces.tobago.TobagoConstants.ATTR_ALIGN; 021 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SORTABLE; 022 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_LABEL; 023 024 import javax.faces.context.FacesContext; 025 import javax.faces.el.ValueBinding; 026 027 028 /* 029 * Created by IntelliJ IDEA. 030 * User: bommel 031 * Date: 18.04.2006 032 * Time: 21:50:29 033 */ 034 public class UIColumn extends javax.faces.component.UIColumn implements SupportsMarkup { 035 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Column"; 036 private Boolean sortable; 037 private String align; 038 private String label; 039 private String[] markup; 040 041 public void restoreState(FacesContext context, Object state) { 042 Object[] values = (Object[]) state; 043 super.restoreState(context, values[0]); 044 align = (String) values[1]; 045 sortable = (Boolean) values[2]; 046 label = (String) values[3]; 047 markup = (String[]) values[4]; 048 } 049 050 public Object saveState(FacesContext context) { 051 Object[] values = new Object[5]; 052 values[0] = super.saveState(context); 053 values[1] = align; 054 values[2] = sortable; 055 values[3] = label; 056 values[4] = markup; 057 return values; 058 } 059 060 public String[] getMarkup() { 061 if (markup != null) { 062 return markup; 063 } 064 return ComponentUtil.getMarkupBinding(getFacesContext(), this); 065 } 066 067 public void setMarkup(String[] markup) { 068 this.markup = markup; 069 } 070 071 public boolean isSortable() { 072 if (sortable != null) { 073 return sortable; 074 } 075 ValueBinding vb = getValueBinding(ATTR_SORTABLE); 076 if (vb != null) { 077 return (Boolean.TRUE.equals(vb.getValue(getFacesContext()))); 078 } else { 079 return false; 080 } 081 } 082 083 public void setSortable(boolean sortable) { 084 this.sortable = sortable; 085 } 086 087 public String getAlign() { 088 if (align != null) { 089 return align; 090 } 091 ValueBinding vb = getValueBinding(ATTR_ALIGN); 092 if (vb != null) { 093 return (String) vb.getValue(getFacesContext()); 094 } else { 095 return align; 096 } 097 } 098 099 public void setAlign(String align) { 100 this.align = align; 101 } 102 103 public String getLabel() { 104 if (label != null) { 105 return label; 106 } 107 ValueBinding vb = getValueBinding(ATTR_LABEL); 108 if (vb != null) { 109 return (String) vb.getValue(getFacesContext()); 110 } else { 111 return label; 112 } 113 } 114 115 public void setLabel(String label) { 116 this.label = label; 117 } 118 119 }