Modal não faz submit

Pessoal,

Bom Feriado a todos! :smiley:
Estou começando com JSF (Richfaces) e estavafazendo uma telinha de login, e tem um modal, mas quando ele aparece o usuário digita as informações, mas quando faz o submit ele não "popula" o meu bean e retorna null.

Segue alguns códigos:

index.jsf

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:a4j="http://richfaces.org/a4j">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link href="css/style.css" type="text/css" rel="stylesheet"/>
        <title>#{msg['user.login']}</title>
    </head>
    <body background="images/background.jpg">
    <style type="text/css">
            .rich-message-marker img {
                padding-right:7px;
            }
            .rich-message-label {
                color:red;
            }
        </style>
    	<f:view>
            <a4j:region>
                <a4j:form id="login">
                    <rich:panel header="#{msg['user.login']}" style="width: 240px; margin: 0 auto">
                        <h:panelGrid columns="2" >
                            <h:outputLabel value="#{msg['user.user']}:" for="name"/>
                            <h:inputText id="name" value="#{userMB.user.username}" required="true" requiredMessage="#{msg['user.userRequired']}" autocomplete="off" maxlength="15" size="18" tabindex="1"/>
                            <h:outputLabel value="#{msg['user.password']}:"/>
                            <h:inputSecret id="password" value="#{userMB.user.password}" required="true" requiredMessage="#{msg['user.passwordRequired']}" maxlength="15" size="18" tabindex="2"/>
                        </h:panelGrid>
						<a4j:commandLink id="forgetMyPasswordLink" immediate="true" value="#{msg['user.forgetmypassword']}">
                           	<rich:componentControl for="panelMail" attachTo="forgetMyPasswordLink" operation="show" event="onclick"/>
                       	</a4j:commandLink>
                       	<rich:spacer width="10px"/>
                    	<a4j:commandButton action="#{userMB.validateLogin}" onclick="this.disabled=true" oncomplete="this.disabled=false" value="#{msg ['general.ok']}" tabindex="3" type="submit" styleClass="button"/>						                        
                        <br/>&lt;a4j:status id="text" startText="#{msg['action.inprogress']}"/&gt;
                        &lt;rich:messages layout="list"&gt;
                            &lt;f:facet name="errorMarker"&gt;
                                &lt;h:graphicImage value="images/error.gif" styleClass="pic" /&gt;
                            &lt;/f:facet&gt;
                        &lt;/rich:messages&gt;
                    &lt;/rich:panel&gt;
                    <br/><br/>
                &lt;/a4j:form&gt;
            &lt;/a4j:region&gt;
            &lt;a4j:region&gt;
                &lt;a4j:form id="forget" ajaxSubmit="true"&gt;
                    &lt;rich:modalPanel id="panelMail" resizeable="false" autosized="true"&gt;
                        &lt;f:facet name="header"&gt;
                            &lt;h:panelGroup&gt;
                                &lt;h:outputText value="#{msg['user.forgetmypassword']}"&gt;
                                &lt;/h:outputText&gt;
                            &lt;/h:panelGroup&gt;
                        &lt;/f:facet&gt;
                        &lt;f:facet name="controls"&gt;
                            &lt;h:panelGroup&gt;
                                &lt;h:graphicImage value="/images/close.png" id="hidelink" styleClass="hidelink"/&gt;
                                &lt;rich:componentControl for="panelMail" attachTo="hidelink" operation="hide" event="onclick"/&gt;
                            &lt;/h:panelGroup&gt;
                        &lt;/f:facet&gt;
                        &lt;h:panelGrid id="mailForm" columns="3"&gt;
                            &lt;h:outputLabel value="#{msg['general.email']}"/&gt;
                            &lt;h:inputText id="mail" value="#{userMB.user.email}" maxlength="40" size="25" required="true" requiredMessage="#{msg['user.emailRequired']}"&gt;
                                &lt;f:validateLength minimum="4" maximum="25"/&gt;
                            &lt;/h:inputText&gt;
                            &lt;a4j:commandButton id="send" action="#{userMB.forgetMyPassword}" value="#{msg['general.send']}" type="submit" styleClass="button"&gt;
                                &lt;rich:componentControl for="panelMail" attachTo="send" operation="hide" event="onclick"/&gt;
                            &lt;/a4j:commandButton&gt;
                        &lt;/h:panelGrid&gt;
                    &lt;/rich:modalPanel&gt;
                &lt;/a4j:form&gt;
            &lt;/a4j:region&gt;
        &lt;/f:view&gt;
    &lt;/body&gt; 
&lt;/html&gt;

meu bean simples:

[code]/**
*
*/
package org.noip.moviespace.jsf.managedbeans;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.noip.moviespace.model.User;

/**

  • @author gustavo.silva

  • @since 16/03/2009

  • @version 1.0
    */
    public class UserMB {

    private User user = new User();

    // gets e sets do User

    /**
    *

    • @return
      */
      public String validateLogin() {
      if (user.validateUser()) {
      // DAOFactory factory = new DAOFactory();
      FacesContext facesContext = FacesContext.getCurrentInstance();
      facesContext.getExternalContext().getSessionMap().put(“user”, user);
      return “OK”;
      } else {
      FacesContext.getCurrentInstance().addMessage(null,
      new FacesMessage(“Usuário e/ou senha inválidos!”));
      return null;
      }
      }

    public String forgetMyPassword() {
    System.out.println(user.getEmail());
    return null;
    }

}
[/code]

e meu model:

[code]/**
*
*/
package org.noip.moviespace.model;

import java.io.Serializable;
import java.sql.SQLException;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.Email;
import org.hibernate.validator.NotEmpty;
import org.noip.moviespace.hibernate.DAO.DAOFactory;
import org.noip.moviespace.security.EncriptyPassword;

/**

  • @author gustavo.silva
  • @since 15/06/2008
  • @version 1.0
    */

@Entity
@Table(name = “TMS_EMPLOYEE_USERS”)
public class User implements Serializable {

// @Transient
// transient Logger logger = Logger.getLogger(User.class);

/**
 * 
 */
private static final long serialVersionUID = 4636756747700250066L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "EMPLOYEE_ID")
private Integer id;

@NotEmpty
@Column(name = "EMPLOYEE_USER_NAME", unique = true, nullable = false, length = 25)
private String username;

@NotEmpty
@Column(name = "EMPLOYEE_PASSWORD", unique = false, nullable = false, length = 50)
private String password;

@Email
@NotEmpty
@Column(name = "EMPLOYEE_EMAIL", unique = true, nullable = false, length = 40)
private String email;

@Column(name = "EMPLOYEE_ENABLED", unique = false, nullable = true)
private boolean enabled;

// gets e sets

public boolean validateUser() {
    // logger.debug("Validating User");
	boolean unique = false;
    DAOFactory factory = new DAOFactory();
    try {
    	unique = factory.getUserDao().validateLogin(this);
    } catch (SQLException e) {
		// TODO: handle exception
    	e.printStackTrace();
	} finally {
		factory.close();
	}
	return unique;
}

}[/code]

Obrigado pela ajuda de todos! 8)

Pessoal,

Retirei algumas partes do código pra melhorar a visualização.
Meu problemas está que o Modal Panel não faz submit, quando eu coloco “esqueci minha senha” e abre o modal eu coloco o email, mas quando faço o submiti ele fecha o modal e quando vou ver o valor do atributo está nulo! Alguém sabe como fazer isso com o modal??

Abraços, 8)

Fala…

Se eu não me engano já tive esse problema e solucionei trocando o
a4j:commandButton do model por <h:commandButton>

flw

Eu descobri o meu problema. De acordo com o manual, existem algumas limitações relativas à apresentação de um painel modal:
1.) Um formulário deve ser declarado dentro do painel modal (e, portanto, o painel modal deve ser definida fora de qualquer forma existente para evitar formas aninhados).
2.) O painel modal não pode ser incluído na página. Deve ser na base da página.

Espero que isso ajude outras pessoas que têm esse problema.