[Building Sakai] accurately getting page url

Bryan Holladay holladay at longsight.com
Fri Nov 11 04:57:30 PST 2011


You'd want to do something like this:


site.getToolForCommonId("sakai.announcements")

and see if it returns something or not


-Bryan

On Fri, Nov 11, 2011 at 5:51 AM, David Wafula <davidwaf at gmail.com> wrote:
> 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
>
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org
> with a subject of "unsubscribe"
>


More information about the sakai-dev mailing list