GUI Extensions - Resources failing to load - tridion

I'm kinda at a loss as to what exactly I'm doing wrong, so hopefully by throwing this out there someone should be able to point something hopefully obvious out to me.
A new GUI extension is being created that will sit as a button on a new Events tab of the Tridion ribbon bar. I can get the button to appear, however no icon appears for the button and is always disabled, which leads me to believe the stylesheet and javascript resources for the extension are not loading :S
My editor config is as follows:
<?xml version="1.0"?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge" xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration" xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions" xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu">
<resources>
<cfg:filters/>
<cfg:groups>
<cfg:group name="Events.Cvent">
<cfg:fileset>
<cfg:file type="style">/Theme/cvent.css</cfg:file>
<cfg:file type="reference">Events.Commands.Cvent</cfg:file>
</cfg:fileset>
</cfg:group>
<cfg:group name="Events.Cvent.Commandset">
<cfg:fileset>
<cfg:file type="script">/Scripts/cvent.js</cfg:file>
</cfg:fileset>
<cfg:dependencies>
<cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
</cfg:dependencies>
</cfg:group>
</cfg:groups>
</resources>
<definitionfiles/>
<extensions>
<ext:dataextenders/>
<ext:editorextensions>
<ext:editorextension target="CME">
<ext:editurls/>
<ext:listdefinitions/>
<ext:taskbars/>
<ext:commands/>
<ext:commandextensions/>
<ext:contextmenus/>
<ext:lists/>
<ext:tabpages/>
<ext:toolbars/>
<ext:ribbontoolbars>
<ext:add>
<ext:extension assignid="EventsPage" name="Events">
<ext:control/>
<ext:pagetype/>
<ext:apply>
<ext:view name="DashboardView">
<ext:control id="DashboardToolbar"/>
</ext:view>
</ext:apply>
</ext:extension>
<ext:extension assignid="EventsAdministrationGroup" pageid="EventsPage" name="Administration">
<ext:group/>
<ext:apply>
<ext:view name="DashboardView">
<ext:control id="DashboardToolbar"/>
</ext:view>
</ext:apply>
</ext:extension>
<ext:extension assignid="CventBtn" groupid="EventsAdministrationGroup" name="Import Cvent Events" pageid="EventsPage">
<ext:command>Cvent</ext:command>
<ext:title>Import Cvent Events</ext:title>
<ext:dependencies>
<cfg:dependency>Events.Cvent</cfg:dependency>
</ext:dependencies>
<ext:apply>
<ext:view name="DashboardView">
<ext:control id="DashboardToolbar"/>
</ext:view>
</ext:apply>
</ext:extension>
</ext:add>
</ext:ribbontoolbars>
</ext:editorextension>
</ext:editorextensions>
<ext:modelextensions/>
</extensions>
<commands>
<cfg:commandset id="Events.Commands.Cvent">
<cfg:command name="Cvent" implementation="Events.Commands.OpenCvent"/>
<cfg:dependencies>
<cfg:dependency>Events.Cvent.Commandset</cfg:dependency>
</cfg:dependencies>
</cfg:commandset>
</commands>
<contextmenus/>
<localization/>
<settings>
<defaultpage/>
<editurls/>
<listdefinitions/>
<theme>
<path>/Theme/</path>
</theme>
<customconfiguration>
<clientconfiguration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge">
<Cventurl xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge">/Cvent/Cvent.aspx</Cventurl>
</clientconfiguration>
</customconfiguration>
</settings>
</Configuration>
All the resource files (javascript and css) I need are there in the directories as according to the config. My JS for GUI looks like the following:
Type.registerNamespace("Events.Commands");
Events.Commands.OpenCvent = function Commands$OpenCvent(name)
{
Type.enableInterface(this, "Events.Commands.OpenCvent");
this.addInterface("Tridion.Cme.Command", ["Cvent"]);
this.properties.url;
};
Events.Commands.OpenCvent.prototype._isAvailable = function OpenCvent$_isAvailable(selection, pipeline)
{
return true;
};
Events.Commands.OpenCvent.prototype._isEnabled = function OpenCvent$_isEnabled(selection, pipeline)
{
return true;
};
Events.Commands.OpenCvent.prototype._execute = function OpenCvent$_execute(selection, pipeline)
{
window.open('www.google.com');
};
Restarted Tridion and still nothing, what am I doing wrong?

You can check whether or not your files are included by loading the CME with the ?mode=js and ?mode=css parameters.
Don't forget that those files are heavily cached - and just changing the configuration does not invalidate the cache. You need to either increase the #modification attribute in System.config (to invalidate the cache of all clients) - or simply clear your browser cache manually (easiest while developing).
If your changes are not in those files, it's likely a problem with your editor config. As Chris pointed out, files are only included if something else is included which has a dependency on it. If you enable tracing, you can see why your files are not being included in the resulting log file (Tridion.Web.trace).
Check out section 6 of this article for more information on how to do that: http://www.sdltridionworld.com/articles/sdltridion2011/tutorials/debugging_the_tridion_2011_cme.aspx

I can't tell you what exactly is wrong with your extension, but maybe you can have a look at an existing GUI Extension (in fact several extensions) and maybe you can compare what is wrong with yours. Have a look at the PowerTools http://code.google.com/p/tridion-2011-power-tools/
Also some good examples on http://www.sdltridionworld.com, e.g. http://www.sdltridionworld.com/articles/sdltridion2011/tutorials/GUIextensionIn8steps.aspx

I believe the dependencies will not actually get loaded unless they are used and referenced from within the comandset nodes of the config. Could you include your complete editor.config rather than just the extract?

Related

How to manage mongorepository singleton using unity

I want to use unity to manage my mongo repository but when I try registering it using the Web.config and LoadConfiguration() I get an error I am unable to decipher:
An exception of type 'System.ArgumentException' occurred in
Microsoft.Practices.Unity.Configuration.dll but was not handled in
user code
Additional information: The container named "" is not defined in this
configuration section.
This is my Global.asax
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
namespace OOP_project
{
public class MvcApplication : System.Web.HttpApplication
{
internal static readonly IUnityContainer unity = new UnityContainer();
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
unity.LoadConfiguration();
}
}
}
and this is the relevant part of my Web.config
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
</configSections>
<unity>
<typeAliases>
<typeAlias alias="string" type="System.String, mscorlib" />
</typeAliases>
<containers>
<container name="container">
<types>
<type type="MongoRepository.MongoRepository`1, MongoRepository" mapTo="MongoRepository.MongoRepository`1, MongoRepository">
<lifetime type="Singleton" />
<constructor>
<param name="connectionString" parameterType="string" value="mongodb://127.0.0.1/Blog"></param>
</constructor>
</type>
</types>
</container>
</containers>
</unity>
I would like to understand what this error actually means and how to fix it.
I see two problems with your code:
First, you need to specify the container name when you call LoadConfiguration. In the configuration file, the container name is "container" (in the <container> xml element), so you need to specify that like this:
unity.LoadConfiguration("container");
Or alternatively, change the container name in the configuration file to an empty string like this:
<container name="">
The second problem which is not directly related to your question is that the singleton lifetime should be specified with a small letter like this:
<lifetime type="singleton" />
By the way, why do you want to use a configuration file to configure Unity? Configuring Unity with a configuration file is brittle. For example, if you change a class name in code, it will not change in the configuration file. You would have to change it manually or your application would break.
Unless you need to be able to change dependencies without recompilation, your should prefer to configure the container via code.
Please note that you could make some of the registrations through code and some in the configuration file (for the dependencies that you need to be able to change without recompilation). You could easily find a resource online of how to do that.

With Glimpse How To Turn It Off Without Disabling?

I love Glimpse but only when I' interested in what it has to tell me. I have a glimpse role that I can turn on and off to make glimpse go away (see code below) but what I really want is to be able to turn it on and off while it is enabled in my global.asax. I've tried going to site.com/glimpse.axd and set "turn glimpse off" but then on the next page refresh it is back.
What am I missing?
public class GlimpseSecurityPolicy : IRuntimePolicy
{
public RuntimePolicy Execute(IRuntimePolicyContext policyContext)
{
var httpContext = policyContext.GetHttpContext();
if (!httpContext.User.IsInRole("GlimpseUser"))
{
return RuntimePolicy.Off;
}
return RuntimePolicy.On;
}
public RuntimeEvent ExecuteOn
{
get { return RuntimeEvent.EndRequest; }
}
}
In My Web.Config:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet" />
<add type="Glimpse.Core.Policy.ControlCookiePolicy, Glimpse.Core" />
</ignoredTypes>
</runtimePolicies>
Ok, the reason why clicking on the "Turn Glimpse Off" button has no effect is because the ControlCookiePolicy is disabled in the config, hence clicking that button will have no effect.
So you need to remove that entry from the config to make that work again:
<add type="Glimpse.Core.Policy.ControlCookiePolicy, Glimpse.Core" />
when you are saying that
The other code public class GlimpseSecurityPolicy" is in my global.asax
you mean that the GlimpseSecurityPolicy is basically defined as an inner class of the Mvc Application class?
Either way if you would enable logging for Glimpse in the config
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<logging level="Trace" />
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet" />
</ignoredTypes>
</runtimePolicies>
</glimpse>
then you should see a glimpse.log file appear in the root of your web application, and once the application is started, you should see an entry like this:
2014-06-13 09:48:25.8498 | DEBUG | Discovered IRuntimePolicy of type 'SOME NAMESPACE+GlimpseSecurityPolicy' and added it to collection. |
If that is the case then the policy is actually discovered.
You can put a breakpoint inside the Execute method to check whether a call is actually made and what the outcome is.

How do you configure an SDL Tridion CME extension for a subset of views?

I have created a new editor for SDL Tridion which adds some new functionality to the ribbon bar. This is enabled by adding the following snippet to the editor.config
<!-- ItemCommenting PowerTool -->
<ext:extension assignid="ItemCommenting" name="Save and<br/>Comment" pageid="HomePage" groupid="ManageGroup" insertbefore="SaveCloseBtn">
<ext:command>PT_ItemCommenting</ext:command>
<ext:title>Save and Comment</ext:title>
<ext:issmallbutton>false</ext:issmallbutton>
<ext:dependencies>
<cfg:dependency>PowerTools.Commands</cfg:dependency>
</ext:dependencies>
<ext:apply>
<ext:view name="*" />
</ext:apply>
</ext:extension>
This is applied to all views by using a wildcard value in the node. This has results in my new button being added to the ribbon of every view, including the main dashboard. Is there a way to add this to all views except for the dashboard? Or do I have to create something like this?
<ext:apply>
<ext:view name="PageView" />
<ext:view name="ComponentView" />
<ext:view name="SchemaView" />
</ext:apply>
If this is the only way to achieve the result I need, is there a list of all the view names somewhere?
Workaround provided by Jaime will not gonna work, because:
Ribbon Toolbar will hide buttons only on the Create tab if isAvailable
method of the corresponding command will return false.
Most of the buttons in RibbonToolbar implements specific Tridion.Controls.RibbonButton interface. This means, when you'll try
to get Tridion.Controls.Button control for the same element - you'll
get totally different control, based on the same html element. So
RibbonToolbar will not know about it and it will work incorrectly.
If you want to hide button in RibbonToolbar, you should use public methods on RibbonToolbar and RibbonPage instead. Thus it will be correctly handled by RibbonToolbar. Example:
var toolbar = $controls.getControl($("#ItemToolbar"), "Tridion.Controls.RibbonToolbar");
var page = toolbar.getPageById("HomePage");
page.hideItem(buttonId);
page.showItem(buttonId);
As for the original question, here is pretty simple and easiest solution:
<ext:add>
<ext:extension assignid="ItemCommenting" name="Save and<br/>Comment" pageid="HomePage" groupid="ManageGroup" insertbefore="SaveCloseBtn">
<ext:command>PT_ItemCommenting</ext:command>
<ext:title>Save and Comment</ext:title>
<ext:issmallbutton>false</ext:issmallbutton>
<ext:dependencies>
<cfg:dependency>PowerTools.Commands</cfg:dependency>
</ext:dependencies>
<ext:apply>
<ext:view name="*" />
</ext:apply>
</ext:extension>
</ext:add>
<ext:remove>
<ext:extension id="ItemCommenting">
<ext:apply>
<ext:view name="DashboardView" />
</ext:apply>
</ext:extension>
</ext:remove>
As far as I know you need to specify all the views or use the wildcard. It will be nice that the isAvailable functionality would work for the Ribbon Tool bar buttons, right? Meaning that if the command returns false in the _isAvailable method, the button will not show...
Well, I found a work around. You can do something like this within your isAvailable method in your command:
Your.Namespace.PT_ItemCommenting.prototype._isAvailable = function PT_ItemCommenting$_isAvailable(selection) {
var isAvailable = $display.getView().getId()!='DashboardView';
if(isAvailable){
return true;
}
var button = $controls.getControl($("#ItemCommenting"), "Tridion.Controls.Button");
button.hide();
return false;
};
I think this is actually a good practice, since it will "hide" the commands if they shouldn't be available, right?
Let me know how it works out.

How to redirect to the different pages in Tridion using Ribbon Toolbar button?

Am implementing the Ribbon toolbar button. On button click depending upon the schema name, I need to create the popup with corresponding url (Aspx page). Previously I worked with only one aspx page and I am succeeded in the same, I created a popup java script file with the same name as aspx page and configured it in configuration file. But in case of multiple aspx pages even if I create multiple popup javascript files.It is not calling the respected javascript file.
How to map the popup java script files to aspx pages in case of multiple aspx pages?
PFB the code samples.
Button java script file code fragment:
if (some condition) {
//Creating the url
var url = "Editors/RTFExtension/Popups/ButtonReferencePopup_2.aspx?schemaId='" + schemaId + "'";
var popup = $popup.create(url, "toolbar=no,width=500,height=200,resizable=yes,scrollbars=yes", null);
}
else{
//Creating the url
var url = "Editors/RTFExtension/Popups/ButtonReferencePopup.aspx?schemaId='" + schemaId + "'";
var popup = $popup.create(url, "toolbar=no,width=500,height=200,resizable=yes,scrollbars=yes", null);
}
Config file code fragment:
<cfg:group name="RTFExtension.ButtonReference">
<cfg:fileset>
<cfg:file type="script">/Popups/ButtonReferencePopup.js</cfg:file>
<cfg:file type="script">/Popups/ButtonReferencePopup_2.js</cfg:file>
<cfg:file type="style">/Themes/ButtonReference.css</cfg:file>
</cfg:fileset>
<cfg:dependencies>
<cfg:dependency>Tridion.Web.UI.Controls</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
</cfg:dependencies>
</cfg:group>
Please help me out in this issue. Thanks in advance. Early response is appreciated.
I believe you need to configure different groups for each config - something like this:
<cfg:group name="RTFExtension.ButtonReference.Popup1">
<cfg:fileset>
<cfg:file type="script">/Popups/ButtonReferencePopup.js</cfg:file>
<cfg:file type="style">/Themes/ButtonReference.css</cfg:file>
</cfg:fileset>
<cfg:dependencies>
<cfg:dependency>Tridion.Web.UI.Controls</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
</cfg:dependencies>
</cfg:group>
<cfg:group name="RTFExtension.ButtonReference.Popup2">
<cfg:fileset>
<cfg:file type="script">/Popups/ButtonReferencePopup_2.js</cfg:file>
<cfg:file type="style">/Themes/ButtonReference.css</cfg:file>
</cfg:fileset>
<cfg:dependencies>
<cfg:dependency>Tridion.Web.UI.Controls</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
</cfg:dependencies>
</cfg:group>
In your popup code-behind you then need to reference the relevant group:
namespace Button.Reference.Popups
{
[ControlResourcesDependency(new Type[] { typeof(Popup), typeof(Tridion.Web.UI.Controls.Button), typeof(Stack), typeof(Dropdown), typeof(List) })]
[ControlResources("RTFExtensions.ButtonReference.Popup1")]
public partial class PopupReference1 : TridionPage
Or:
namespace Button.Reference.Popups
{
[ControlResourcesDependency(new Type[] { typeof(Popup), typeof(Tridion.Web.UI.Controls.Button), typeof(Stack), typeof(Dropdown), typeof(List) })]
[ControlResources("RTFExtensions.ButtonReference.Popup2")]
public partial class PopupReference2 : TridionPage

GUI Extension - TabPage not loading JS

I am adding a new Tab to the Component Edit screen. My tab is showing fine but the JavaScript is not loading. I would like to write out the URI of the current Component in the tab. I have a feeling the naming of my JavaScript methods is not correct or matching with the config, but really don't know how to say 'hello' from the JavaScript side.
I used the InfoTab View from the Tridion CME (code sample below) and also the PowerTools ItemXml for inspiration - but no luck.
What is the minimum set of methods in the JS to get hello world working?
Solution
Added the dependencies node from Rob's suggestion. The log then showed the js file as loading.
HelloTab.js
Type.registerNamespace("RC");
RC.HelloTab = function RC$HelloTab$HelloTab(element) {
console.log('Constructor');
Tridion.OO.enableInterface(this, "RC.HelloTab");
this.addInterface("Tridion.Controls.DeckPage", [element]); //My extension is like this
};
RC.HelloTab.prototype.initialize = function HelloTab$initialize()
{
console.log('init');
$log.debug('init');
this.callBase("Tridion.Controls.DeckPage", "initialize");
$evt.addEventHandler($display.getItem(), "load", this.getDelegate(this.updateView));
};
RC.HelloTab.prototype.select = function HelloTab$select()
{
console.log('select');
this.callBase("Tridion.Controls.DeckPage", "select");
this.updateView();
};
RC.HelloTab.prototype.updateView = function HelloTab$updateView()
{
console.log('update');
if (this.isSelected())
{
console.log('selected')
}
};
Tridion.Controls.Deck.registerPageType(RC.HelloTab, "RC.HelloTab");
HelloTab.config
<?xml version="1.0"?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge"
xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration"
xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions"
xmlns:cmenu="http://www.sdltridion.com/2009/GUI/extensions/ContextMenu">
<resources cache="true">
<cfg:filters />
<cfg:groups>
<cfg:group name="RC.HelloTab" merge="always">
<cfg:fileset>
<cfg:file type="script">/HelloTab.js</cfg:file>
</cfg:fileset>
<cfg:dependencies>
<cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
</cfg:dependencies>
</cfg:group>
</cfg:groups>
</resources>
<definitionfiles />
<extensions>
<ext:dataextenders/>
<ext:editorextensions>
<ext:editorextension target="CME">
<ext:editurls/>
<ext:listdefinitions/>
<ext:taskbars/>
<ext:commands/>
<ext:commandextensions/>
<ext:contextmenus/>
<ext:lists />
<ext:tabpages>
<ext:add>
<ext:extension assignid="HelloTab" name="Hi There!" insertbefore="InfoTab">
<ext:control>~/HelloTab.ascx</ext:control>
<ext:pagetype>RC.HelloTab</ext:pagetype>
<ext:dependencies>
<cfg:dependency>RC.HelloTab</cfg:dependency>
</ext:dependencies>
<ext:apply>
<ext:view name="ComponentView">
<ext:control id="MasterTabControl"/>
</ext:view>
</ext:apply>
</ext:extension>
</ext:add>
</ext:tabpages>
<ext:toolbars/>
<ext:ribbontoolbars/>
</ext:editorextension>
</ext:editorextensions>
</extensions>
<commands/>
<contextmenus />
<localization />
<settings>
<defaultpage/><!-- /Views/Default.aspx</defaultpage> -->
<navigatorurl/><!-- /Views/Default.aspx</navigatorurl> -->
<editurls/>
<listdefinitions />
<itemicons/>
<theme>
<path>theme/</path>
</theme>
<customconfiguration />
</settings>
</Configuration>
Original:
HelloTab.config
<resources cache="true">
<cfg:filters />
<cfg:groups>
<cfg:group name="RC.HelloTab" merge="always">
<cfg:fileset>
<cfg:file type="style">{ThemePath}/HelloTab.css</cfg:file>
<cfg:file type="script">/HelloTab/HelloTab.js</cfg:file>
</cfg:fileset>
<cfg:dependencies>
<cfg:dependency>Tridion.Web.UI.Editors.CME</cfg:dependency>
<cfg:dependency>Tridion.Web.UI.Editors.CME.commands</cfg:dependency>
</cfg:dependencies>
</cfg:group>
</cfg:groups>
</resources>
<definitionfiles />
<extensions>
<ext:dataextenders/>
<ext:editorextensions>
<ext:editorextension target="CME">
<ext:editurls/>
<ext:listdefinitions/>
<ext:taskbars/>
<ext:commands/>
<ext:commandextensions/>
<ext:contextmenus/>
<ext:lists />
<ext:tabpages>
<ext:add>
<ext:extension assignid="HelloTab" name="Hi There!" insertbefore="InfoTab">
<ext:control>~/HelloTab.ascx</ext:control>
<ext:pagetype>HelloTab</ext:pagetype>
<ext:apply>
<ext:view name="ComponentView">
<ext:control id="MasterTabControl"/>
</ext:view>
</ext:apply>
</ext:extension>
</ext:add>
</ext:tabpages>
<ext:toolbars/>
<ext:ribbontoolbars/>
</ext:editorextension>
</ext:editorextensions>
</extensions>
<commands/>
<contextmenus />
<localization />
<settings>
<defaultpage/><!-- /Views/Default.aspx</defaultpage> -->
<navigatorurl/><!-- /Views/Default.aspx</navigatorurl> -->
<editurls/>
<listdefinitions />
<itemicons/>
<theme>
<path>theme/</path>
</theme>
<customconfiguration />
</settings>
JavaScript:
Type.registerNamespace("RC.HelloTab");
RC.HelloTab = function HelloTab(element)
{
Tridion.OO.enableInterface(this, "RC.HelloTab");
this.addInterface("Tridion.Controls.DeckPage", [element]);
};
RC.HelloTab.prototype.initialize = function HelloTab$initialize()
{
$log.event("RC.HelloTab", "RC.HelloTab init");
this.callBase("Tridion.Controls.DeckPage", "initialize");
document.write("something else");
var item = $display.getItem();
if (item)
{
if (item.isLoaded())
{
this._showInfo();
}
else
{
item.load();
}
}
};
RC.HelloTab.prototype.select = function HelloTab$select()
{
this.callBase("Tridion.Controls.DeckPage", "select");
if (this.properties.itemChanged)
{
this._showInfo();
this.properties.itemChanged = false;
}
};
RC.HelloTab.prototype._showInfo = function HelloTab$_showInfo()
{
var item = $display.getItem();
var html = "<h1>title</h1>";
$dom.setOuterHTML($("#title"), html);
document.write('another uri=' + item.ID);
};
RC.HelloTab.prototype._onItemChanged = function HelloTab$_onItemChanged()
{
if (this.isSelected())
{
this._showInfo();
}
};
Tridion.Controls.Deck.registerPageType(RC.HelloTab, "HelloTab");
Tridion.Web.Trace:
w3wp.exe Information: 0 : (634734775171817068) CachedJssControlResources: LastModifiedTime for type HelloTab is 5/24/2012 5:22:26 PM
w3wp.exe Information: 0 : (634734770029374585) CachedJssControlResources: LastModifiedTime for type editors_hellotab_hellotab_ascx is 5/24/2012 5:22:26 PM
I think your problem is you're missing the dependency elements in the ext:extension element.
<ext:dependencies>
<cfg:dependency></cfg:dependency>
</ext:dependencies>
Add like so:
<ext:extension assignid="HelloTab" name="Hi There!" insertbefore="InfoTab">
<ext:control>~/HelloTab.ascx</ext:control>
<ext:pagetype>HelloTab</ext:pagetype>
<ext:dependencies>
<cfg:dependency>RC.HelloTab</cfg:dependency>
</ext:dependencies>
<ext:apply>
<ext:view name="ComponentView">
<ext:control id="MasterTabControl"/>
</ext:view>
</ext:apply>
</ext:extension>
If you're using Chrome you could put in some console.log statements (alerts if IE) into each of the methods you have implemented from the interface as a test and at the top of the file. E.g.:
console.log('Hello: File loaded');
One difference between your code and a GUI extension I've written recently is your constructor function name does not include the namespace.
I would expect it to be called:
RC.HelloTab = function RC$HelloTab$HelloTab(element)
{
console.log('Constructor');
Tridion.OO.enableInterface(this, "RC.HelloTab.HelloTab"); //Also was missing NS here
this.addInterface("Tridion.Controls.DeckPage", [element]); //My extension is like this
};
Another way to check is to use Chrome developer tools on the page you expect your Javascript to appear, go to the scripts tab and use the search box within the developer tools to search for your namespace.
Hope this helps.
Indeed, the dependency on the group with resource files is missing. That's why js was not present on the page. Btw, there are two ways to make a dependency:
Make a dependency in the ext:extension node (as Rob proposed)
If you have code behind for your HelloTab.ascx, you could use ControlResources attribute for the class definition
[ControlResources("RC.HelloTab")]public class HelloTab{}
Some additional comments:
The recommended way to use registerNamespace is to define only namespace object, but not the class itself. So in the provided code, there should be only Type.registerNamespace("RC");
Tridion.OO.enableInterface used to define the unique interface name for the class and set the API functions to use OO possibilities on the class. To this call actually makes possible to call addInterface method. Interface name could be any string, which should be unique. Usually, we use the name of the class with full namespace. So in this case original version was correct - Tridion.OO.enableInterface(this, "RC.HelloTab");.

Resources