KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > UIFormWithInformationProvider


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.faces.core.component;
6
7 import java.io.IOException JavaDoc;
8 import java.util.List JavaDoc;
9
10 import javax.faces.application.FacesMessage;
11 import javax.faces.context.FacesContext;
12 import org.exoplatform.faces.core.component.model.Information;
13
14 /**
15  * Jun 2, 2004
16  * @author: Tuan Nguyen
17  * @email: tuan08@users.sourceforge.net
18  * @version: $ID$
19  **/

20 public class UIFormWithInformationProvider extends UISimpleForm implements InformationProvider {
21     private Information information_ = new Information() ;
22     private int displayMessageType_ = FOOTER_MESSAGE_TYPE ;
23     
24     public UIFormWithInformationProvider(String JavaDoc name, String JavaDoc method, String JavaDoc formId) {
25       super(name, method, formId) ;
26     }
27     
28     public int getDisplayMessageType() { return displayMessageType_ ; }
29     public void setDisplayMessageType(int type) { displayMessageType_ = type ; }
30     public void addMessage(FacesMessage message) { information_.addMessage(message); }
31     public void clearMessages() { information_.clearMessages() ;}
32   public List JavaDoc getMessages() { return information_.getMessages() ; }
33     public boolean hasMessage() { return information_.hasMessage() ; }
34     
35     public void encodeChildren(FacesContext context) throws IOException JavaDoc {
36     if(information_.hasMessage()) {
37       if(displayMessageType_ == BODY_MESSAGE_TYPE) {
38         Information.renderBodyInformation(context, this) ;
39         return ;
40       }
41     }
42     super.encodeChildren(context);
43     if(information_.hasMessage()) {
44       if(displayMessageType_ == FOOTER_MESSAGE_TYPE) {
45         Information.renderFooterInformation(context, this) ;
46         return ;
47       }
48     }
49   }
50 }
Popular Tags