Diego Nieto
Diego Nieto

Reputation: 721

actionListener doesn't works jsf and primefaces

I have one .xhtml file with primefaces and have one form with one commandButton when try to fire the actionListener doesn't works this is the form:

<h:form id="formCreate">
                <p:dialog header="Crear" widgetVar="usuarioDlgCreate" resizable="false" id="usuDlgCreate"  
                          showEffect="fade" hideEffect="explode" modal="true">  

                    <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  

                        <h:outputText value="Rol:" />  
                        <p:inputText value="#{usuarioBean.usuarioSeleccionado.rolId}"/>  

                        <h:outputText value="Nombre:" />  
                        <p:inputText value="#{usuarioBean.usuarioSeleccionado.nomUsuario}"/>  


                        <h:outputText value="Email:" />  
                        <p:inputText value="#{usuarioBean.usuarioSeleccionado.email}" size="30"/>  

                        <f:facet name="footer">
                            <p:separator/>
                            <p:commandButton id="btnNewAccept" actionListener="#{usuarioBean.create(actionEvent)}" title="Guardar" value="Guardar"/>  
                            <p:commandButton id="btnNewCancel" oncomplete="usuarioDlgCreate.hide()" icon="ui-icon-new" title="Cancelar" value="Cancelar"/>  
                        </f:facet>
                    </h:panelGrid>  

                </p:dialog>  

            </h:form>

and this is my bean method:

public void create(ActionEvent actionEvent) {
   UsuarioDao usuarioDao = new UsuarioDaoImplements();
   String msg = null;
   if(usuarioDao.create(this.usuarioSeleccionado)) {
       msg = "Información guardada correctamente";
   } else {
       msg = "No ha sido posible almacenar la información";
   }

    FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, null);
    FacesContext.getCurrentInstance().addMessage(null, message);
}

already tried with the button like:

and the method without the parameter ActionEvent:

and like this too(without parenthesis):

but doesn't fire the method, pleas help me.... thanks a lot

Upvotes: 1

Views: 2377

Answers (4)

Diego Nieto
Diego Nieto

Reputation: 721

Well, I solved this it seems Primefaces 3.5 and Glassfish 4.0 doesn't work very well, so I changed by Primefaces 4.0 and it works.

Upvotes: 0

SkaiiNyght
SkaiiNyght

Reputation: 63

Try putting your form inside of the dialog - not the other way around

Upvotes: 0

Ales M-Power
Ales M-Power

Reputation: 11

I have similar issue, actionListener didn't fired when I used in component as value expression object. Submit wasn't successful and no error message showed (also no logged). So I change value expression to simple variable: integer, string etc. and after that work for me.

before:

<p:selectOneMenu value="#{formCalendarDay.airplane}">
  <f:selectItems value="#{classifiers.airplanes}" var="airplane" itemLabel="#{airplane.name}" itemValue="#{airplane}"/>  
</p:selectOneMenu> 

after fix:

<p:selectOneMenu value="#{formCalendarDay.airplaneId}">
  <f:selectItems value="#{classifiers.airplanes}" var="airplane" itemLabel="#{airplane.name}" itemValue="#{airplane.id}"/>  
</p:selectOneMenu> 

Upvotes: 1

Alexandre Lavoie
Alexandre Lavoie

Reputation: 8771

The first thing, you should change your attribute like this : actionListener="#{usuarioBean.create}".

Second, make sure you are using javax.faces.event.ActionEvent.

If it still doesn't work, you should verify for validation errors, you can try by adding h:messages to see if something goes wrong.

Upvotes: 0

Related Questions