If you look at the source code of the Item Selector (https://github.com/bkoopman/sdl-tridion-world/blob/master/Item%20Selector/trunk/SDLTridion.Examples.ItemSelector/UserControls/TridionTreeView.ascx.cs) you might notice the following:
private TreeNode CreateTreeNode(string nodeText, string nodeValue)
{
TcmUri uri = new TcmUri(nodeValue);
if (uri.ItemType == ItemType.WorkItem)
{
if (!_showItemTypes.Contains(ItemType.Category))
{
return null;
}
}
if (!_showItemTypes.Contains(uri.ItemType))
{
return null;
}
TreeNode tNode = new TreeNode(nodeText, nodeValue) { Expanded = false, ImageUrl = UriImage(uri) };
switch (uri.ItemType)
{
case ItemType.Publication:
case ItemType.Folder:
case ItemType.StructureGroup:
case ItemType.Category:
case ItemType.Keyword:
case ItemType.WorkItem:
tNode.PopulateOnDemand = true;
break;
default:
tNode.PopulateOnDemand = false;
break;
}
if (!_selectedItemTypes.Contains(uri.ItemType))
{
// disable select action (set to expand)
tNode.SelectAction = TreeNodeSelectAction.Expand;
}
else
{
// call javascript from navigate url to prevent post (post will loose window.dialogarguments)
tNode.NavigateUrl = "javascript:setvalue('" + nodeValue + "');";
}
return tNode;
}
In the end you see the generation of the javascript callback with the nodeValue
, which currently is the TCM URI.
If you want to return a WebDAV URL, that javascript line is what you should change, by getting the WebDAV URL from the item, something like this should do the trick I guess:
RepositoryLocalObjectData item = (RepositoryLocalObjectData)_client.Read(nodeValue, new ReadOptions());
tNode.NavigateUrl = "javascript:setvalue('" + item.LocationInfo.WebDavUrl + "');";
To answer your question if it is wise to use a WebDAV URL, rather than a TCM URI. To be honest, it is never a good idea to link to any item using an unmanaged link. The Item Selector does exactly that, it creates an unmanaged link, by pasting a reference to an item in a text field. But the reality is, that sometimes this is your only option.
I built the Item Selector as an example of how to use the Core Service in a Custom Page (or Custom URL in this case actually). It serves a useful purpose as an Item Selector, which complemented the Rapid Editorial Interface event system I built before it. You are free to use it as is or modify any way you like (for instance by returning the WebDAV URL like explained above). But keep in mind what you are doing with regards to unmanaged links, and know what concequenses that has. That being said, a WebDAV URL might indeed be a better solution than the TCM URI, if you need to port this information between environments.