cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing an individual piece of content

snelson
Champ in-the-making
Champ in-the-making
Hi,

I am producing some simple dynamic pages to test the WCM functionality of Alfresco and seem to have hit a problem that I want to solve in a clean way.

I have a jsp which uses some Java backing beans to iterate over a collection of XML documents stored in a particular directory in the repository. This produces a simple list of items. I want to provide the functionality so that a user can click an item and be forwarded to another jsp which contains further information about the item. This information is stored within the XML document that was iterated over.

I want to refer to this piece of content by an unique ID so that I can search for it in the repository and then display its full details. I realise I could store every item (with its full details) in session state and use that - however this will never scale.

What would be a better way to do this type of function?

Many thanks,

Stephen
4 REPLIES 4

arielb
Champ in-the-making
Champ in-the-making
it depends on what library you are using to access the wcm repository.  if you are using NodeService, then NodeRefs can be used as unique id's and can be used to lookup assets later.  if you are using AVMRemote, then you can use avm paths as keys.

in the next drop, we will be providing a library for accessing auxilliary xml assets from the jsp, xsl, and freemarker context (both static and dynamic contexts).  since this is not available yet, what i'd recommend doing is mimicing the behavior of the backing beans within the sample website provided.  take a look at org.alfresco.web.pr.Util.

by the way - really psyched that you're trying this stuff out.  it's really raw functionality in the preview and not so much documented, but it's something we've been putting a lot of thought into over the past two weeks to make it easier for the release.

snelson
Champ in-the-making
Champ in-the-making
Hi Ariel,

Thanks for the reply it is helping to make things clearer for me - especially with the latest code drop.

I have been accessing content using AVMRemote as the Util class does. What is the difference between AVM and NodeService? I understand from the wiki that NodeService is an in-process API. Is AVM some type of RMI interface?

I will try using the AVM path to key a content search and see how I get on with that.

Thanks for the encouragement!

Stephen

arielb
Champ in-the-making
Champ in-the-making
hadn't realized who you were Smiley Happy  kevin laughed at me for my previous enthusiastic post.  (i am still very excited that you guys are trying this stuff out).

yes - nodeservice is in process - though i believe there is some kind of webservices api.

avmremote is an rmi interface to the avm (the repository used by wcm).  we need to use that from tomcat-virtual since it's in a seperate process.

so, what you should be able to do is have an url that looks like

/render_xml_item?avmPath=test-website-admin-main:/appBase/avm_webapps/folder/foo.xml

you can then use that path with ServletContextFormDataFunctionsAdapter.parseXMLDocument(virtualPath).

however, parseXMLDocument expects a virtual path at the moment, meaning a path rooted at the webapp (it should probably also be able to handle avm paths - but i need to think about that).  so rather than pass in test-website-admin-main:/appBase/avm_webapps/folder/foo.xml
it expects either just foo.xml (assuming the jsp resides in the folder directory), or /folder/foo.xml if the jsp is elsewhere.

snelson
Champ in-the-making
Champ in-the-making
Hi Ariel,

Many thanks for explaining the different access methods. As we are deploying to the virtualization server we will keep using the AVMRemote along with the helper class.

Using the AVM path isn't really going to help as this will be exposed in the user facing JSP page. We have worked around this by using the XML filename and then using parseXMLDocument method to load that document, populate a backing bean and pass it back to the JSP in a custom tag.

We have some more requirements for accessing content but I'll contact you separately about this.

Many thanks.

Stephen