[Building Sakai] accurately getting page url

David Wafula davidwaf at gmail.com
Fri Nov 11 05:10:43 PST 2011


Yes, thank you. That works.

On Fri, Nov 11, 2011 at 2:57 PM, Bryan Holladay <holladay at longsight.com>wrote:

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



-- 
David Wafula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20111111/27829311/attachment.html 


More information about the sakai-dev mailing list