action does not work in p:commandButton

UI Components for JSF
Post Reply
khall
Posts: 4
Joined: 30 Mar 2016, 22:26

17 Dec 2017, 19:18

Hi everyone.

In my login.xhtml page the action does not call my managed bean method when I click on commandButton.


My login.xhtml is:

<div class="ui-g-12">
<p:commandButton value="Entrar" update="growl"
action="#{loginBean.validaLogin}" icon="ui-icon-person"/>
</div>


my method in LoginBean.java is:

public String validaLogin() {

String retorno = "login_ok";

EntityManagerFactory factory = Persistence.createEntityManagerFactory("scorpius");
EntityManager manager = factory.createEntityManager();

return retorno;

}



My faces-config.xml is :

<?xml version="1.0" encoding="utf-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-f ... ig_2_0.xsd">

<name>primefaces_serenity</name>

<navigation-rule>
<from-view-id>/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>login_ok</from-outcome>
<to-view-id>/dashboard.xhtml</to-view-id>
</navigation-case>
</navigation-rule> .....
I use eclipse IDE, MySql, JSF javax.faces-2.2.8.jar, tomcat 8, primefaces 6.0, hibernate-5.2.12.Final.jar and serenity theme.

khall
Posts: 4
Joined: 30 Mar 2016, 22:26

18 Dec 2017, 04:16

I found my fault. The p:commandButton wasn't into a form in my web page. Solved.
I use eclipse IDE, MySql, JSF javax.faces-2.2.8.jar, tomcat 8, primefaces 6.0, hibernate-5.2.12.Final.jar and serenity theme.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 33 guests