[Building Sakai] Open a tool wit parameters
Steve Swinsburg
steve.swinsburg at gmail.com
Tue Jan 19 13:15:28 PST 2010
Hi Tania,
You can do something like the following:
ToolConfiguration toolConfig = getFirstInstanceOfTool(siteId, "sakai.profile2");
if(toolConfig == null) {
//tool doesn't exist in this site, do something
}
String pageId = toolConfig.getPageId();
String placementId = toolConfig.getId();
StringBuilder url = new StringBuilder();
url.append(portalUrl);
url.append("/site/");
url.append(siteId);
url.append("/page/");
url.append(pageId);
//only if we have params to add
if(StringUtils.isNotBlank(extraParams)) {
url.append("?toolstate-");
url.append(placementId);
url.append("=");
url.append(URLEncoder.encode(extraParams,"UTF-8"));
}
return url.toString();
You'll then get a url that looks like
/portal/site/siteId/page/pageId?toolstate-placementId=(url encoded params)
Here's a working example that links to the Profile2 tool in a user's My Workspace, takes them to the Message page, and then shows a specific message thread. Of course, the receiving tool needs to be able to handle the params. In a Wicket tool, these params are automatically available in the PageParameters object. You can checkout the class source in Profile2 if you like.
http://localhost:8080/portal/site/~0cec13cb-3999-47d7-81f7-78582ffa4aa9/page/e3d80831-a36e-4a9c-b834-12430e62e8b7?toolstate-be8f4b9c-29b9-4b29-a835-b2211fed06a2=%3Fwicket%3AbookmarkablePage%3D%3Aorg.sakaiproject.profile2.tool.pages.MyMessageView%26thread%3D07e9506b-5133-4359-b773-c6b5117b1179
cheers,
Steve
On 20/01/2010, at 1:28 AM, Tania Tritean wrote:
> Hello,
>
> I have a question:
> How can I open a tool from another tool and be able to sent parameters to the new requested tool (so I will be able to use those values in the frame of the tool)?
>
> Thanks
>
> Tania
> _______________________________________________
> 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/20100120/56455444/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3823 bytes
Desc: not available
Url : http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100120/56455444/attachment.bin
More information about the sakai-dev
mailing list