AnsweredAssumed Answered

Alfresco Share Advanced Search Customization

Question asked by queiros on May 29, 2012
Latest reply on Jun 5, 2012 by queiros

I have followed this example exactly as mentioned: , to configure my Alfresco Advanced Search.
I try to customize the share advanced search by introducing my type xxx:entidade using web scripting that implements YAHOO.widget.AutoComplete
(autocomplete.ftl, autocomplete.get.desc.xml, autocomplete.get.html.ftl, autocomplete.get.js e autocomplete.get.config.xml) web scripting not working.

I have my share-config-custom.xml :

    <!– xxx:comercial type (new nodes) –>
    <config evaluator="model-type" condition="xxx:comercial">
               <show id="cm:name" />
               <show id="cm:content" force="true" />
               <field id="cm:content">
                     <control-param name="editorAppearance">explorer</control-param>
         <form id="search">
               <show id="cm:name" />
               <show id="cm:title" force="true" />
               <show id="cm:description" force="true" />
            <show id="cm:taggable" force="true" />         
               <show id="xxx:entidadeNome" force="true"/>
             <field id="xxx:entidadeNome">
              <control template="/xxx/controls/autocomplete.ftl">
                 <control-param name="ds">/share/service/ds/autocomplete/google</control-param>

              <field id="cm:taggable">
                            <control-param name="compactMode">true</control-param>
                            <control-param name="params">aspect=cm:taggable</control-param>
                            <control-param name="createNewItemIcon">tag</control-param>

   I have web scripts autocomplete.ftl :
        <#if field.control.params.ds?exists><#assign ds=field.control.params.ds><#else><#assign ds=&#39;&#39;></#if>
      <#if field.control.params.width?exists><#assign width=field.control.params.width><#else><#assign width=&#39;35em&#39;></#if>

      <style type="text/css">
      #${fieldHtmlId}-AutoComplete {
         width:${width}; /* set width here or else widget will expand to fit its container */

      <div class="form-field">
         <#if form.mode == "view">
           <div class="viewmode-field">
             <#if field.mandatory && !(field.value?is_number) && field.value == "">
               <span class="incomplete-warning"><img src="${url.context}/components/form/images/warning-16.png" title="${msg("form.field.incomplete")}" /><span>
             <span class="viewmode-label">${field.label?html}:</span>
             <span class="viewmode-value">${field.value?html}</span>
           <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>
           <div id="${fieldHtmlId}-AutoComplete">
              <input id="${fieldHtmlId}" type="text" name="${}"
                <#if field.control.params.styleClass?exists>class="${field.control.params.styleClass}"</#if>
                <#if field.value?is_number>value="${field.value?c}"<#else>value="${field.value}"</#if>
                <#if field.description?exists>title="${field.description}"</#if>
                <#if field.control.params.maxLength?exists>maxlength="${field.control.params.maxLength}"</#if>
                <#if field.control.params.size?exists>size="${field.control.params.size}"</#if>
                <#if field.disabled>disabled="true"</#if> />
              <div id="${fieldHtmlId}-Container"></div>      

      <script type="text/javascript">//<![CDATA[
            // Use an XHRDataSource
            var oDS = new YAHOO.util.XHRDataSource("${ds}");
            // Set the responseType
            oDS.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
            // Define the schema of the JSON results
            oDS.responseSchema = {
               resultsList : "result",
               fields : ["value"]

            // Instantiate the AutoComplete
            var oAC = new YAHOO.widget.AutoComplete("${fieldHtmlId}", "${fieldHtmlId}-Container", oDS);
            // Throttle requests sent
            oAC.queryDelay = .5;
            // The webservice needs additional parameters
            oAC.generateRequest = function(sQuery) {
               <#if ds?contains("?")>
                  return "&q=" + sQuery ;
                  return "?q=" + sQuery ;

            return {
               oDS: oDS,
               oAC: oAC

   I have web scripts autocomplete.get.desc.xml :

         <shortname>Data web script for auto complete widget</shortname>
         <description>Data web script for auto complete widget</description>
         <url template="/ds/autocomplete/{resource}"/>
         <format default="html">extension</format>

   I have web scripts autocomplete.get.html.ftl :

   I have web scripts autocomplete.get.js :
      var results = {};
      var result= new Array();
      var resource = "" + url.extension;
      var query  = args.q;
      var status = "succeed";

      switch (resource)
         case "google":

           var googleServiceUrl = "'+query;
           var connector = remote.connect("http");
           var str = new String(;

           //Javascript E4X module has problems with XML header
           if ( str.substr(0,5).indexOf("?xml") != -1 )
             positionRootElement = str.indexOf("<", 10);//get first real tag
             str = str.substr( positionRootElement, str.length - 1 );

           var suggestions = new XML(str);
           var suggestion;
           for each (suggestion in suggestions.CompleteSuggestion)
             var resultItem = {};
     = suggestion.suggestion.@data.toString();
             resultItem.value = suggestion.suggestion.@data.toString();
         case "yahoo":
           // get appid from configuration
           var s = new XML(config.script);
           var appid =;

           var yahooServiceUrl = "'+query+'&appid='+appid+'&output=json";
           var connector = remote.connect("http");
           var jsonStr = eval("(" + + ")");

           var suggestion;
           for each (suggestion in jsonStr.ResultSet.Result)
             var resultItem = {};
     = suggestion;
             resultItem.value = suggestion;
         default :

      results.result = result;
      model.result = jsonUtils.toJSONString(results);

    I have web scripts autocomplete.get.config.xml :

    Web scripting autocomplete no working.
   Could you have any ideas about this issue? How we can configure the advanced search customized with my web scripting?