0

Here is the code my util class

 public static void addSuccessMessage(String msg){
 FacesMessage facesMsg=new FacesMessage(FacesMessage.SEVERITY_INFO, "Successfully Inserted" , msg);
  // FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"No results found with "));  
  FacesContext.getCurrentInstance().addMessage("successInfo", facesMsg);
}
public static void addErrorMessage(String msg){
    FacesMessage facesMsg=new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,msg);
    FacesContext.getCurrentInstance().addMessage(null, facesMsg);

here is the default message that is printed can someone plz help me out

<h:messages infoStyle="color:green;" showDetail="false"   />

My message i getting printed like .Successfully inserted i want my message to be in panel for sometime and disappear by Showing success or failur message

this the method that is method that is getting called on performing operation and i am printing my success and failure message through this method

 public String updateEmpActn() throws Exception{
     if("updated".equals(empapp.updtEmpApp())){
          JsfUtil.addSuccessMessage("Successfully Saved");
       //i tried putting this also some error of incompatable type is coming
             FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,"Successfully Saved"));  
         return "inserted";
     }else{
          JsfUtil.addErrorMessage("Not Saved");
         return "notinserted";
     }
user3227175
  • 29
  • 1
  • 10
  • I am not clear on what exactly you need here. Can you explain it better please. – Adarsh Feb 21 '14 at 10:53
  • @adarsh:i am getting a default message like dot successful message i want my message to be displayed as successfully saved for some time in panel with green color and disappear – user3227175 Feb 21 '14 at 10:59
  • What do u mean default message dot successful message ? – Adarsh Feb 21 '14 at 11:05
  • @adarsh:i would like my success or failure messages in form of panel which i have mentioned not like using orlike as like this http://www.primefaces.org/showcase/ui/messages.jsf – user3227175 Feb 21 '14 at 11:10
  • Are you talking about something like growl ? – Adarsh Feb 21 '14 at 11:39
  • its not growl horizontal panel type within which our messages get displayed i would had showed u with an image but my reputation is low or give ur mail id i will mail u – user3227175 Feb 21 '14 at 11:49
  • I cannot post an answer here, but try on the lines of the answers to these questions. http://stackoverflow.com/questions/3694450/how-can-i-show-hide-component-with-jsf and http://stackoverflow.com/questions/12600170/how-to-hide-and-show-ppanel-on-commandbutton-click – Adarsh Feb 21 '14 at 11:51
  • @adarsh :i want my messages to be displayed like this http://www.primefaces.org/showcase/ui/ajaxStatus.jsf on entering text and pressing submit i want to be displayed welcome xyz same like that i want my message to be displayed – user3227175 Feb 21 '14 at 12:06
  • @adarsh: just see the changes i have made in my question – user3227175 Feb 21 '14 at 12:20

1 Answers1

0

You have to update the h:messages in your submit button.

Example:

<h:messages id="msgs" infoStyle="color:green;" showDetail="false" />
...
<p:commandButton value="Update" action="#{myBean.updateSomething}" partialSubmit="true" process="@form" update=":#{p:component('msgs')}" />

Also there's a less "ugly" way to show temporal messages to user by using growl:

<p:growl id="growl_msg" life="10000" />
...
<p:commandButton value="Update" action="#{myBean.updateSomething}" partialSubmit="true" process="@form" update=":#{p:component('growl_msg')}" />
akaine
  • 129
  • 9