tag p:commandButton does not do what is in managedBean

Asked

Viewed 109 times

0

I’m starting now at jsf primefaces and I’m in trouble. My commandButton is not executing the method that is in managedBean and is not shooting anything on the console when you click on it (even when I put it there to shoot)....

My 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"));
    }
}

the full project is here at github https://github.com/WagnerPaulino/Estudos/tree/master/whit

My xhtml here

<!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>
  • 1

    Post the code on your page

  • Turn on your debug and see if the method is triggered.

  • 1

    Try changing actionListener to action.

  • Add a scopo to your bean, ex.: @RequestScoped and remove the parentheses from actionListener #{growlView.saveMessage()}

  • Remove the parentheses of #{growlView.saveMessage()}

  • Hi guys. It was the java el dependency that was missing from my pom.xml

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.