The spring configuration wires on the server, and I'm guessing user info cannot be derived from anything configured there. Therefore, I solved this using a custom javascript action handler.
First off, I wired in my custom javascript in share-config-custom.xml like so:
<config>
<forms>
<dependencies>
<js src="/components/documentlibrary/my-actions.js" />
</dependencies>
</forms>
</config>
In this javascript file, I defined a javascript function for action handling:
/**
* Call a given url like an action of type 'link' would, but allows for configuration of the window.open call and
* appends the username of the active user in share to the url.
*
* Uses the 'href' param to form the URL, and allows for the 'name' and 'specs' param.
*
* @method onMyUserActionLink
* @param record {object} Object literal representing one file or folder to be actioned
* @param owner
*/
onMyUserActionLink : function dlA_onMyUserActionLink(record, owner) {
Alfresco.logger.debug("onMyUserActionLink");
var scope = this, nodeRef = record.nodeRef, jsNode = record.jsNode;
Alfresco.logger.debug("Scope formed");
// Get action & params
var params = this.getAction(record, owner).params;
Alfresco.logger.debug("Params retrieved");
// Get URL
var url = params.href;
Alfresco.logger.debug("URL: " + url);
// Append username
var appendage;
if(url.contains("?")) {
appendage = "&u="+Alfresco.constants.USERNAME;
} else {
appendage = "?u="+Alfresco.constants.USERNAME;
}
url += appendage;
Alfresco.logger.debug("URL+u: "+url);
// Check for name
var name = "_blank";
if(params["name"]) {
name = params["name"];
}
Alfresco.logger.debug("Name: "+name);
// Check for specs
var specs = "channelmode=yes,directories=no,fullscreen=yes,location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes,titlebar=yes,toolbar=yes,top=0,left=0";
if(params["specs"]) {
specs = params["specs"];
}
Alfresco.logger.debug("specs: "+specs);
Alfresco.logger.debug("Opening window with url: "+url +", specs: "+specs+", name: "+name);
window.open(url, name, specs);
}
I then registered the handlers for several Action contexts:
(function() {
if (Alfresco.DocumentList) {
YAHOO.lang.augmentProto(Alfresco.DocumentList, MY.doclib.FolderActions);
}
if (Alfresco.DocListToolbar) {
YAHOO.lang.augmentProto(Alfresco.DocListToolbar, MY.doclib.FolderActions);
}
if (Alfresco.DocumentActions) {
YAHOO.lang.augmentProto(Alfresco.DocumentActions, MY.doclib.FolderActions);
}
if (Alfresco.FolderActions) {
YAHOO.lang.augmentProto(Alfresco.FolderActions, MY.doclib.FolderActions);
}
if (Alfresco.doclib.Actions) {
YAHOO.lang.augmentProto(Alfresco.doclib.Actions, MY.doclib.FolderActions);
}
if (Alfresco.doclib.FolderActions) {
YAHOO.lang.augmentProto(Alfresco.doclib.FolderActions, MY.doclib.FolderActions);
}
})();
I changed my action bean configuration to work with this accordingly in share-config-custom.xml:
<action id="myaction" type="javascript" label="actions.mine.menu.label" icon="my-icon">
<param name="function">onMyUserActionLink</param>
<param name="itemKind">action</param>
<param name="itemId">myAction</param>
<param name="mode">create</param>
<param name="destination">{node.nodeRef}</param>
<param name="successMessage">actions.mine.success</param>
<param name="failureMessage">actions.mine.fail</param>
<param name="href">/mylink/linky?id={node.properties.my_idProp}&prop2={node.properties.my_prop2}</param>
<param name="name">_blank</param>
<evaluator>evaluator.oa.action.isWhatIWant</evaluator>
</action>
The action calls my custom javascript, which appends the username, then proceeds to work as a link.
Shame even alfresco employees weren't able to respond to this, but I sure hope with the current lack of share client javascript on the internet this will help a good deal of developers!
TIP: For example bean configurations, look at share\WEB-INF\classes\alfresco\share-documentlibrary-config.xml
. For example javascript, look at share\js\documentlibrary-actions.js
.