Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
   * with the License.  You may obtain a copy of the License at
   *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 package org.apache.myfaces.shared.util;
 
 
This class encapsulates a FacesMessage to evaluate the label expression on render response, where f:loadBundle is available

Author(s):
Leonardo Uribe (latest modification by $Author: lu4242 $)
Version:
$Revision: 1299845 $ $Date: 2012-03-12 20:46:16 +0000 (Mon, 12 Mar 2012) $
 
 public class ParametrizableFacesMessage extends FacesMessage
 {
    
 
     private static final long serialVersionUID = 7792947730961657948L;
 
     private final Object _args[];
     private String _evaluatedDetail;
     private String _evaluatedSummary;
     private transient Object _evaluatedArgs[];
     private Locale _locale;
 
     public ParametrizableFacesMessage(
             String summaryString detailObject[] argsLocale locale)
     {
         super(summarydetail);
         if(locale == null)
         {
             throw new NullPointerException("locale");
         }
          = locale;
          = args;
     }
 
             String summaryString detailObject[] argsLocale locale)
     {
         super(severitysummarydetail);
         if(locale == null)
         {
             throw new NullPointerException("locale");
         }
          = locale;
          = args;
     }
 
     @Override
     public String getDetail()
     {
         if ( == null &&  != null)
         {
             evaluateArgs();
         }
         if ( == null)
         {
             MessageFormat format = new MessageFormat(super.getDetail(), );
              = format.format();
         }
         return ;
     }
 
     @Override
     public void setDetail(String detail)
     {
         super.setDetail(detail);
          = null;
     }
     
     public String getUnformattedDetail()
     {
         return super.getDetail();
     }
 
    @Override
    public String getSummary()
    {
        if ( == null &&  != null)
        {
            evaluateArgs();
        }
        if ( == null)
        {
            MessageFormat format = new MessageFormat(super.getSummary(), );
             = format.format();
        }
        return ;
    }
    @Override
    public void setSummary(String summary)
    {
        super.setSummary(summary);
         = null;
    }
    
    public String getUnformattedSummary()
    {
        return super.getSummary();
    }
    private void evaluateArgs()
    {
         = new Object[.];
        FacesContext facesContext = null;
        for (int i = 0; i < .i++)
        {
            if ([i] == null)
            {
                continue;
            }
            else if ([iinstanceof ValueBinding)
            {
                if (facesContext == null)
                {
                    facesContext = FacesContext.getCurrentInstance();
                }
                [i] = ((ValueBinding)[i]).getValue(facesContext);
            }
            else if ([iinstanceof ValueExpression)
            {
                if (facesContext == null)
                {
                    facesContext = FacesContext.getCurrentInstance();
                }
                [i] = ((ValueExpression)[i]).getValue(facesContext.getELContext());
            }
            else 
            {
                [i] = [i];
            }
        }
    }
New to GrepCode? Check out our FAQ X