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 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ESCAPE; 022 023 import javax.faces.context.FacesContext; 024 import javax.faces.el.ValueBinding; 025 026 /* 027 * Created by IntelliJ IDEA. 028 * User: bommel 029 * Date: 09.02.2006 030 * Time: 23:53:37 031 */ 032 public class UIOutput extends javax.faces.component.UIOutput implements SupportsMarkup { 033 public static final String COMPONENT_TYPE = "org.apache.myfaces.tobago.Output"; 034 private Boolean escape; 035 private String[] markup; 036 private String tip; 037 private boolean createSpan = true; 038 039 @Override 040 public void restoreState(FacesContext context, Object state) { 041 Object[] values = (Object[]) state; 042 super.restoreState(context, values[0]); 043 escape = (Boolean) values[1]; 044 markup = (String[]) values[2]; 045 tip = (String) values[3]; 046 createSpan = (Boolean) values[4]; 047 } 048 049 @Override 050 public Object saveState(FacesContext context) { 051 Object[] values = new Object[5]; 052 values[0] = super.saveState(context); 053 values[1] = escape; 054 values[2] = markup; 055 values[3] = tip; 056 values[4] = createSpan; 057 return values; 058 } 059 060 public boolean isEscape() { 061 if (escape != null) { 062 return escape; 063 } 064 ValueBinding vb = getValueBinding(ATTR_ESCAPE); 065 if (vb != null) { 066 return (Boolean.TRUE.equals(vb.getValue(getFacesContext()))); 067 } else { 068 return true; 069 } 070 } 071 072 public void setEscape(boolean escape) { 073 this.escape = escape; 074 } 075 076 public String[] getMarkup() { 077 if (markup != null) { 078 return markup; 079 } 080 return ComponentUtil.getMarkupBinding(getFacesContext(), this); 081 } 082 083 public void setMarkup(String[] markup) { 084 this.markup = markup; 085 } 086 087 public String getTip() { 088 if (tip != null) { 089 return tip; 090 } 091 ValueBinding vb = getValueBinding(ATTR_TIP); 092 if (vb != null) { 093 return (String) vb.getValue(getFacesContext()); 094 } else { 095 return null; 096 } 097 } 098 099 public void setTip(String tip) { 100 this.tip = tip; 101 } 102 103 public boolean isCreateSpan() { 104 return createSpan; 105 } 106 107 public void setCreateSpan(boolean createSpan) { 108 this.createSpan = createSpan; 109 } 110 111 }