beforeShowDay Calendar with Ajax is bugged?

UI Components for JSF
Post Reply
dodolins
Posts: 18
Joined: 24 May 2017, 06:35

14 Mar 2018, 21:49

Hi, in my application, I use facelets, my main page is index.xhtml, it has 3 <ui:include />:

First: <ui:include src="folder/header.xhtml" /> for headers page.
Second: <ui:include src="#{changePageBean.page}" /> for change contents page.
Third: <ui:include src="folder/footer.xhtml" /> for footers page.

I have a doctors dataTable (in my "select-doctor.xhtml"), when I click on a dataTable row, a ajax requisiton is triggered, then the value of changePageBean changes and a calendar (in my "select-date.xhtml") appears as new content.

My calendar uses beforeShowDay for disable some days, without ajax/facelets it works, but with ajax/facelets not, to make it work I need refresh my browser.
Before I refresh the page, a message appears in js console saying:
"[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience.
For more help, check https://xhr.spec.whatwg.org/"
After refreshing the page, my calendar works perfectly and the message goes away.

The problema is when I use ajax with beforeShowDay, without facelets its works perfectly because I dont need use ajax.

select-doctor.xhtml

Code: Select all

<p:dataTable value="#{atendimentoOnlineBean.listarMedicos()}" var="m" scrollable="true" reflow="true" scrollHeight="300" selectionMode="single" selection="#{atendimentoOnlineBean.medico}" rowKey="#{m.id}" style="text-align: left !important;" styleClass="medico-datatable">
	<f:facet name="header">
		<i class="fa fa-user-md" />
		<h:outputText value="Médicos" />
	</f:facet>
	<p:ajax event="rowSelect" listener="#{changePageBean.trocarPaginaAndIndex('../WEB-INF/agendamento-online/select-date.xhtml', 2)}"  process="@this" update="panel-ajax steps" ></p:ajax>
				
	p:column style="text-align: center;" headerText="Nome">
		<h:outputText id="nome" value="#{m.nome}" />
	</p:column>
				
</p:dataTable>
beforeShowDay call disponibilizarDias, disponibilizasDias is in index.xhtml
select-date.xhtml

Code: Select all

<p:calendar id="calendar-agendamento"  value="#{atendimentoOnlineBean.diaAgendamento}"  beforeShowDay="disponibilizarDias" mode="inline" locale="pt" navigator="true" yearRange="c:c+1" style="margin: 0 auto;" >
	<f:param name="pagina" value="seleciona-horario.xhtml"></f:param>
	<f:param name="index" value="3"></f:param>
	<p:ajax event="dateSelect" listener="#{changePageBean.trocarPaginaAttribute()}" process="@this" update="panel-ajax steps"></p:ajax>
</p:calendar>
index.xhtml

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:p="http://primefaces.org/ui"
		xmlns:c="http://java.sun.com/jstl/core"
		xmlns:fn="http://java.sun.com/jsp/jstl/functions">

		
	<h:head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
		<title>Atendimento</title>
		<h:outputStylesheet library="style" name="layout.css"></h:outputStylesheet>
		<h:outputStylesheet library="style" name="components.css"></h:outputStylesheet>
		<h:outputScript library="js" name="localeCalendar.js"></h:outputScript>
		<h:outputScript library="js" name="toggle.js"></h:outputScript>
		<h:outputScript>
			function disponibilizarDias(date) {
			
 				disabledDays = [
	 				<ui:repeat var="days"  value="#{atendimentoOnlineBean.diasDisponiveis}" varStatus="loop">
	 					"#{days}"#{loop.last ? "" : ","}
	 				</ui:repeat>
 				];
 				
 				
			    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
			    for (i = 0; i < disabledDays.length; i++) {
			        if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1) {
			            return [true, ''];
			        }
			    }
			    return [false, ''];
				
			}
			
			
		</h:outputScript>
		
	</h:head>
	
	<h:body>

		<ui:include src="header.xhtml"></ui:include>
		
		<div id="content" class="content js-content">
			<p:outputPanel id="panel-ajax">
				<ui:include src="#{changePageBean.page}" />
			</p:outputPanel>
		</div>
		<ui:include src="footer.xhtml"></ui:include>
		
	</h:body>
</html>
Any suggestion?

Regards,
Mike.

JSF 2.2, PrimeFaces 6.2, Glassfish 4.0

dodolins
Posts: 18
Joined: 24 May 2017, 06:35

15 Mar 2018, 13:15

up!

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

15 Mar 2018, 13:42

Read the rules please;) viewtopic.php?f=3&t=1194
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

dodolins
Posts: 18
Joined: 24 May 2017, 06:35

15 Mar 2018, 13:56

tandraschko wrote:
15 Mar 2018, 13:42
Read the rules please;) viewtopic.php?f=3&t=1194
Sorry for "up!" :(

I already tried everything and nothing worked

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

15 Mar 2018, 14:08

Thats a community forum tracker, there is no guarantee for getting support as everyone answers here in his freetime.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests