cancel
Showing results for 
Search instead for 
Did you mean: 

[solved] How to change columns content in browse view ?

ethan
Champ in-the-making
Champ in-the-making
Hi Smiley Happy

I would like to replace the content of the Created column and Last Modified column in all the view modes of Alfresco Explorer. My custom model have custom properties which contain the real created date and last modified date of the documents. I looked at  /jsp/browse/browse.jsp and found out  #{r.created} and #{r.modified} are used to display the default cm:content properties.

Is there a way to replace them by my custom model properties? I tried #{DialogManager.bean.document.myCustomCreatedDate} but it throws a nullPointerException.

Thank you Smiley Happy
6 REPLIES 6

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
well ethan, you must override Browsebean to do this.
   <managed-bean>
      <description>The bean that holds folder browse state.</description>
      <managed-bean-name>BrowseBean</managed-bean-name>
      <managed-bean-class>org.alfresco.docassistent.CustomBrowseBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
         <property-name>navigator</property-name>
         <value>#{NavigationBean}</value>
      </managed-property>
      <managed-property>
         <property-name>nodeService</property-name>
         <value>#{NodeService}</value>
      </managed-property>
      <managed-property>
         <property-name>searchService</property-name>
         <value>#{SearchService}</value>
      </managed-property>
      <managed-property>
         <property-name>lockService</property-name>
         <value>#{LockService}</value>
      </managed-property>
      <managed-property>
         <property-name>dictionaryService</property-name>
         <value>#{DictionaryService}</value>
      </managed-property>
      <managed-property>
         <property-name>fileFolderService</property-name>
         <value>#{FileFolderService}</value>
      </managed-property>
      <managed-property>
         <property-name>userPreferencesBean</property-name>
         <value>#{UserPreferencesBean}</value>
      </managed-property>
      <managed-property>
         <property-name>multilingualContentService</property-name>
         <value>#{MultilingualContentService}</value>
      </managed-property>
   </managed-bean>
put this inside faces-config-custom.xml and replace my class with yours. customBrowseBean should extend BrowseBean.

most easyest way is to override Browsebean and method   public List<Node> getContent() to add  prop resolover to each node like node.addPropertyResolver("url", this.resolverLinkUrl); (you can see how is tone in method queryBrowseNodes).

your prop resolover would look like this.
 public NodePropertyResolver resolverFileType16 = new NodePropertyResolver() {
      private static final long serialVersionUID = -2690520488415178029L;

      public Object get(Node node) {
         return nodeservice.getProperty(NodeRef nodeRef,
                                                             QName qname);
      }
   };



http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-client/source/jav...

time to do this is max 10 minutes.

gyro_gearless
Champ in-the-making
Champ in-the-making
Hi Smiley Happy

I would like to replace the content of the Created column and Last Modified column in all the view modes of Alfresco Explorer. My custom model have custom properties which contain the real created date and last modified date of the documents. I looked at  /jsp/browse/browse.jsp and found out  #{r.created} and #{r.modified} are used to display the default cm:content properties.

Is there a way to replace them by my custom model properties? I tried #{DialogManager.bean.document.myCustomCreatedDate} but it throws a nullPointerException.

Thank you Smiley Happy

There is no need to override BrowseBean to add or modify columns, it suffices to override browse.jsp!

First, you have to stay with #{r….} as it is used in browse.jsp - remember that the rendering of rows happens inside a <a:richlist> tag, where "r" is the loop variable:

<%– Content list –%>
<a:richList id="contentRichList" binding="#{BrowseBean.contentRichList}" viewMode="#{BrowseBean.browseViewMode}" pageSize="#{BrowseBean.pageSizeContent}"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{BrowseBean.content}" var="r">
(Around line 406 in browse.jsp)

The other point is that you have to use a special syntax to access your custom properties, see this example:

<%– AW 2010-09-03: Add column for property 'acme:document_id –%>
<a:column id="col13a" style="text-align:left">
  <f:facet name="header">
    <a:sortLink id="col13a-sort" label="DBS Document ID" value="description" styleClass="header"/>
  </f:facet>
  <h:outputText id="col13a-txt" value="#{r['acme:document_id']}" />
</a:column>

So you may add new columns or modify existing ones. This works at least for simple String properties; if rendering requires complex formatting, you might want to override BrowseBean as suggested by Savic, though….

Cheers
Gyro

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
sorry my thought was some calculation is need because of {DialogManager.bean.document.myCustomCreatedDate}. So I give this complex tutorial on this.

ethan
Champ in-the-making
Champ in-the-making
Thanks to both of you for your help Smiley Happy I'll try this.

I also would like to change the column header but I don't know which file I have to edit to change the value of the #{msg.created} property ? Does it have something to with the webclient.properties or webclient_en_US.properties files ?

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
my advice is to add new prop file and add your custom strings ( also you can change both files and it will work too)

<bean id="extension.workflowBootstrap"
parent="workflowDeployer">
<property name="labels">
<list>
<value>alfresco.extension.propfile</value><!–propfile.properties–>
</list>
</property>
</bean>
name this file extension-context.xml and change valuepart to mach your custom properties file

ethan
Champ in-the-making
Champ in-the-making
Thank you for your help. I used your snippet plus the alfresco wiki page about I18N Strings and it worked ! I needed to add the following code in the browse.jsp file :

<f:loadBundle basename="alfresco.extension.customMsg" var="custom"/>

Smiley Happy