1

I need to display messages with jGrowl like this:

enter image description here

I need to store the messages into the managed bean using Map. The tricky part is that I want to display the messages into the Map right after they are inserted. The solution I suppose will be to make Ajax calls infinitely to the server from the browser. How can I achieve this in JSF?

1

1 Answer 1

1

It is really easy if you can use prime faces

in xhtml

<p:panel header="Map">  
    <h:panelGrid columns="3">  
        <h:outputText value="Map Info: " />   
        <p:inputText value="#{myBean.key}" label="Name"/>  
        <p:inputText value="#{myBean.value}" label="Name"/> 
    </h:panelGrid>  

    <p:commandButton value="Save" actionListener="#{myBean.save}" update="growl"/>  
</p:panel>  

in java

public class MyBean {

private String key;  
private String value;  

public String getKey() {  
    return text;  
}  
public void setKey(String key) {  
    this.key = key;  
}

public String getValue() {  
    return value;  
}  
public void setValue(String value) {  
    this.value = value;  
}   

public void save(ActionEvent actionEvent) {  
    FacesContext context = FacesContext.getCurrentInstance();  

    context.addMessage(null, new FacesMessage("Successful", "Key : " + key + " Value : " + value));    
}  

}

for more details use this link http://www.primefaces.org/showcase-labs/ui/growl.jsf

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.