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