1

Already I am having a fully functioning button created named "buttonreference". And I am trying to create a different button with the same functionality and different name like "TestButton". I followed these steps.

  1. Created a folder named Testbutton.
  2. Created virtual directory for this folder.
  3. Created editor in System config.
  4. But when I am trying to access this button, its triggering PopupReference.js which is in buttonreference folder rather than triggering PopupReference.js which is in my Folder "Testbutton". I have no clue why its not triggring my js?

My Testbutton.js is as follows:

Type.registerNamespace("RTFExtensions.Commands");

RTFExtensions.Commands.TestButton = function Commands$TestButton(name) {
Type.enableInterface(this, "RTFExtensions.Commands.TestButton");
this.addInterface("Tridion.Cme.Command", [name || "TestButton"]);
this.addInterface("Tridion.Cme.FaCommand", [name || "TestButton"]);
};

RTFExtensions.Commands.TestButton.prototype._isAvailable = function     TestButton$_isAvailable(target) {
if (target.editor.getDisposed()) {
    return false;
}

return true;
};

RTFExtensions.Commands.TestButton.prototype._isEnabled = function     TestButton$_isEnabled(target) {
if (!Tridion.OO.implementsInterface(target.editor, "Tridion.FormatArea")     || target.editor.getDisposed()) {
    return false;
}

return true;
};

RTFExtensions.Commands.TestButton.prototype._execute = function TestButton$_execute(target) {
if (target.item.isActivePopupOpened()) {
    return;
}

function TestButton$execute$onPopupCanceled(event) {
    target.item.closeActivePopup();
};

var url = $config.expandEditorPath("/Popups/PopupReference.aspx","TestButton");
//alert(url);
var popup = $popup.create(url,"toolbar=no,width=900,height=800,resizable=yes,scrollbars=yes", null);

$evt.addEventHandler(popup, "submit",
    function TestButton$execute$onPopupSubmitted(event) {

        alert('Inside testbuttonjs');

        // Release
        target.item.closeActivePopup();
    }
);

$evt.addEventHandler(popup, "unload", TestButton$execute$onPopupCanceled);

target.item.setActivePopup(popup);
popup.open();
};

My TestButton config file is like this :

<?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="RTFExtensions.TestButton">
    <cfg:fileset>

      <cfg:file type="script">/Popups/PopupReference.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:group    name="RTFExtensions.TestButton.Commands" merger="Tridion.Web.UI.Core.Configuration.Resources.CommandGroupProcessor" include="byreference"   merge="release">
    <cfg:fileset>
      <cfg:file type="script">/Commands/TestButton.js</cfg:file>

      <cfg:file     type="reference">RTFExtensions.TestButton.CommandSet</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: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>
        <!-- RIBBON TAB -->

        <!-- GROUPS -->
        <ext:extension assignid="ExtensionGroup" pageid="FormatPage" name="RTF Extensions">
          <ext:group/>
          <ext:apply>
            <ext:view name="ComponentView">
              <ext:control id="ItemToolbar"/>
            </ext:view>
          </ext:apply>
        </ext:extension>

        <!-- BUTTONS -->
        <ext:extension pageid="FormatPage" groupid="ExtensionGroup"     name="TestButton" assignid="TestButton">
          <ext:command>TestButton</ext:command>
          <ext:title>TestButton</ext:title>
          <ext:dependencies>
                    <cfg:dependency>RTFExtensions.TestButton.Commands</cfg:dependency>
          </ext:dependencies>
          <ext:apply>
            <ext:view name="ComponentView">
              <ext:control id="ItemToolbar"/>
            </ext:view>
          </ext:apply>
        </ext:extension>
      </ext:add>
    </ext:ribbontoolbars>
  </ext:editorextension>
    </ext:editorextensions>
    <ext:dataextenders/>
</extensions>
<commands>
    <cfg:commandset id="RTFExtensions.TestButton.CommandSet">
  <cfg:command name="TestButton"    implementation="RTFExtensions.Commands.TestButton"/>
  <cfg:dependencies>
    <cfg:dependency/>
  </cfg:dependencies>
    </cfg:commandset>
</commands>
<contextmenus/>
<localization/>
<settings>
<defaultpage/>
<navigatorurl/>
<editurls/>
<listdefinitions/>
<itemicons/>
<theme>
  <path>Themes</path>
    </theme>
    <customconfiguration/>
 </settings>
</Configuration>

My PopupReference.Js is like :

Type.registerNamespace("RTFExtensions.Popups");

RTFExtensions.Popups.PopupReference = function (element) {
Type.enableInterface(this, "RTFExtensions.Popups.PopupReference");
this.addInterface("Tridion.Cme.View");
};

RTFExtensions.Popups.PopupReference.prototype.initialize = function () {
$log.message("Initializing Button Reference popup...");
this.callBase("Tridion.Cme.View", "initialize");
$log.message("Initializing TestButton Reference popup...");
var p = this.properties;
var c = p.controls;

p.HtmlValue = { value: null };

c.InsertButton = $controls.getControl($("#InsertButton"), "Tridion.Controls.Button");
$evt.addEventHandler(c.InsertButton, "click", this.getDelegate(this._execute));
};

RTFExtensions.Popups.PopupReference.prototype._execute = function () {
alert('Inside Popupreferencejs');
this.fireEvent("submit", this.properties.HtmlValue);
window.close();
};

$display.registerView(RTFExtensions.Popups.PopupReference);

My CS page for TestButton is like :

namespace Tridion.GUI.Extensions.RTF.Popups
{
[ControlResourcesDependency(new Type[] { typeof(Popup), typeof(Tridion.Web.UI.Controls.Button), typeof(Stack), typeof(Dropdown), typeof(List) })]
[ControlResources("RTFExtensions.TestButton")]
public partial class PopupReference : TridionPage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        TridionManager tm = new TridionManager();

        tm.Editor = "RTFTestButton";
        System.Web.UI.HtmlControls.HtmlGenericControl dep = new System.Web.UI.HtmlControls.HtmlGenericControl("dependency");
        dep.InnerText = "Tridion.Web.UI.Editors.CME";
        tm.dependencies.Add(dep);

        System.Web.UI.HtmlControls.HtmlGenericControl dep2 = new System.Web.UI.HtmlControls.HtmlGenericControl("dependency");
        dep2.InnerText = "Tridion.Web.UI.Editors.CME.commands";
        tm.dependencies.Add(dep2);

        //Add them to the Head section
        this.Header.Controls.Add(tm); //At(0, tm);
    }
}
}

Can anyone help me finding the issue. Am I missing anystep while creating a new button? Do I need to keep .dll to anywhere?

Bart Koopman
  • 4,835
  • 17
  • 30
SDLBeginner
  • 829
  • 1
  • 7
  • 19
  • It will call PopupReference.js from /Popups/PopupReference.js. Are you sure this is the correct path. I can't see how it would call any other file as there is no other file configured... – Jeremy Grand-Scrutton Aug 13 '12 at 07:58
  • @Jeremy yes Jeremy path is correct. dont know why its calling popupreference.js from buttonreference folder rather than calling it fron testbutton folder – SDLBeginner Aug 13 '12 at 08:40

2 Answers2

2

To me everything looks good-to-go!

In your c# you're calling the reference group using the code:

[ControlResources("RTFExtensions.TestButton")]

I also see that your config file contains the group 'RTFExtensions.TestButton' so everything does look ok.

Have you built the .net project and dropped the DLL into the [tridion_home]/web/webUI/webRoot/bin

??

johnwinter
  • 3,624
  • 15
  • 24
  • No john i didnt build the project. and didnt put the DLL into that path. – SDLBeginner Aug 13 '12 at 08:42
  • What happens if you do compile it and put the dll there? – Jeremy Grand-Scrutton Aug 13 '12 at 10:08
  • @Jeremy I am using the exsiting one Popupreference.aspx , if i am going to create a new one same as the existing one its giving error, i am not able to build the .net solution. – SDLBeginner Aug 13 '12 at 10:23
  • @johnwinter RTFExtension.dll is already there in that bin folder. I am using same DLL for my button too. can i do like this ? – SDLBeginner Aug 13 '12 at 10:47
  • If you're having problems compiling the code then perhaps you should be asking why that is the case. Isn't it obvious that precompiled code is unlikely to work if you change something that it is based on? – Jeremy Grand-Scrutton Aug 13 '12 at 11:02
  • Hi - Are you sure that your RTFExtension.dll contain the above code, it compiles and it is in the correct Bin directory? - What is the error message you receive? How are you trying to debug what's going wrong here? – johnwinter Aug 13 '12 at 11:03
  • @johnwinter RTFExtension.dll contains the old code for buttonreference, how can i compile the same for my TestButton. When i tried to create a new project with popupreference.aspx for my TestButton its giving error like you are missing Assembly Reference or Namespace. – SDLBeginner Aug 13 '12 at 11:21
  • @johnwinter hi john thanks i got my js triggered.. thanks for the grt advice.... :) – SDLBeginner Aug 13 '12 at 12:17
  • No problem, glad you've got it sorted :) – johnwinter Aug 13 '12 at 12:27
2

You must compile the dll for the updated code in the popup aspx page. If not you will be using whichever values were present in the page when the code was compiled.

Jeremy Grand-Scrutton
  • 2,802
  • 14
  • 20
  • yes i am facing problem in compiling the codes for my "TestButton". When i am creating a new project with new popupreference.aspx its giving error like "You are missing Assembly Reference or Namespace." – SDLBeginner Aug 13 '12 at 11:19
  • 1
    So all you need to do is add the missing reference. Typically shared source code for extensions will be missing certain references due to licensing restrictions. VS will tell you what's missing. – Jeremy Grand-Scrutton Aug 13 '12 at 11:33
  • Thanks a lot.. i compiled my code and placed the DLl. and its triggring my Js .. :) – SDLBeginner Aug 13 '12 at 12:18