cancel
Showing results for 
Search instead for 
Did you mean: 

Form problem

kiri31
Champ in-the-making
Champ in-the-making
Hi, i try to make a form like the webview configuration.
The form appears, but problems raise when i submit the form :

org.alfresco.web.scripts.WebScriptException: 05040001 Failed to load script '/or
g/alfresco/modules/test/config-test.post.json.js (in classpath store file:C:
/Alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts)': 05040
000 TypeError: Cannot read property "properties" from null (file:C:/Alfresco/tom
cat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/modules/
test/config-test.post.json.js#7)

here the contain of config-test.post.json.js

var c = sitedata.getComponent(url.templateArgs.componentId);

var testLogin = String(json.get("testLogin"));
var testPass = String(json.get("testPass"));
var testURL = String(json.get("testURL"));

c.properties["testLogin"] = testLogin;
model.testLogin = (testLogin == "") ? null : testLogin;

c.properties["testPass"] = testPass;
model.testPass = (testPass == "") ? null : testPass;

c.properties["testURL"] = testURL;
model.testURL = (testURL == "") ? null : testURL;

c.save();

Thanks a lot for your help
5 REPLIES 5

mikeh
Star Contributor
Star Contributor
The error suggests "c" is null.

Are you making sure the componentId is on the URL to your webscript and defined as a variable in the webscript descriptor file?

Mike

kiri31
Champ in-the-making
Champ in-the-making
thanks for you help.

Here the contain of config-test.post.desc.xml :

<webscript>
  <shortname>Test Config post</shortname>
  <description>Configuration dialog for Test dashlet</description>
  <url>/modules/test/config/{componentId}</url>
  <format default="html">argument</format>
</webscript>

mikeh
Star Contributor
Star Contributor
Ok, so what's the URL you are POSTing to from your client-side javascript?

Better yet, use Firebug to look at the complete POST method.

Mike

kiri31
Champ in-the-making
Champ in-the-making
Hi,

I try to use Firebug but i'm not very skilled. And I'm sorry but I don't understand when you 're talking about "POSTing to from your client-side javascript".
So here, all the remaining javascript :

test.get.js :
var uri = args.testURI;

if (!uri)
{
   // Use the default
   var conf = new XML(config.script);
   uri = conf.uri[0].toString();
}


var url = "http://localhost/test/login.php?username=admin&password=admin&return=alfresco_view_page.php";
model.url = url;

var testLogin = args.testLogin;
if (!testLogin)
{
   testLogin = "";
}

var testPass = args.testPass;
if (!testPass)
{
   testPass = "";
}

var testURL = args.testURL;
if (!testURL)
{
   testURL = "";
}

var connector = remote.connect("http");
var re = /^http:\/\//;
if (!re.test(uri))
{
   uri = "http://" + uri;
}

model.testLogin = testLogin;
model.testPass = testPass;
model.testURL = testURL;

test.js

/*
*** Alfresco test Dashlet
*
* @namespace Alfresco
* @class Alfresco.test
*
*/
(function()
{
   /**
    * YUI Library aliases
    */
   var Dom = YAHOO.util.Dom,
      Event = YAHOO.util.Event;

   /**
    * Alfresco Slingshot aliases
    */
   var $html = Alfresco.util.encodeHTML;
  
   Alfresco.test = function(htmlId)
   {
      this.name = "Alfresco.test";
      this.id = htmlId;

      this.configDialog = null;

      /* Register this component */
      Alfresco.util.ComponentManager.register(this);

      /* Load YUI Components */
      Alfresco.util.YUILoaderHelper.require([], this.onComponentsLoaded, this);

      return this;
   };

   Alfresco.test.prototype =
   {
      /**
       * Object container for initialization options
       *
       * @property options
       * @type object
       */
      options:
      {
         componentId: "",
         testLogin: "",
         testPass: "",
    testURL: ""
      },
     
      /**
       * Configuration dialog instance
       *
       * @property configDialog
       * @type object
       */
      configDialog: null,

      /**
       * Set multiple initialization options at once.
       *
       * @method setOptions
       * @param obj {object} Object literal specifying a set of options
       */
      setOptions: function test_setOptions(obj)
      {
         this.options = YAHOO.lang.merge(this.options, obj);
         return this;
      },

      /**
       * Fired by YUILoaderHelper when required component script files have
       * been loaded into the browser.
       *
       * @method onComponentsLoaded
       */
      onComponentsLoaded: function test_onComponentsLoaded()
      {
         Event.onContentReady(this.id, this.onReady, this, true);
      },

      /**
       * Fired by YUI when parent element is available for scripting.
       * Initialises components, including YUI widgets.
       *
       * @method onReady
       */
      onReady: function test_onReady()
      {
         var configtestLink = Dom.get(this.id + "-configtest-link");
         Event.addListener(configtestLink, "click", this.onConfigtestClick, this, true);
      },

      /**
       * Event listener for configuration link click.
       *
       * @method onConfigtestClick
       */
      onConfigtestClick: function test_onConfigtestClick(event)
      {
         var actionUrl = Alfresco.constants.URL_SERVICECONTEXT + "modules/test/config/" + encodeURIComponent(this.options.componentId);

         if (!this.configDialog)
         {
            this.configDialog = new Alfresco.module.SimpleDialog(this.id + "-configDialog").setOptions(
            {
               width: "50em",
               templateUrl: Alfresco.constants.URL_SERVICECONTEXT + "modules/test/config",
               actionUrl: actionUrl,
               onSuccess:
               {
                  fn: function test_onConfigtest_callback(response)
                  {
                     // MSIE6 doesn't redraw the IFRAME correctly, so tell it to refresh the page
                     if (YAHOO.env.ua.ie === 6)
                     {
                        window.location.reload(true);
                     }
                     else
                     {
                        var div = Dom.get(this.id + "-iframeWrapper");
                        div.innerHTML = response.serverResponse.responseText;
                        var iframe = Dom.getFirstChildBy(div, function(node)
                        {
                           return (node.tagName.toUpperCase() == "IFRAME");
                        });
                        if (iframe)
                        {
                           if (iframe.attributes["testLogin"])
                           {
            var testLogin = iframe.attributes["testLogin"].value;
                           }
                           if (iframe.attributes["testPass"])
                           {
                              var testPass = iframe.attributes["testPass"].value;
                           }
            if (iframe.attributes["testURL"])
                           {
                              var testPass = iframe.attributes["testURL"].value;
                           }
                        }
                     }
                  },
                  scope: this
               },
               doSetupFormsValidation:
               {
                  fn: function test_doSetupForm_callback(form)
                  {
                     /* Get the link title */
                     var elem = Dom.get(this.configDialog.id + "-testLogin");
                     if (elem)
                     {
                        elem.value = this.options.testLogin;
                     }

                     /* Get the link title */
                     var elem = Dom.get(this.configDialog.id + "-testPass");
                     if (elem)
                     {
                        elem.value = this.options.testPass;
                     }
          
            var elem = Dom.get(this.configDialog.id + "-testURL");
                     if (elem)
                     {
                        elem.value = this.options.testPass;
                     }
                  },
                  scope: this
               }
            });
         }
         else
         {
            this.configDialog.setOptions(
            {
               actionUrl: actionUrl
            });
         }
         this.configDialog.show();
         Event.stopEvent(event);
      }
   };
})();

and test-min.js
(function(){var f=YAHOO.util.Dom,b=YAHOO.util.Event;var a=Alfresco.util.encodeHTML;Alfresco.test=function(h){this.name="Alfresco.test";this.id=h;this.configDialog=null;Alfresco.util.ComponentManager.register(this);Alfresco.util.YUILoaderHelper.require([],this.onComponentsLoaded,this);return this};Alfresco.test.prototype={options:{componentId:"",testLogin:"",testPass:"",testURL:""},configDialog:null,setOptions:function d(h){this.options=YAHOO.lang.merge(this.options,h);return this},onComponentsLoaded:function e(){b.onContentReady(this.id,this.onReady,this,true)},onReady:function g(){var h=f.get(this.id+"-configtest-link");b.addListener(h,"click",this.onConfigtestClick,this,true)},onConfigtestClick:function c(j){var i=Alfresco.constants.URL_SERVICECONTEXT+"modules/test/config/"+encodeURIComponent(this.options.componentId);if(!this.configDialog){this.configDialog=new Alfresco.module.SimpleDialog(this.id+"-configDialog").setOptions({width:"50em",templateUrl:Alfresco.constants.URL_SERVICECONTEXT+"modules/test/config",actionUrl:i,onSuccess:{fn:function k(m){if(YAHOO.env.ua.ie===6){window.location.reload(true)}else{var q=f.get(this.id+"-iframeWrapper");q.innerHTML=m.serverResponse.responseText;var n=f.getFirstChildBy(q,function(r){return(r.tagName.toUpperCase()=="IFRAME")});if(n){if(n.attributes.testLogin){var p=n.attributes.testLogin.value;}if(n.attributes.testPass){var l=n.attributes.testPass.value;}}}},scope:this},doSetupFormsValidation:{fn:function h(m){var l=f.get(this.configDialog.id+"-testLogin");if(l){l.value=this.options.testLogin}l=f.get(this.configDialog.id+"-testPass");if(l){l.value=this.options.testPass}l=f.get(this.configDialog.id+"-testURL");if(l){l.value=this.options.testURL}},scope:this}})}else{this.configDialog.setOptions({actionUrl:i})}this.configDialog.show();b.stopEvent(j)}}})();

I'm sorry for pasting all the script, but I dont know where is the problem at all because i begin with alfresco. Thanks a lot.

kiri31
Champ in-the-making
Champ in-the-making
Hi,
I found my problem. In the test.get.html.ftl file, I called a wrong function, the real name was setOptions instead of setConfigOptions….

Now I can save my attributes of my form and call back them. I try to use these attributes on my dashlet when I validate the form, but an error appears (again) on Firebug :

m.getAttribute is not a function

the problem raise on http://localhost:8080/share/js/bubbling.v1.5.0-min.js. I don't modify this file at all, so I guess I have a problem in one of my js files. But I have no idea at all…. Thanks for your help.