[Xerte-dev] How to wait while Xerte populates rootIcon.pages

Kemp Johnathan johnathan.kemp at ntlworld.com
Mon Apr 9 23:06:32 BST 2012


Hello everyone - a little puzzle for Easter,

I don't know if anyone can throw any light on this little problem I have
hit.

Xerte desktop creates an array rootIcon.pages

By the time a learning object setup script runs rootIcon.pages has not been
defined as it has undefined length.
By the time a script off an Entry Frame runs it has length 0, so it has
been created but not populated.
By the time a script in a page runs its length is the number of pages in
the project.

For each entry in the array Xerte will place the details of a page
including the extXML data so you can get at the values set in an xwd form
for any page in your project. However at the time the first page has loaded
only the details of the xml for the first page have loaded. By the time the
next page of a project is loaded the array is fully populated.

This effectively means that my Connector pages which use this array for
desktop projects (but not for XOt projects) cannot work as the first page
of a project, because they cannot look up the pages they are set up to
connect to.

However it appears that the loading of the style sheet in my entryFrame's
setup script effectively causes the first page to load twice. This is
invisible to the end user but any debug statements will be repeated,
showing the page loaded twice.

This has the benefit that in Xerte preview mode, or if the published
project is viewed in Internet Explorer or Firefox a connector page can
operate as the first page of a project, because by the time the page has
reloaded the rootIcon.pages array is fully populated.

The twist is I have been trying to use this to make it possible to open a
Xerte project at a specific page by adding

?pageID=myTargetPage

to the url of an external link to the project. I achieve this by adding
some Connector page like code to the title page. A project then uses this
form of Title page as the first page of the project.  When the project
opens in the browser it opens at the first page and the pageID value if one
is passed in the Url gets captured. The Title page then uses the same
method as a standard connector page to go to the page specified by the
pageID.

I have this working in Firefox and Internet Explorer. However in Opera the
url parameter captures perfectly but for some reason the rootIcon.pages
array is still not populated with the extXML data for any of the other
pages, so the redirect fails. If I use the Xerte navigation to move to page
2 and then go back to the title page it will redirect to the page specified
in the url, so the principle works in Opera.

So is there a way I can force the rootIcon.pages array to fully populate
before I move on to compare the url pageID. I tried a while loop but just
looping until the array has time to populate does not work. I guess because
the array stops populating whilst the loop is running. I am sure this would
be a feature many people would find useful, so any ideas as to how I get
the page to wait until the array is populated would be much appreciated.

Kind regards

Johnathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte-dev/attachments/20120409/962f71de/attachment.html>


More information about the Xerte-dev mailing list