[Building Sakai] accurately getting page url
David Wafula
davidwaf at gmail.com
Fri Nov 11 02:51:53 PST 2011
Team,
Am using the following code:
private String getPageUrl(String title) {
try {
String currentSiteId =
toolManager.getCurrentPlacement().getContext();
Site site = siteService.getSite(currentSiteId);
for (SitePage sitePage : site.getPages()) {
if (sitePage.getTitle().equalsIgnoreCase(title)) {
return sitePage.getUrl();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
And i call it like
String url=getPageUrl("Announcements");
However, a user could change the title of the page, and this method will
fail. How best can i always guarantee a valid page url, even when this
happens ?
Regards,
--
David Wafula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20111111/2ad25c5a/attachment.html
More information about the sakai-dev
mailing list