Custom message with FacesContext.getCurrentInstance().addMessage is not displayed in page (JSF)

Posted by bblanco on Stack Overflow See other posts from Stack Overflow or by bblanco
Published on 2010-02-26T11:20:45Z Indexed on 2010/03/29 12:53 UTC
Read the original article Hit count: 2300

Filed under:
|
|

Hi!

My page:

...
    <div id="header">
       <!-- content header -->
     </div>
     <div id="content">
       <h:messages />
       <h:ouputText value="#{example.text}" />
     </div>
...

My managedBean:

public class ExampleManagedBean(){
       private String text;


       public String getText(){
           FacesContext.getCurrentInstance().
                   addMessage(null, 
                      new FacesMessage(FacesMessage.SEVERITY_WARN, 
                                       "Warning message...", null));
           return text;
       }

       public void setText(String text){
           this.text = text;
       }
   }

My problem is that the warning message not is rendered in page. Why?

© Stack Overflow or respective owner

Related posts about jsf

Related posts about java