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_TIP; 021 022 import javax.faces.el.ValueBinding; 023 import javax.faces.context.FacesContext; 024 025 /* 026 * User: bommel 027 * Date: Apr 24, 2007 028 * Time: 8:07:24 PM 029 */ 030 public class UIProgress extends javax.faces.component.UIOutput implements SupportsMarkup { 031 private String[] markup; 032 private String tip; 033 034 @Override 035 public void restoreState(FacesContext context, Object state) { 036 Object[] values = (Object[]) state; 037 super.restoreState(context, values[0]); 038 markup = (String[]) values[1]; 039 tip = (String) values[2]; 040 } 041 042 @Override 043 public Object saveState(FacesContext context) { 044 Object[] values = new Object[3]; 045 values[0] = super.saveState(context); 046 values[1] = markup; 047 values[2] = tip; 048 return values; 049 } 050 051 public String[] getMarkup() { 052 if (markup != null) { 053 return markup; 054 } 055 return ComponentUtil.getMarkupBinding(getFacesContext(), this); 056 } 057 058 public void setMarkup(String[] markup) { 059 this.markup = markup; 060 } 061 062 public String getTip() { 063 if (tip != null) { 064 return tip; 065 } 066 ValueBinding vb = getValueBinding(ATTR_TIP); 067 if (vb != null) { 068 return (String) vb.getValue(getFacesContext()); 069 } else { 070 return null; 071 } 072 } 073 074 public void setTip(String tip) { 075 this.tip = tip; 076 } 077 078 }