Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5014

UiEngineImpl.createComponents trigger page initiator after page init

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 10.0.0, 9.6.0.1
    • None

      Steps to Reproduce

      Add initiator to zk.xml

       

      	<listener>
      	    <listener-class>foo.bar.ShadowPageInitiator</listener-class>
      	</listener>
      

       

      Run sample locally (attached files)
      Put breakpoint in foo.bar.ShadowPageInitiator.doInit(Page, Map<String, Object>)
      Click button

       

      Current Result

       These component creations trigger Initiator.doInit

      		<apply templateURI="template-inner.zul" content='@load("separate zul file as template")' />
      		<template name="myExtTemplate" src="template-inner.zul" />
      		<apply template="myExtTemplate" content='@load("external template")'>
      		</apply>
      		<button onClick="@command('doTheThing')"/>
      
      	@Command("doTheThing")
      	public void doTheThing() {
      		Executions.createComponents("template-inner.zul", Executions.getCurrent().getDesktop().getFirstPage().getFirstRoot(),null);
      	}
      

       These component creations do not trigger Initiator.doInit

      		<apply templateURI="template-inner.zul" content='@load("separate zul file as template")' />
      		<apply templateName="myTemplate" content='@load("inline content")'>
      			<div>
      				<label value="@load(content)"/>
      			</div>
      		</apply>
      

       

      Expected Result

      Intiator.doInit javadoc states:

      Note: when it is called, Page.getDesktop()Page.getId() and Page.getTitle() all return null, since the page is not initialized yet. 

       

      When initiator is triggered by createComponents, it receives a page that has already been instantiated.

      Debug Information

      CreateComponents create a dummy page to instantiate the components.

       Need to check if this is on spec.

      • Should CreateComponents call initiators on the dummy page?
      • Different apply structures have different results.

      Workaround

      To not trigger pre-init on initiator calls triggered by shadow element / createComponents calls, check for page UUID.

      If page UUID is not null, do not proceed with page init workflow

        1. shadow-initiator.zul
          0.6 kB
        2. ShadowInitiatorViewModel-1.java
          0.3 kB
        3. ShadowPageInitiator-1.java
          0.8 kB
        4. template-inner.zul
          0.1 kB

            Unassigned Unassigned
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: