001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id: FacesContextMessageHelper.java 19451 2007-05-27 09:03:18Z sfermigier $ 020 */ 021 022package org.nuxeo.ecm.webapp.helpers; 023 024import javax.faces.application.FacesMessage; 025import javax.faces.context.FacesContext; 026 027/** 028 * Helper to generate JSF context messages. 029 * <p> 030 * Use <h:messages/> to display them client side. 031 * 032 * @author <a href="mailto:[email protected]">Julien Anguenot</a> 033 */ 034@Deprecated 035// TODO: remove (not used) 036public final class FacesContextMessageHelper { 037 038 // Utility class 039 private FacesContextMessageHelper() { 040 } 041 042 /** 043 * Returns a FacesMessage instance. 044 * 045 * @param content the actual message content. 046 * @return a FacesMessage instance 047 */ 048 public static FacesMessage getFacesMessageFor(String content) { 049 return new FacesMessage(content); 050 } 051 052 /** 053 * Appends a FacesMessage to the set of messages associated with the specified client identifier, if clientId is not 054 * null. 055 * 056 * @param fctx the FacesContext 057 * @param content the actual message content. 058 */ 059 public static void addMessageToFctx(FacesContext fctx, String clientId, String content) { 060 if (fctx != null && clientId != null) { 061 fctx.addMessage(clientId, getFacesMessageFor(content)); 062 } 063 } 064 065}