cancel
Showing results for 
Search instead for 
Did you mean: 

[Solved][Share] Customise DocumentList

lamba
Champ on-the-rise
Champ on-the-rise
Hello,

I created a custom folder type and I added it to Alfresco 3.2r2 with succes.
For this custom folder type, I have a specific contents to show by using a WebScript.
For Alfresco Explorer, I was able to do it by replacing browse.jsp by custombrowse.jsp in web-client-config-custom.xml as follows:

   <config evaluator="node-type" condition="csf:customFolderType">
      <navigation>
         <override from-view-id="/jsp/browse/browse.jsp" to-view-id="/jsp/browse/custombrowse.jsp" />
      </navigation>
   </config>

NB: the file custombrowse.jsp contains the call of my WS.

But for Share I do not know how could I do it?
I think that it is necessary to modify WebScript doclist.get or the file documentlist.js, is this true?

help please.


Thank you in advance.
22 REPLIES 22

mikeh
Star Contributor
Star Contributor
Without seeing the rest of your customisation, I'm not sure how you're integrating with the existing code. Is it a problem that "me" isn't defined? How are you accessing any other data from the webscript?

Thanks,
Mike

lamba
Champ on-the-rise
Champ on-the-rise
Mike, this is the customisation that I did

I added the nodeType property to the doclist.get.json.ftl file as below:


"metadata":
   {
      "parent":
      {
         <#if doclist.parent??>
         "nodeRef": "${doclist.parent.nodeRef}",
         "nodeType": "${doclist.parent.type}",
       </#if>
      
         "permissions":
         {
            "userRole": "${user.role!""}",
            "userAccess":


I created the method below in the documentlist.js file


_setupCustomDataTable: function DL__setupCustomDataTable()
      {
         var me = this;
      var parentNodeRef = ????;
      var src = Alfresco.constants.PROXY_URI + "/custom/browsedoclist?nodeRef=" + parentNodeRef;
      var customIframe = '"<iframe src="' + src + '" frameborder="0" Marginwidth="0" Marginheight="0" width="100%" height="320" ></iframe>"';
         
       this.widgets.custompanel = new YAHOO.widget.Module(this.id + "-customdocuments", {visible:true } );
       this.widgets.custompanel.setBody(customIframe);
            
       this.widgets.custompanel.render();
     },

I call this method on the documentlist.js file as below:


       var nodeType = me.doclistMetadata.parent.nodeType;
       if(nodeType === "{extension.Custom}customFolder"){
         this._setupDataTable(columnDefinitions);
       }else{
         this._setupCustomDataTable();
       }

I tested the method with a static parentNodeRef and it worked fine. But I can't get the current parentNodeRef !

What I missed?


Thanks,

stevegreenbaum
Champ in-the-making
Champ in-the-making
Not sure I am following the full intent of your customization, but when looking at the documentation for share-config.custom.xml, the OOTB file shows that you can reference a custom Type including a custom folder type in the UI.  Have you looked at this approach?

mikeh
Star Contributor
Star Contributor
Why not just do: this._setupCustomDataTable(me.doclistMetadata.parent.nodeRef) then pick it up as a function argument?

Thanks,
Mike

lamba
Champ on-the-rise
Champ on-the-rise
Thank you Steve.
In fact, I tried the approach that you proposed but that did not work.

On the other hand, for your proposition Mike, I have the me.doclistMetadata variable which is null.
I think that it is necessary to take advantage of the WS doclist.get.json.ftl to initialize it but I have two problems at this level:

1. How to get back variables filterData and currentPath on the documentlist.js.
NB: this.currentPath and this.currentFilter.filterData  return null !

2. How to parse the file json result of the call of this WS (doclist.get.json.ftl).


thanks,

mikeh
Star Contributor
Star Contributor
Let's take a step back. This code you posted earlier:
       var nodeType = me.doclistMetadata.parent.nodeType;
       if(nodeType === "{extension.Custom}customFolder"){
         this._setupDataTable(columnDefinitions);
       }else{
         this._setupCustomDataTable();
       }

Exactly where has that been added?

I suspect, because of the _setupDataTable() call in there, you're trying to operate on the data before it's even been requested. As you should be able to see from the implementation, all _setupDataTable() does is to initialise the YUI components; it's not until the handleDataReturnPayload() callback is invoked that you can start acting on the data itself. Remember the page is all AJAX-based hence asynchronous.

Thanks,
Mike

lamba
Champ on-the-rise
Champ on-the-rise
Yes, you are right Mike, in my documentlist.js I replaced the _setupDataTable() by my code.
Mike, I am not very familiar with AJAX and especially its use in Share.

Now please, where can I put my code and get it working?  :cry:
I tried in and after the call of the handleDataReturnPayload() but that did not work because the calls oResponse.meta.metadata.parent; and oResponse.meta.parent; are not any more recognized, they return null  Smiley Sad

thanks

mikeh
Star Contributor
Star Contributor
There's an entire set of Ajax helper code in alfresco.js, e.g.
Alfresco.util.Ajax.jsonGet(
{
   url: [webscript URL],
   successCallback:
   {
      fn: this.onDataReturn,
      scope: this
   }
});

function onDataReturn(response)
{
   // Do something with response.json
}

There are lots of examples of this throughout the Share code. I would recommend walking through some of the existing code. You might also find our recently-released book (Wrox) useful.

Thanks,
Mike

P.S. Did you not get the e-mail I forwarded via Ash?

lamba
Champ on-the-rise
Champ on-the-rise
OK Mike, I will try this.

For the e-mail that you forwarded via Ash, I didn't get it.
In fact, I didn't know "Ash", what is it?

Thank you very much Mike.

mikeh
Star Contributor
Star Contributor
For the e-mail that you forwarded via Ash, I didn't get it.
In fact, I didn't know "Ash", what is it?
Never mind, I guess he replied to Andrew directly.

Thanks,
Mike