pe:timeline - lazyload is not working

Community Driven Extensions Project
Post Reply
AndreasK
Posts: 1
Joined: 14 Apr 2015, 08:31

14 Apr 2015, 09:05

Hello,

I am using the timeline component of PrimeFaces Extensions. For a better performance and less network traffic I need to use the lazyload functionality of this element.

Therefor I have copied the source code of the use case of the showcase (see http://www.primefaces.org/showcase-ext/ ... e/lazy.jsf) and tested it. For this I used the debugger and set a breakpoint in the onLazyLoad-method.

Till now, I was not able to call the onLazyLoad-method - it doesn't work.
But the javascript code in the onstart and oncomplete handler is always being called.

Does someone know how to use the onLazyLoad-Listener?

I am using:
- glassfish server 4.1 with Java8
- the PrimeFaces extensions 3.0.0 (I've also tried it with 3.1.0 from github)
- PrimeFaces 5.2

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

22 Apr 2015, 22:05

Please provide an example. And make sure you set ID on pe:timeline and use process="@this" or similar on p:ajax.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

airpadina
Posts: 4
Joined: 29 Jul 2015, 12:29

29 Jul 2015, 12:40

Try to add process="@form" to lazyLoad event.

pzoli
Posts: 100
Joined: 27 Feb 2012, 20:52
Location: Hungary
Contact:

30 Oct 2015, 17:05

You can use it by change partial state saving to true in web.xml

Code: Select all

	<context-param>
		<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
		<param-value>true</param-value>
	 </context-param>
It works for me. But I need use false if I want use Primefaces ajaxExceptionHandler.
(please read this: http://forum.primefaces.org/viewtopic.php?f=3&t=43470)

So, when I TimelineUpdater.getCurrentInstance, I get null value, and Timeline does no view any change.

Code: Select all

    public void onLazyLoad(TimelineLazyLoadEvent e) {        
        String id = "mainform:timeline";
        TimelineUpdater timelineUpdater = TimelineUpdater.getCurrentInstance(id);
        
        Date startDate = e.getStartDateFirst();
        Date endDate = e.getEndDateFirst();
        clearTimeline();
        List<ScheduleEvent> events = activityService.loadEvents(startDate, endDate, timeZone, currentClient);
        for (ScheduleEvent event : events) {
            EventHistory eHistoryItem = ((EventHistory) event);
            String subjTypeId = "";
            if (eHistoryItem.getSubject() != null && (eHistoryItem.getSubject().getSubjectType() != null) && (eHistoryItem.getSubject().getSubjectType().getId() != null)) {
                subjTypeId = eHistoryItem.getSubject().getSubjectType().getId().toString();
            }
            model.add(new TimelineEvent(eHistoryItem.getTitle() + "(" + subjTypeId + ")", event.getStartDate()),timelineUpdater);
        }

        if (e.hasTwoRanges()) {
            events = activityService.loadEvents(e.getStartDateSecond(), e.getEndDateSecond(), timeZone, currentClient);
            for (ScheduleEvent event : events) {
                model.add(new TimelineEvent(((EventHistory) event).getTitle(), e.getStartDateSecond()), timelineUpdater);
            }
        }
    }
This is my timeline code in xhtml:

Code: Select all

			<h:form id="mainform">
				<pe:timeline id="timeline" value="#{activityManager.model}"
					start="#{activityManager.currentTime}" widgetVar="timelineWdgt"
					var="eventItem" preloadFactor="0.5"
					zoomMax="#{activityManager.zoomMax}" zoomable="true" locale="hu"
					minHeight="350" showNavigation="true">
					<p:ajax event="lazyload" update="@none" process="@form"
						listener="#{activityManager.onLazyLoad}" />
				</pe:timeline>
			</h:form>
I try create TimelineEvent without updater, but the result is same.
Last edited by pzoli on 30 Oct 2015, 22:19, edited 1 time in total.
JBoss Developer Studio 11.3.0.GA
Eclipse Oxygen
Wildfly 11
PrimeFaces 6.2.3, PrimaFaces Extensions 6.2.3
Mojarra 2.2.11-jbossorg-1, MyFaces 2.2.8, Deltaspike 1.7.1
MySQL, Oracle, MS-SQL, PostgreSQL, NoSQL

pzoli
Posts: 100
Joined: 27 Feb 2012, 20:52
Location: Hungary
Contact:

30 Oct 2015, 22:01

Code: Select all

if (timelineUpdater == null) {                        
  FacesContext fc = FacesContext.getCurrentInstance();
  UIComponent uiTimeline = fc.getViewRoot().findComponent(id);
  if (uiTimeline instanceof Timeline) {                
      //RequestContext.getCurrentInstance().update(id);                
  }
}
Ok, the question is: how can I use model.add without TimelineUpdater and how can I update manualy the timeline?
JBoss Developer Studio 11.3.0.GA
Eclipse Oxygen
Wildfly 11
PrimeFaces 6.2.3, PrimaFaces Extensions 6.2.3
Mojarra 2.2.11-jbossorg-1, MyFaces 2.2.8, Deltaspike 1.7.1
MySQL, Oracle, MS-SQL, PostgreSQL, NoSQL

pzoli
Posts: 100
Joined: 27 Feb 2012, 20:52
Location: Hungary
Contact:

31 Oct 2015, 12:27

I found FULL_STATE_SAVING_VIEW_IDS:

Code: Select all

	<context-param>
	    <param-name>javax.faces.FULL_STATE_SAVING_VIEW_IDS</param-name>
	    <param-value>
	    /user/alerts.xhtml,/user/clients.xhtml,/user/event_templates.xhtml,/user/groups.xhtml,/user/lessons.xhtml,/user/meetings.xhtml,/user/messagelist.xhtml,/user/reports.xhtml,/user/reportsyear.xhtml,/user/setup.xhtml,/user/visitaday.xhtml,/admin/admin.xhtml,/admin/clientcategory.xhtml,/admin/doctors.xhtml,/admin/import.xhtml,/admin/subjects.xhtml,/admin/users.xhtml
	    </param-value>
	</context-param>
I found on this website:
https://myfaces.apache.org/core20/myfac ... onfig.html

But becaouse of ViewExpiredException needs on every page, I can't use it on page that display Timeline.
I'm not foud context-param or UIComponent attribute that's applicable for partial state saving.
JBoss Developer Studio 11.3.0.GA
Eclipse Oxygen
Wildfly 11
PrimeFaces 6.2.3, PrimaFaces Extensions 6.2.3
Mojarra 2.2.11-jbossorg-1, MyFaces 2.2.8, Deltaspike 1.7.1
MySQL, Oracle, MS-SQL, PostgreSQL, NoSQL

pzoli
Posts: 100
Joined: 27 Feb 2012, 20:52
Location: Hungary
Contact:

31 Oct 2015, 14:03

In public static TimelineUpdater.getCurrentInstance(String id):

Code: Select all

Map<String, TimelineUpdater> map = (Map<String, TimelineUpdater>) fc.getAttributes().get(TimelineUpdater.class.getName());
map is null when partial stat saving is false.
JBoss Developer Studio 11.3.0.GA
Eclipse Oxygen
Wildfly 11
PrimeFaces 6.2.3, PrimaFaces Extensions 6.2.3
Mojarra 2.2.11-jbossorg-1, MyFaces 2.2.8, Deltaspike 1.7.1
MySQL, Oracle, MS-SQL, PostgreSQL, NoSQL

pzoli
Posts: 100
Joined: 27 Feb 2012, 20:52
Location: Hungary
Contact:

01 Nov 2015, 19:07

Ok, I know this is independent from state saving, but I try partialSubmit, too:

Code: Select all

  <p:ajax event="lazyload" update="@none" process="@form" partialSubmit="true"
    listener="#{activityManager.onLazyLoad}" />
but nothing.
JBoss Developer Studio 11.3.0.GA
Eclipse Oxygen
Wildfly 11
PrimeFaces 6.2.3, PrimaFaces Extensions 6.2.3
Mojarra 2.2.11-jbossorg-1, MyFaces 2.2.8, Deltaspike 1.7.1
MySQL, Oracle, MS-SQL, PostgreSQL, NoSQL

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests