timeline: does not fire an ajax request when selected

Community Driven Extensions Project
Post Reply
headoff
Posts: 5
Joined: 25 Feb 2014, 12:24

09 Apr 2014, 15:39

Hi,
I've got a Problem:
I am using the basic timeline. Furthermore I fire an ajax request when selecting an event in the timeline. Everything works fine. But now I surrouned the timeline with a datalist. This is still working. For each object I create there is a new timeline.
But what does not work is that when selecting an event there is no ajax request fired.

Code: Select all


<p:dataList var="model" value="#{controller.models}">
		<pe:timeline 
			value="#{model}"
			editable="false" eventMargin="5" eventMarginAxis="3"
			axisOnTop="false" 
			timeZone="Europe/Berlin"
			selectable="true">
			<p:ajax event="select" 
				listener="#{controller.onSelect}" />

		</pe:timeline>
		<p:spacer></p:spacer>
		</p:dataList>


Code: Select all

public void onSelect(TimelineSelectEvent e) {
		System.out.println("onselect");

}
After clicking on an event the Console still is emtpy.
Is my aim not possible? Or is there something obvious I do not see?

brooksie
Posts: 18
Joined: 21 Feb 2012, 23:09

13 Apr 2014, 17:40

You're taking input - it needs to be inside a <h:form>.
PrimeFaces 4.0 | PFE 1.2.1. | GlassFish 4.0 | Mojarra 2.2.6
NetBeans 8.0 | JDK 8

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

14 Apr 2014, 00:34

Also try to reference process="..." in p:ajax to the p:dataList.
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

headoff
Posts: 5
Joined: 25 Feb 2014, 12:24

14 Apr 2014, 09:35

Now i've tried to use h:form. Still nothing is happening neither when surrounding the p:datalist with h:form nor when surrounding each timeline.
Furthermore I've tried to to use process="" to reference both the datalist and the corresponding timeline. Same result. No result.

Nevertheless thank you for your efforts.

headoff
Posts: 5
Joined: 25 Feb 2014, 12:24

14 Apr 2014, 12:37

It seems like there was a bug.

When using Grouping Timeline, Selection causes no trouble.
When using Basic Timeline, absolutely nothing happens.

Is this possible?

brooksie
Posts: 18
Joined: 21 Feb 2012, 23:09

16 Apr 2014, 00:14

This works for me:

Code: Select all

        <h:form id="mainForm" >

            <p:dataList var="model" value="#{controllerX.modelList}">
                <pe:timeline
                    value="#{model}"
                    editable="false" eventMargin="5" eventMarginAxis="3"
                    axisOnTop="false"
                    timeZone="Europe/Berlin"
                    selectable="true">
                    <p:ajax event="select"
                            listener="#{controllerX.onSelect}" />

                </pe:timeline>
                <p:spacer></p:spacer>
            </p:dataList>
        </h:form>

Code: Select all

@Named
@ViewScoped
public class ControllerX implements Serializable {

    /**
     * Creates a new instance of ControllerX
     */
    public ControllerX() {
    }

    private List<TimelineModel> modelList;

    @PostConstruct
    protected void initialize() {
        modelList = new ArrayList<>();
        Random rand = new Random();
        Calendar today = new GregorianCalendar();
        long timeMS;

        for (int i = 0; i < 3; i++) {

            TimelineModel model = new TimelineModel();
            for (int j = 0; j < 4; j++) {
                TimelineEvent event = new TimelineEvent();
                timeMS = today.getTimeInMillis() + j * 1000L * 60 * 60; // add j hours
                event.setStartDate(new Date(timeMS));
                timeMS = timeMS + (1+rand.nextInt(12)) * 1000L * 60 * 60; // add 1-12 hours
                event.setEndDate(new Date(timeMS));
                event.setData("Event " + i + "." + j);
                System.out.println( 
                        event.getData().toString() + " " 
                        + event.getStartDate() + " - " + event.getEndDate() );
                model.add(event);
            }

            modelList.add(model);
        }
    }

    public List<TimelineModel> getModelList() {
        return modelList;
    }

    public void onSelect(TimelineSelectEvent e) {
        System.out.println("onselect " + e.getTimelineEvent().getData().toString());

    }
}
Result:

Code: Select all

Info:   Event 0.0 Tue Apr 15 23:00:56 BST 2014 - Wed Apr 16 05:00:56 BST 2014
Info:   Event 0.1 Wed Apr 16 00:00:56 BST 2014 - Wed Apr 16 08:00:56 BST 2014
Info:   Event 0.2 Wed Apr 16 01:00:56 BST 2014 - Wed Apr 16 06:00:56 BST 2014
Info:   Event 0.3 Wed Apr 16 02:00:56 BST 2014 - Wed Apr 16 04:00:56 BST 2014
Info:   Event 1.0 Tue Apr 15 23:00:56 BST 2014 - Wed Apr 16 04:00:56 BST 2014
Info:   Event 1.1 Wed Apr 16 00:00:56 BST 2014 - Wed Apr 16 10:00:56 BST 2014
Info:   Event 1.2 Wed Apr 16 01:00:56 BST 2014 - Wed Apr 16 07:00:56 BST 2014
Info:   Event 1.3 Wed Apr 16 02:00:56 BST 2014 - Wed Apr 16 12:00:56 BST 2014
Info:   Event 2.0 Tue Apr 15 23:00:56 BST 2014 - Wed Apr 16 06:00:56 BST 2014
Info:   Event 2.1 Wed Apr 16 00:00:56 BST 2014 - Wed Apr 16 08:00:56 BST 2014
Info:   Event 2.2 Wed Apr 16 01:00:56 BST 2014 - Wed Apr 16 13:00:56 BST 2014
Info:   Event 2.3 Wed Apr 16 02:00:56 BST 2014 - Wed Apr 16 13:00:56 BST 2014
Info:   onselect Event 2.2
Info:   onselect Event 1.3
Info:   onselect Event 1.2
Info:   onselect Event 0.0
PrimeFaces 4.0 | PFE 1.2.1. | GlassFish 4.0 | Mojarra 2.2.6
NetBeans 8.0 | JDK 8

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests