001 package org.apache.myfaces.tobago.taglib.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_FOR; 021 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_GLOBAL_ONLY; 022 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MAX_NUMBER; 023 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MAX_SEVERITY; 024 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_MIN_SEVERITY; 025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_ORDER_BY; 026 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_DETAIL; 027 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_SHOW_SUMMARY; 028 import org.apache.myfaces.tobago.component.ComponentUtil; 029 import org.apache.myfaces.tobago.component.UIMessages; 030 031 import javax.faces.component.UIComponent; 032 import javax.faces.webapp.UIComponentTag; 033 034 035 public class MessagesTag extends TobagoTag 036 implements MessagesTagDeclaration { 037 038 private String forComponent; 039 private String showSummary; 040 private String showDetail; 041 private String globalOnly; 042 private String minSeverity; 043 private String maxSeverity; 044 private String maxNumber; 045 private String orderBy; 046 047 public String getComponentType() { 048 return UIMessages.COMPONENT_TYPE; 049 } 050 051 protected void setProperties(UIComponent component) { 052 super.setProperties(component); 053 ComponentUtil.setStringProperty(component, ATTR_FOR, forComponent); 054 ComponentUtil.setBooleanProperty(component, ATTR_GLOBAL_ONLY, globalOnly); 055 ComponentUtil.setBooleanProperty(component, ATTR_SHOW_SUMMARY, showSummary); 056 ComponentUtil.setBooleanProperty(component, ATTR_SHOW_DETAIL, showDetail); 057 ComponentUtil.setStringProperty(component, ATTR_MIN_SEVERITY, minSeverity); 058 ComponentUtil.setStringProperty(component, ATTR_MAX_SEVERITY, maxSeverity); 059 ComponentUtil.setStringProperty(component, ATTR_MAX_NUMBER, maxNumber); 060 setOrderByProperty(component, ATTR_ORDER_BY, orderBy); 061 } 062 063 private void setOrderByProperty(UIComponent component, String name, String value) { 064 if (value != null) { 065 if (UIComponentTag.isValueReference(value)) { 066 component.setValueBinding(name, ComponentUtil.createValueBinding(value)); 067 } else { 068 component.getAttributes().put(name, UIMessages.OrderBy.parse(value)); 069 } 070 } 071 } 072 073 074 075 public void release() { 076 super.release(); 077 forComponent = null; 078 showSummary = null; 079 showDetail = null; 080 minSeverity = null; 081 maxSeverity = null; 082 maxNumber = null; 083 orderBy = null; 084 } 085 086 public String getFor() { 087 return forComponent; 088 } 089 090 public void setFor(String forComponent) { 091 this.forComponent = forComponent; 092 } 093 094 public void setGlobalOnly(String globalOnly) { 095 this.globalOnly = globalOnly; 096 } 097 098 public void setShowSummary(String showSummary) { 099 this.showSummary = showSummary; 100 } 101 102 public void setShowDetail(String showDetail) { 103 this.showDetail = showDetail; 104 } 105 106 public void setMinSeverity(String minSeverity) { 107 this.minSeverity = minSeverity; 108 } 109 110 public void setMaxSeverity(String maxSeverity) { 111 this.maxSeverity = maxSeverity; 112 } 113 114 public void setMaxNumber(String maxNumber) { 115 this.maxNumber = maxNumber; 116 } 117 118 public void setOrderBy(String orderBy) { 119 this.orderBy = orderBy; 120 } 121 }