commandButton actionListener not called when using calendar

UI Components for JSF
Post Reply
tozar
Posts: 2
Joined: 16 Aug 2017, 17:11

28 Aug 2017, 17:57

Hi,

I started working with JSF and primefaces a short time ago.

I have a problem using the primefaces calendar and commandButton actionListener() method. When the calendar component is used, then the commanButton's actionListener() never gets called. Commenting out the calendar in the xhtml will cause the commandButton's actionListener() to get called again.

Is there something simple I'm overlooking or are these two not compatible with each other?

Thank you in advance for any comments or suggestions!


Below is the sample code for showing the problem:

advancedsearch.xhtml:

<?xml version="1.0" encoding="UTF-8"?>
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:separator />
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel for="from_cal" value="From:" />
<p:calendar id="from_cal" value="#{dtAdvancedSearch.from_cal}" />
<p:outputLabel for="to_cal" value="To:" />
<p:calendar id="to_cal" value="#{dtAdvancedSearch.to_cal}" />
</h:panelGrid>
<p:separator />
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
<p:commandButton value="Submit Request" actionListener="#{dtAdvancedSearch.info}" />
</h:form>
</h:body>
</html>


AdvancedSearch.java:

package com.test.outage;

import java.util.Date;
import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

@ManagedBean(name="dtAdvancedSearch")
@SessionScoped
public class AdvancedSearch implements Serializable {
private static final long serialVersionUID = 1L;

public AdvancedSearch() {
}

private Date from_cal;
public Date getFrom_cal() {
return from_cal;
}
public Date setFrom_cal(Date value) {
return from_cal = value;
}

private Date to_cal;
public Date getTo_cal() {
return to_cal;
}
public Date setTo_cal(Date value) {
return to_cal = value;
}

public void info() {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Info", "submit button request"));
}
}
Primefaces 6.1.4, Mojarra 2.1.8, JBoss AS 7.1.1

tozar
Posts: 2
Joined: 16 Aug 2017, 17:11

29 Aug 2017, 17:58

I found the answer to this problem. Have to add process="@this" attribute to commandButton.
Primefaces 6.1.4, Mojarra 2.1.8, JBoss AS 7.1.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 29 guests