[Building Sakai] accurately getting page url

Steve Swinsburg steve.swinsburg at gmail.com
Fri Nov 11 14:26:55 PST 2011


Bear in mind you may have two of the same tool in the one site, like web content. IIRC there was a way of dealing with that case too. 

Cheers
Steve

Sent from my iPhone

On 12/11/2011, at 0:10, David Wafula <davidwaf at gmail.com> wrote:

> 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
> _______________________________________________
> 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"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20111112/f5fea591/attachment.html 


More information about the sakai-dev mailing list