001    package org.apache.myfaces.tobago.application;
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 javax.el.ValueExpression;
021    import javax.faces.application.FacesMessage;
022    import javax.faces.context.FacesContext;
023    
024    public class LabelValueExpressionFacesMessage extends FacesMessage {
025      public LabelValueExpressionFacesMessage() {
026        super();
027      }
028    
029      public LabelValueExpressionFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
030        super(severity, summary, detail);
031      }
032    
033      public LabelValueExpressionFacesMessage(String summary, String detail) {
034        super(summary, detail);
035      }
036    
037      public LabelValueExpressionFacesMessage(String summary) {
038        super(summary);
039      }
040    
041      @Override
042      public String getDetail() {
043        FacesContext facesContext = FacesContext.getCurrentInstance();
044        ValueExpression value = facesContext.getApplication().getExpressionFactory().
045            createValueExpression(facesContext.getELContext(), super.getDetail(), String.class);
046        return (String) value.getValue(facesContext.getELContext());
047      }
048    
049      @Override
050      public String getSummary() {
051        FacesContext facesContext = FacesContext.getCurrentInstance();
052        ValueExpression value = facesContext.getApplication().getExpressionFactory().
053            createValueExpression(facesContext.getELContext(), super.getSummary(), String.class);
054        return (String) value.getValue(facesContext.getELContext());
055      }
056    
057    
058    }