last day (14 days later) » 

11:00 AM
1
Q: p:schedule is not showing events

SihoHere is my <p:schedule>: <h:form> <p:schedule value="#{calendrierReleasesController.model}" /> </h:form> And here is my bean calendrierReleasesController: @Component @Scope("view") @Qualifier("calendrierReleasesController") public class CalendrierReleasesController implements Serializ...

 
I copied the exact code and it's working for me !
 
Really? You can see Event1 for today?
 
Check your console for any JS errors...
 
I see... I'll recheck the console more carefully
@HatemAlimam Please tell me how can I identify them (the JS errors)?
 
When you develop a web application it's very important that you keep an eye on the console, even the ajax requests how they're executed, I use Google chrome console developer.chrome.com/devtools/docs/console
 
11:00 AM
@HatemAlimam I found an error in the console Uncaught ReferenceError: statusDialog is not defined ... statusDialog is my ajax status dialog. It's defined in the template and I use the same template for all my pages. it never displayed such error.. Do you know how to solve it plz?
 
Post your status dialog...
 
@HatemAlimam Done.. I edited my question
@HatemAlimam Note that I also have an "Uncaught ReferenceError: PrimeFacesExt is not defined" error but it never caused a problem. I googled and seen that it doesn't have bad effects
 
Now it makes sense, see the working example and go to github and see the code, it's pretty much simple... where do you use PF extensions ?
 
I have done a copy/past from your code and it still don't work. I use PF extension in another page (I use a timeline) why?
 
Alright just to test my theory placing this in your current page would fix it... <pe:blockUI widgetVar="blockUIWidget1"> </pe:blockUI>
 
11:00 AM
placing it in the page deleted the "Uncaught ReferenceError: PrimeFacesExt is not defined" But I still have the "Uncaught ReferenceError: statusDialog is not defined " error and no events in the schedule
 
which PF version ? and do you have any reference to statusDialog widgetVar in your current page ?
 
I use PF 4.0; The statusDialog is in the template and I use that template in my schedule page yes.
 
just delete the statusDialog from the template.. and run the page
 
hello
 
11:02 AM
but I need the status dialog
(or just delete it to test?)
 
I know you need it... just to make sure that the problem is not related to JS
 
ok
i'll do it right now
 
go ahead and let me know
 
done
 
still no events ?
 
11:03 AM
well the error don't disappear
but I had 2 x the same error and know there is only one
 
hmmm
 
 
have you debugged ?
 
that's before
and know I have
 
okay get back where you were
 
11:05 AM
Yes I debugged and there is no problem
 
I mean get the dialog back
 
the model gets filled corretly this data
correctly**
ok
 
and show me the console again.. in which line you have the undefined ref
 
I have put a screenshot
have u seen it?
 
click on the page name line 75 and do a screetshot
 
11:07 AM
ok
but now I don't have only one error
I have 2
(since I get back everything as it was)
 
which ?
 
Here is the 2 errors and what is displayed when I clock on the error line
click**
 
now you need to figure out where do you call that widgetVar
and cancel the calling
for test of course
 
I call that widgetVar nowhere in my schedule page
I only call it in my template
and my schedule page uses that template
<p:ajaxStatus onstart="statusDialog.show();"
onsuccess="statusDialog.hide();" />
<p:dialog modal="true" widgetVar="statusDialog" showHeader="false"
draggable="false" closable="false" resizable="false" visible="false"
position="center" maximizable="false" minimizable="false">
<p:graphicImage value="#{resource['images/ajax_loader_blue.gif']}" />
</p:dialog>
 
alright remove the ajaxStatus
 
11:13 AM
I already done that when u asked me to
and the result was that one of the 2 errors desappeared
disappeared**
 
aha .. and still no events correct ?
 
yes
 
we're back to zero then
 
unfortunately yes
 
quite strange.. if you copied my code it has to function .. now the only thing would be that for some reason the managedBean is not doing it's job
and you said that you debugged and you reached the managedBean ?
 
11:15 AM
yes
 
alright wait a sec
 
I debugged and the model is OK, it contained all the events
ok
(Thanks a lot for your time and patience by the way)
 
our projects in production time .. so I'm relaxed somehow :) don't worry
 
:)
great
I debugged again to show you that the model gets filled correctly with the event
oh good news: just to try I tested the schedule with no template
<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:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head></h:head>
<h:body>

<p:panel>
<p:schedule value="#{calendrierReleasesController.model}" />
</p:panel>

</h:body>
</html>
and it works very well
 
aha ... so you have something in the template which blocks the drawing process
 
11:23 AM
So I'm sure now that the problem comes from the UI (actually the template and the ajax status) and not from the bean
yess exactly
 
I was looking into the current bugs
nothing found
 
I see
hmm
 
maybe CSS conflicts ? by long shot ?
 
is there a way to disable the ajax status only for one page?
sorry I don't understood
what's the problem with the css?
 
it depends on the components
I mean sometimes you have some CSS rules that would cover or display:none the other elements
 
11:25 AM
ah i see
 
but this is a long shot anyway
I'm sure it's a JS problem ..
 
yes
I think too
(but I can show you my css file)
a workaround would be to create another template without the ajax status and to reference it in my schedule page
but I prefer to solve the problem in a "clean" way
 
try this and let me know ... the schedule component is based on this arshaw.com/fullcalendar
so maybe PF has some conflict with the original component
OR change the dialog widgetVar name
keep the same template but change the widgetVar name .. of course change the calls
onstart and oncomplete
 
ok
 
it's very odd situations but sometimes you might have a conflict the names ... that's why in PF 5 and 4 the have PF() widgetVar shortcut
 
11:33 AM
maybe stupid question... but I have implemented a locale (french locale) and since the template references it maybe it causes a problem (the schedule works with that locale)
i'll try with the template without ajax status
and see what happens
 
also you might try this <p:ajaxStatus onstart="PF('statusDialog').show();"
onsuccess="PF('statusDialog').hide();" />
 
if the problem still there, I'll srously suspect the locale
ok
 
maybe
 
i'll do it right now
tried to change for PF('') and it displays another error (in addition to the first)
Uncaught TypeError: Cannot read property 'show' of undefined
 
alright wait a sec I'll test your dialog with the ajaxStatus
 
11:37 AM
ok
by the way
 
it's working !
 
tested the "add another template with no ajax status solution" it works, it adds the event but it still display 1 instance of the error "Uncaught ReferenceError: statusDialog is not defined"
 
I mean the same ajaxStatus with the dialog it works fine!
 
sorry I don't understand
 
search your new template for a "statusDialog"
you should see a call
 
11:40 AM
this?
<p:ajaxStatus onstart="PF('statusDialog').show();"
onsuccess="PF('statusDialog').hide();" />
 
is your template file big ? can you share it with me ?
 
no it's not big
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:pe="http://primefaces.org/ui/extensions">

<f:view contentType="text/html" id="fview" locale="fr">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Release Management</title>
well... let's say... not That big :)
 
WAIT a second !!
you're doing something which is very confusing to me !
 
ouch !
what?
 
you do realize that your code is inside the head tag ?
 
11:44 AM
yes
it have to be
 
why !!
 
I found that template on the web
 
you can't have such a code inside the head tag
 
euh... but it's working very well
 
wait a sec .. I'll show you how to fix it
 
11:44 AM
everything is oj
ok
 
I doubt that
 
I work on this project since february.. and it never caused me a problem
 
just try this please
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:pe="http://primefaces.org/ui/extensions">

<f:view contentType="text/html" id="fview" locale="fr">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Release Management</title>
 
hahah this is so funny !
sorry but I had to laugh about the article !
 
11:47 AM
is it that... bad?
 
see the comments
 
i tried the code you gave to me
here is the result
 
I'm sorry to say this .. but if you place such a code in head that means you know nothing about the web .. it's a web not JSF matter
 
why?
 
okay great .. lets fix that
now you see the primefaces_locales.js inside the head ?
 
11:50 AM
yes
 
delete the outputScript
 
and now the locale is NOT applied
the calendars are in englich
english
 
now after the opening of the body place this <f:facet name="last">
<h:outputScript name="js/primefaces_locales.js" />
</f:facet>
I know but we need to fix every JS problem
 
ok
done
 
now run
any errors ?
 
11:52 AM
yes
the same errors
and the locale is not recognized
 
delete this from the body onload="statusDialog.hide();"
then set a target to the outputScript as head
<h:outputScript name="js/primefaces_locales.js" target="head" />
 
delete what?
 
<h:body onload="statusDialog.hide();">
on load
and what exactly this is doing listener="#{notifController.checkNewNotifs()}" ? is it executing and JS from requestContext ?
 
ok now some errors are gone
the locale is back
but still no events
and there is these errors
the listener is there to execute a method on every page load to check if the user has a notification waiting
(then a poll re-executes that method to check the new notifications when the user stays in the same page)
 
when exactly the poll is being called .. I suppose right aways correct ?
 
12:00 PM
the poll calls that method checkNewNotifs() every 30 min
<p:poll interval="1800"
listener="#{notifController.checkNewNotifs()}"
update="formNotif" />
but my problem was that on page load the method is not executed
 
add global="false" to it just to test my theory
 
and it the uset has notifs they will not be shown
so I made that call onLoad to solve that
add global to what?
 
to poll
 
ok
global is by default false no?
 
no it's true
 
12:02 PM
ok
tried and it change nothing
 
you still have errors ?
 
but what an I supposed to test exactly after changing global?
the same ones
 
test the page
 
yes
ok.. that's what I done
 
because the widgetVar of the dialog might take some time to be initialised so the first time the poll fires the dialog would not be ready... that's why I suspected that global="false" would fix it
so nothing huh ?
 
12:06 PM
nothing yes
 
I'm sorry it's getting to complicated and I can't figure out what's exactly is being called but the good thing that you found out that the ajaxStatus is causing this .. my suggestion would be not to use the dialog with the ajaxStatus it's disturbing ...
 
sorry but
the poll fires totally another dialog that the ajax status dialog
 
Always try to get rid of the JS errors
 
I need that ajaxStatus dialog to give the illusion that the user request is processing (ang it's sometinmes too long to respond so I need that dialog)
sorry my internet connexion crashed
 
it's okay man
 
12:11 PM
ok (i'm a girl XD)
 
oh sorry haha
 
no problem you couldnt know
but what is really strange is that when I supress every reference to the ajax status
it still display error that that ajax status is undenied
undefined **
 
for me your template is so confusing ... I hate to use PF extensions it's so complicated .. my layout is always pure HTML
 
oh wait wait
now when I supress all reference to the dialog it does work
and with no errors
:D
HALLELUYAH XD XD XD
 
yeah but you didn't get what you want haha
 
12:15 PM
so I think that I m gonna create another template
haha yes I can get it if I create another template just for this page
since I don't need ajax status for this page
it's not the best idea ever but it can work
 
no .. what I'm trying to understand is what ajax requests are being called .. could you open the network tab in chrome
and see what ajax requests are being fired ?
 
ok
 
and one question ... why the body of the template has onload="statusDialog.hide()" !! this has to break everything !
go down down ..
I mean the dialog is not even showen why to hide it !
 
sorry... stupid answer: I copied the template as I found it cause at that time I was a newbie in templates
hmm
maybe if a request opens another page
it will display the dialog
and hide it when the called page loads
 
you could find so much references on templeting .. I've done a couple of articles blog.hatemalimam.com
no I'm sure that the one who wrote this article doesn't have any idea about facelets or so!
 
12:20 PM
yes I have seen you website recently.. I wish I had seen it long long before
 
anyhow back to your problem .. I wouldn't create a new template file .. I would see that show function where it's being called
 
(I finish my internship today :( )
 
ah I see
then just create another template and go home haha
 
hmm u mean the hide function right?
(haha, no I want to make things properly, even if I will do it in my free time)
 
or show .. because in the error log there was a show indication that it's undefined
 
12:22 PM
hmm
cause I have already deleted the call to hide in body
 
maybe one of your ui:include s ?
 
hmm
my includes don't reference any ajax status
 
oh the show is in the schedule !
boom
 
heinnn
realyy?
really**
where?
 
there's an ajax request from the schedule component, can you see that >
?
 
12:28 PM
euh
my schedule is very simple
it executes no ajax request on events
it's just to display them
here is the whole code of schedule
<p:schedule value="#{calendrierReleasesController.model}" />
 
now in my opinion that the events are being fetched ajaxly ... causing the ajax status to fire where the dialog is not ready
 
it uses it even if I don't use any of <p:ajax> events?
 
now in your template ... just for testing ... move the ajaxStatus and the dialog into the end of the file
 
before the body close?
or after
 
of course PrimeFaces uses a lot of underlaying ajax requests.. depends on the plugins
before the body close
 
12:32 PM
?
ok
the dialog is already there
 
I know
 
i'll move the ajaxStatus
 
move the ajaxStatus
after the dialog it's better
 
OH GOD IT'S A MIRACLE
XD
IT WORKS :))))))
 
hahaha that was a hell of analysis
 
12:34 PM
but why does it work?
haha yes
 
alright I'll explain
 
thank youuu ... yes plz
 
when you define a component the component renderer would generate a script (JS)
 
ok
 
and place it into the page where it's positioned
so the ajaxStatus is positioned on the top
 
12:35 PM
yes
 
and the dialog is in the last
 
exactly
 
so first the render would go like this
first ajaxStatus > schedule > dialog
now schedule tries to do ajax request > the ajaxStatus fired > but the dialog is not ready
and boom
 
ohhhhhhhhhh i seeeeeeee
 
you can't see the scripts when you inspect the elements because they're removed once they're executed
 
12:37 PM
so if we put the dialog under the dialog it will be always ready when the request is fired right?
put the ajax status under dialog**
 
yes that's way the schedule would do the ajax request knowing that the ajaxStatus is not even ready to call the dialog where the page is not being showen yet :D I know it's complicated
this is how they remove the script github.com/primefaces/primefaces/blob/…
Basic jQuery
 
oh it's very clear now... thank you so much.. I'll always keep in mind that there is JS code behind components and so the order in which I place the components is important
so the problem was the fact that schedule executes ajax status requests right?
 
exactly .. if you didn't expand the error log for me I woudn't know it
 
and the reason why I didn't encountered this problem earlier is that no other component (I used) does the same
really? u understood something from that strange code
?
 
you would believe me sooner or later .. and the template would cause so much headache
I'm the head front-end developer here .. so I train people on the front-end stuff :)
 
12:43 PM
but the problem was not the template itself no?
I see
 
the template is not the problem yes .. the ordering is
but the template is functioning only because the JSF would re-posistion the components into the body
but it's completely wrong .. but I had worse believe me :)
 
i see
so what's the solution if i need a template
use bare html?
 
I always use frameworks which they make my work less miserable
like for instance bootstrap
or foundation
front-end stuff .. and yes pure HTML
 
I see
very well
 
with too many stuff of course JS + CSS and so on
 
12:47 PM
thank you soooo much for your help
 
you're most welcome ... you can follow me on twitter if you want :)
 
and so sorry for the waste of time
I will :)
thanks again
 
no it's okay we have time to develop on our own .. :)
 
:D
 
so you're french correct ?
I see from the local haha
 
12:51 PM
I'm tunisian
 
and I'm Syrian but I live in Italy
Now if you can, delete your question please
 
Yes I have seen that you're from italy in your stackoverflow profile and I guessed that you're not italian from your name ^^
can't you post a response so I could validate it?
 
yes exactly we're arabs :)
 
haha yes
 
no it's totally unrelated if I answer
 
12:55 PM
(i mean in order to help others with that difficulties as I am)
but people can enter this chat and see the process to find the solution
 
I couldn't know the answer without the deep explanation of your code , and you can't ask such a question with so much code .. so we would waste their time
 
it could be helpful don't u think?
 
no I don't think so
 
ok
i'll delete it
done
 
good
 

last day (14 days later) »