0

Tô começando agora no jsf primefaces e estou com problema. O meu commandButton não tá executando o metodo que tá no managedBean e não tá disparando nada no console quando se clica nele(mesmo quando eu coloco lá pra ele disparar)....

Meu managedBean

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

@ManagedBean
public class GrowlView implements Serializable {

    private static final long serialVersionUID = 1L;
    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void saveMessage() {
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, new FacesMessage("Successful", "Your message: " + message));
        context.addMessage(null, new FacesMessage("Second Message", "Additional Message Detail"));
    }
}

o projeto completo está aqui no github https://github.com/WagnerPaulino/Estudos/tree/master/whit

Meu xhtml aqui

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">

<h:head>
    <title>Hello Word</title>
</h:head>
<h:body>
    <h:form>
        <p:growl id="growl" showDetail="true" sticky="true" />

        <p:panel header="Growl">
            <h:panelGrid columns="2" cellpadding="5">
                <p:outputLabel for="msg" value="Message:" />
                <p:inputText id="msg" value="#{growlView.message}" required="true" />
            </h:panelGrid>

            <p:commandButton value="Save"
                actionListener="#{growlView.saveMessage()}" update="growl" />
        </p:panel>
    </h:form>
</h:body>
</html>
6
  • 1
    Posta o código da sua página
    – Roknauta
    5/02/2017 às 1:58
  • Liga seu debug e veja se o método é acionado.
    – Roknauta
    6/02/2017 às 11:26
  • 1
    Tente mudar o actionListener para action. 6/02/2017 às 13:16
  • Adicioine um scopo em seu Bean, ex.: @RequestScoped e remova os parêntesis do actionListener #{growlView.saveMessage()}
    – Rodrigo
    7/02/2017 às 10:35
  • Remova os parenteses de #{growlView.saveMessage()} 7/02/2017 às 15:53

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .