[Building Sakai] Need help setting a tool title in 2.6

Seth Theriault slt at columbia.edu
Thu Dec 30 08:10:41 PST 2010


Hello,

I am doing some local work on an automated site feed in 2.6. One 
of the requirements is to set the title of the "Site Information 
Display" tool (sakai.iframe.site) that sits on the site's Home 
page.

I tried this code (courseID is the siteId), but I can't for the 
life of me get it to work:

 String iframeToolId = "sakai.iframe.site";
 
 ToolConfiguration toolConfig = SiteService.getSite(courseID).getToolForCommonId(iframeToolId);
 if (toolConfig == null) {
    LOG.error("Failed to find tool for siteId: " + courseID + " and toolId: " + iframeToolId );
  } else {
    LOG.debug("Setting title..... " );
    toolConfig.setTitle("Seth Testing");
    toolConfig.save();
    SiteService.save(site);
  }

At the time I set the title, I will have just created a site, so 
I know its siteId and that the sakai.iframe.site toolId is unique 
to the site.

Since setting it from the GUI works just fine, I took a look at 
that code in:

web/web-tool/tool/src/java/org/sakaiproject/web/tool/IFrameAction.java 

This code uses a Placement object to make the change:

  Placement placement = ToolManager.getCurrentPlacement();
[...]
  // title
  String title = data.getParameters().getString(TITLE);
  // state.setAttribute(TITLE, title);
  if (StringUtil.trimToNull(title) == null)
  {
    addAlert(state, rb.getString("gen.tootit"));
    return;
  }
  placement.setTitle(title);

[...]

  // save
  // TODO: we might have just saved the entire site, so this would not be needed -ggolden
  placement.save();

I know I am missing something, so help anyone?

Seth



More information about the sakai-dev mailing list