01: /**********************************************************************************
02: *
03: * $Id: DivMessageRenderer.java 9271 2006-05-10 21:52:49Z ray@media.berkeley.edu $
04: *
05: ***********************************************************************************
06: *
07: * Copyright (c) 2005 The Regents of the University of California, The MIT Corporation
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: **********************************************************************************/package org.sakaiproject.tool.gradebook.jsf;
22:
23: import java.io.IOException;
24: import java.util.Iterator;
25:
26: import javax.faces.application.FacesMessage;
27: import javax.faces.component.UIComponent;
28: import javax.faces.component.UIMessage;
29: import javax.faces.context.FacesContext;
30:
31: import org.apache.commons.logging.Log;
32: import org.apache.commons.logging.LogFactory;
33:
34: /**
35: * Put the message in a "div" instead of a "span", allowing for much more
36: * positioning control.
37: */
38:
39: public class DivMessageRenderer extends DivMessageRendererBase {
40: private static final Log logger = LogFactory
41: .getLog(DivMessageRenderer.class);
42:
43: public void encodeEnd(FacesContext context, UIComponent component)
44: throws IOException {
45: // Note our complete disregard for class cast and null exceptions....
46: UIMessage uiMessage = (UIMessage) component;
47: String clientId = uiMessage.findComponent(uiMessage.getFor())
48: .getClientId(context);
49:
50: Iterator iter = context.getMessages(clientId);
51: if (iter.hasNext()) {
52: // Just do the first one.
53: FacesMessage message = (FacesMessage) iter.next();
54: renderMessage(context, component, message);
55: }
56: }
57: }
|