Re: #foreach and page iterators
Anthony Eden <[email protected]> Wed, 22 Jan 2003 13:19:01 -0500
| Newsgroups | gmane.comp.java.jpublish.devel |
|---|---|
| Message-ID | <[email protected]> |
Andrew Speakman wrote:
>Thanks for the comments.
>
>Point taken about using actions - I have started use bean shell scripts but
>there is still a problem with the iterators.
>
>The FilePageManager getPages() works only if the page root is supplied in
>the call:
>
>import org.jpublish.PageManager;
>PageManager pm = site.getPageManager();
>Iterator itr = pm.getPages(pm.getRoot() + "/topics/");
>
You are correct and I consider this a bug. I have modified the code in
the CVS as follows:
getPages() should now return everything from the page root down
getPages(path) should now return everything from the page root + path down
>but it does not like it if there is a file in the 'topics' sub-directory
>which does not have
>a '.xml' ending (for example README.txt) - throws a
>JPublishRuntimeException: File not found
>
>
I believe I see the problem. The PageManager expects that the path
argument in the getPage(path) method will be a path to content. Thus,
it will remove the trailing suffix and will replace it with XML.
However, perhaps when iterating through pages the paths specified are
the actual page configuration files themselves. What I have done is add
a catch in the iterator implementation for FileNotFoundExceptions which
will log them with a warning and then continue on. This should fix the
problem.
>The XMLPageManager getPages() does not work for me. The returned iterator is
>not null but it cannot be used - hasNext() never returns false and next()
>throws a JPublishRuntimeException.
>
>I am working with a pages.xml which has entries with the following format:
>
><page path="/topics/resources">
> <property name="title">Resources</property>
></page>
><page path="/topics/progress">
> <property name="title">Progress</property>
></page>
>
>and a bean shell script as follows:
>
>import org.jpublish.PageManager;
>PageManager pm = site.getPageManager();
>Iterator itr = pm.getPages("/topics/");
>
I put in the same type of fix as the FileSystemPageManager which will
hopefully fix the problem.
If you want to wait a little bit I will be releasing JPublish 1.5 soon.
Otherwise you can check out of CVS and build but be aware that I am
working on some stuff in the CVS so while it builds there may be bugs.
Sincerely,
Anthony Eden
-------------------------------------------------------
This SF.net email is sponsored by: Scholarships for Techies!
Can't afford IT training? All 2003 ictp students receive scholarships.
Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more.
www.ictp.com/training/sourceforge.asp