RE: #foreach and page iterators

"Andrew Speakman" <[email protected]> Wed, 22 Jan 2003 16:25:34 -0000
Newsgroups gmane.comp.java.jpublish.devel
Message-ID <[email protected]>
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/");

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

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/");

Thanks for any help

Andrew


-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of
Anthony Eden
Sent: 22 January 2003 05:58
To: [email protected]
Subject: Re: [JPublish-developer] #foreach and page iterators


Responses inline...

Florian Gnägi wrote:
> Hi Andrew
>
> Try putting your code in a page action where you could extract all titles
of pages
> and other properties from other pages and push them in the context from
within your page.
>
> To get all page titles looks like a functionality problem an not like a
layout issue.
> In my point of view it should therefore be placed in a page action that
calculates an
> array with the page names and maybe some other stuff like the date when
the page has
> ben updated last time etc. The velocity macro can then be used to iterate
over the array
> it gets from the page-action and solve the layout issue.

Florian is correct: it is best to do all logic like this in an action as
opposed to in the
Velocity code.  You will have a lot more flexibility in the action, plus you
can reuse your
code that way.

>
> What I miss in the page property system are global properties that could
be defined in
> the pages.xml file but not within a specific page tag. This would allow to
have common
> properties like 'save', 'update', 'edit', 'new' 'home' etc. In our case we
use an
> internationalization class that reads this properties from a properties
file. This is not
> so nice since it should be provided by the framework. Maybe it's already
there and we didn't find it?

No, there is nothing right now to have common properties.  I would rather
not put them in
pages.xml though because that file is only used when using the
XMLPageManager.  Or at least
I would first like to come up with a way to do it using the default page
manager.  I'll think
about it for a bit and see where it would best fit.

>
> Sincerly
> -Florian
>
> ----- Original Message -----
> From: "Andrew Speakman" <[email protected]>
> To: <[email protected]>
> Sent: Tuesday, January 21, 2003 6:11 PM
> Subject: [JPublish-developer] #foreach and page iterators
>
>
> |
> | JPublish looks like a great framework but I am struggling with one
aspect.
> |
> | I would like to iterate through a group of page definitions to extract a
> | list of titles and other properties. Something like this ...
> |
> | #foreach ( $topic in $site.getPageManager().getPages("/topics") )
> | <p>Topic title:
> | $site.getPageManager().getPage("$topic").getProperty("title")</p>
> | #end
> |
> | This throws up a number of errors but I am wondering if it is possible
for
> | the Velocity #foreach directive to do this, given that getPages()
returns an
> | Iterator rather than a reference to a List.
> |
> | Andrew Speakman
> |
> |
> |
> | -------------------------------------------------------
> | 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
> | _______________________________________________
> | Jpublish-developer mailing list
> | [email protected]
> | https://lists.sourceforge.net/lists/listinfo/jpublish-developer
> | N¬HY޵隊X¬²š'²ŠÞu¼’r%j»!Š›¢´Þrž°&§µ§ß¢·HNÚÚŠx§€
eÛM7‰Ëi²Ûz{l­çŠ÷¬r%j»!Š›zØZÛ(žÚÚŠx§‚)̉Ê貇í
> +¡+§.)îÇõ
>
!v§vj+{0‰Ëir‰¿¶¶¢ž)àþÊ.­ÇŸ¢¸jÊI¦æåŠÈ]z÷¥¢—«™¨¥Šx%ŠËI¦æåŠÈ]z÷¥¢—«–+-²Ê.­ÇŸ¢
¸ëa¶Úlÿùb²Û,¢êÜyú+éÞ·ùb²Û?–+-Šwèþ:nnX¬…ׯzZ)er==



-------------------------------------------------------
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
_______________________________________________
Jpublish-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jpublish-developer



-------------------------------------------------------
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