[Building Sakai] Writing a Helper

mizematr at notes.udayton.edu mizematr at notes.udayton.edu
Thu Apr 29 09:01:49 PDT 2010


Thanks for getting back to me, the code you included will serve as a great 
starting point for me.  Basically, our faculty are looking to fill out a 
rubric form when grading an assignment for accreditation purposes.  My 
plan is to have the metaobj helper create a new form item, store it in the 
same resource location that attachments are stored for the assignment 
(/content/attachment/<site id>/Assignments/<not yet sure what this id 
is>/<filename>, then return to the assignment grade screen. I'd like to 
either use the metaobj helper currently written for the Resources tool, 
or, if I must, write a new helper which tweaks the metaobj resource helper 
for use in the assignments tool.

The example that I'd found used the ToolServlet.startHelper function so 
I'd started playing around with that, but will look at this too.  Thanks 
much.

Matthew Buckett <matthew.buckett at oucs.ox.ac.uk> wrote on 04/29/2010 
05:27:24 AM:

> On 28 April 2010 19:09,  <mizematr at notes.udayton.edu> wrote:
> >
> > Is there any documentation out there for writing a Sakai helper from
> > scratch?  My googling has turned up little to nothing on the topic.
> 
> Are you wanting to write a helper to replace an existing one?
> Or call an existing helper from a new tool?
> Or just curious how helpers work?
> 
> I've written a new helper for handling some stuff from Site Info and
> I've called existing helpers from tools, so can probably go a dig up
> how I did it....
> 
> Ok, so to dispatch to a helper in a tool I did:
> 
> I have a path inside my tool that always passes the request through 
> to a helper:
> 
>       ActiveTool tool = 
ActiveToolManager.getActiveTool("sakai.sitesetup");
>       req.removeAttribute(ActiveTool.NATIVE_URL); // Forgot why I did 
this....
>       tool.help(req, res, null, null);
> 
> Then to start the helper I stuff some stuff into the sakai session and
> redirect to the path I've mapped to the helper:
> 
>       // This will actually be a tool session specific to this tool.
>       HttpSession session = request.getSession();
>       // Chuck the URL into the session so another controller can use 
it.
>       session.setAttribute(ATTRIBUTE_URL, newSite.getName());
> 
>       // This is the URL the helper should send the browser to when done
>       session.setAttribute(Tool.HELPER_DONE_URL, 
request.getContextPath()+
> request.getServletPath()+getReturnPath());
> 
>       // Stash some stuff into the session so the helper can see it.
>       session.setAttribute(SiteHelper.SITE_CREATE_SITE_TYPES, 
> "project,course");
>       session.setAttribute(SiteHelper.SITE_CREATE_SITE_TITLE, 
> newSite.getTitle());
> 
>       // Then redirect/forward through to the path mapped to the helper.
> 
> My helper then has control and as long as it doesn't change the path
> should continue working. When it's done it redirects the browser to
> the Tool.HELPER_DONE_URL from the session:
> 
>    ToolSession sakaiSession = SessionManager.getCurrentToolSession();
>    String url = (String) 
sakaiSession.getAttribute(Tool.HELPER_DONE_URL);
>    response.sendRedirect(url);
> 
> Again the helper can pass results through the session if it wants to.
> 
> Some examples of helpers in the Sakai codebase are the login tool,
> resources file picker, permissions manager and in newer releases
> (2.6+) parts of Site Info have been refactored into helpers (choosing
> participants to add and managing groups).
> 
> -- 
>   Matthew Buckett
>   VLE Developer, LTG, Oxford University Computing Services


---------------------------------------------------------------------------
Matt Mize, Systems Administrator
 - Pay no attention to the man in the back office....
Matt.Mize at notes.udayton.edu
(937) 229-1024

UDit Department, University of Dayton
300 College Park, Dayton, OH, 45469-1302
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100429/ed3c7b56/attachment.html 


More information about the sakai-dev mailing list