cancel
Showing results for 
Search instead for 
Did you mean: 

Truing to get content node path in contentRichList

tcordova
Champ in-the-making
Champ in-the-making
I was reading through the wiki on URL addressability and found the part about using the template servlet to display content with a template…

Problem here is that in order to do this I need to get the path of the content node so I can construct the proper URL.

I've tried changing browse.jsp as follows:


<%– Primary column for details view mode –%>
<a:column id="col10" primary="true" width="200" style="padding:2px;text-align:left" rendered="#{BrowseBean.browseViewMode == 'details'}">
<f:facet name="header">
<a:sortLink id="col10-sort" label="#{msg.title}" value="title" mode="case-insensitive" styleClass="header"/>
</f:facet>
<f:facet name="small-icon">
<a:actionLink id="col10-act1" value="#{r.title}" href="/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/inline_doc.ftl&contextPath=#{r.path}" target="new" image="#{r.fileType16}" showLink="false" styleClass="inlineAction" />
</f:facet>
<a:actionLink id="col10-act2" value="#{r.title}" href="#{r.url}" target="new" />
<r:lockIcon id="col10-lock" value="#{r.nodeRef}" align="absmiddle" />
</a:column>

but the reference to #{r.path} in the href of actionLink col10-act1 always returns an empty string.

Help!
7 REPLIES 7

rdanner
Champ in-the-making
Champ in-the-making
I was reading through the wiki on URL addressability and found the part about using the template servlet to display content with a template…

Problem here is that in order to do this I need to get the path of the content node so I can construct the proper URL.

I've tried changing browse.jsp as follows:


<%– Primary column for details view mode –%>
<a:column id="col10" primary="true" width="200" style="padding:2px;text-align:left" rendered="#{BrowseBean.browseViewMode == 'details'}">
<f:facet name="header">
<a:sortLink id="col10-sort" label="#{msg.title}" value="title" mode="case-insensitive" styleClass="header"/>
</f:facet>
<f:facet name="small-icon">
<a:actionLink id="col10-act1" value="#{r.title}" href="/alfresco/template?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/inline_doc.ftl&contextPath=#{r.path}" target="new" image="#{r.fileType16}" showLink="false" styleClass="inlineAction" />
</f:facet>
<a:actionLink id="col10-act2" value="#{r.title}" href="#{r.url}" target="new" />
<r:lockIcon id="col10-lock" value="#{r.nodeRef}" align="absmiddle" />
</a:column>

but the reference to #{r.path} in the href of actionLink col10-act1 always returns an empty string.

Help!

I could be all wet about this but I dont think you have access to r.path here.  For the sake of argument put r.nonFound  You wont get a bind error, just an empty string.  r.path would be nice to have here.  I don't spend much time focusing on the Alfresco UI so I may be wrong but I think the properties that you have access to are not the ones in the java class but the properties given by the M2 Model so for example Modifier etc.

I could be wrong about that.  If I am not, I am not sure how you get around the issue of properties from differnt names spaces that have the same name (which makes me think I am wrong)

TemplateContentServlet does not require both templatePath and contextPath.

Assuming I am right about r.path being unavailable and I wanted to keep my support contact with alfresco valid I would would do take the following steps.

o Places a jira tag requesting the path property be made available.  It would be nice to be able to get the current folder path from browseBean and be able to get the path information for each node.  You are right that a org.alfresco.web.bean.repository.Node has a path property

o extend  TemplateContentServlet to work with a node id's as well as named locations (this would be nice anyway with versioning etc) Compile it into its own jar and make a simple web xml edit to "plug it in"

That way you could map your own servlet to alfresco which is very easy to proove out in the case of other issues and the changes to browse.jsp become trivial.  The fact that you changed browse.jsp is going to going to make the code "unsupportable" but you could make a case for the fact that the change was very simple and I think that would fly.  You didnt in that case introduce any logic.

This is likely not the only thing you want to change so I dont know if this approach is right for you.  If you are going to make a ton of edits to underlying classes then you are going to have trouble getting support.  The best bet in that case is to donate all of your edits back to alfresco and try to get them supported.

I would like to see the ability to configure custom items on the context menu.  The thing you are doing here is a perfect example.  I imagine it would be possible in the future to use scripting to add something like this.

path is likely not in the M2 property because it is a computed value and is a projection of parent child associations.

Hope I am right about this… maybe someone at alfresco can verify or point out just how far off I am (If I am wrong … I am likely very wrong.)

I was going to try and verify this for myself but I have to run to a doctor appointment. Good luck.

kevinr
Star Contributor
Star Contributor
I could be all wet about this but I dont think you have access to r.path here.  For the sake of argument put r.nonFound  You wont get a bind error, just an empty string.  r.path would be nice to have here.  I don't spend much time focusing on the Alfresco UI so I may be wrong but I think the properties that you have access to are not the ones in the java class but the properties given by the M2 Model so for example Modifier etc.

I could be wrong about that.  If I am not, I am not sure how you get around the issue of properties from differnt names spaces that have the same name (which makes me think I am wrong)

Yes you are wrong. There is a lot more going on in the web-client than simple access to DD properties for a node. We have the concept of a client Node wrapper which as well as providing wrapped and cached access to properties, associations, aspects etc. also provides a mechanism called Property Resolver which allows the concept of pseudo calculated properties which can be used to generate richer UI pages. The .path property is available and provided by a Property Resolver which dynamically calls the nodeservice.getPath(noderef) method to return the Path object. It is the actual Path object instance though not a simple String object which is returned, so this is why the r.path does not appear to output anything useful for the JSF binding above.

There is an additional pseudo property called .displayPath which dynamically generates the cm:name based path to an object as a String - this may be what you require?

Thanks,

Kevin

rdanner
Champ in-the-making
Champ in-the-making
I could be all wet about this but I dont think you have access to r.path here.  For the sake of argument put r.nonFound  You wont get a bind error, just an empty string.  r.path would be nice to have here.  I don't spend much time focusing on the Alfresco UI so I may be wrong but I think the properties that you have access to are not the ones in the java class but the properties given by the M2 Model so for example Modifier etc.

I could be wrong about that.  If I am not, I am not sure how you get around the issue of properties from differnt names spaces that have the same name (which makes me think I am wrong)

Yes you are wrong. There is a lot more going on in the web-client than simple access to DD properties for a node. We have the concept of a client Node wrapper which as well as providing wrapped and cached access to properties, associations, aspects etc. also provides a mechanism called Property Resolver which allows the concept of pseudo calculated properties which can be used to generate richer UI pages. The .path property is available and provided by a Property Resolver which dynamically calls the nodeservice.getPath(noderef) method to return the Path object. It is the actual Path object instance though not a simple String object which is returned, so this is why the r.path does not appear to output anything useful for the JSF binding above.

There is an additional pseudo property called .displayPath which dynamically generates the cm:name based path to an object as a String - this may be what you require?

Thanks,

Kevin

Sweet.  I figured that something was not right about my analysis I don't spend much time looking at the web clients architecture.  I saw that browseBean.nodes returns a list of nodes and I put a break on Node.getPath which never got called so I knew there was indirection involved.  I tested some DD Properties that were not in the Node class and found they worked.  Right about the indirection, wrong about the composition extent of it. (I had a hunch I something was wrong..)


I just tried to use #{r.displayPath} on browse.jsp and got an empty string.

kevinr
Star Contributor
Star Contributor
I just tried to use #{r.displayPath} on browse.jsp and got an empty string.

That particular dynamic property resolver is only available when the browse.jsp is used in Search results mode. It wouldn't be hard to change this if it proves useful to have it available all the time - as there is no performance impact to dynamic property resolvers unless they are used on the page.

Thanks,

Kevin

tcordova
Champ in-the-making
Champ in-the-making
Sure… my whole point here is to use a template to display html content when a consumer clicks the content's main link.

Is there any other way to do this?

Thanks,

Tom

kevinr
Star Contributor
Star Contributor
Yes absolutely Smiley Happy

The template servlet accepts both 'path' URL arguments or the noderef of the template/context objects as URL elements:
http://wiki.alfresco.com/wiki/URL_Addressability#TemplateContentServlet

So for your example it would be something like this:

<a:actionLink id="col10-act1" value="#{r.title}" href="/alfresco/template/workspace/SpacesStore/#{r.id}?templatePath=/Company%20Home/Data%20Dictionary/Presentation%20Templates/inline_doc.ftl" target="new" image="#{r.fileType16}" showLink="false" styleClass="inlineAction" />

Hope this helps,

Kevin

tcordova
Champ in-the-making
Champ in-the-making
That worked perfectly…