cancel
Showing results for 
Search instead for 
Did you mean: 

display Properties

danisowa
Champ in-the-making
Champ in-the-making
Hello,

i have Programmed a Search by Categories.
now i would display the result in the following way:

NAME  TITLE DESCRIPTION

how do i get these 3 properties?

It is very important for me.

Thanks a lot

regards

danisowa
7 REPLIES 7

nimind
Champ in-the-making
Champ in-the-making

reference = new Reference(store, row.getNode().getId(), null);
                   predicate = new Predicate(new Reference[]{reference}, null, null);
                   nodes = repositoryService.get(predicate);
                   
                   for (i=0;i < nodes[0].getProperties().length; i++)
                   {
                      //Nombre
                      if (nodes[0].getProperties(i).getName().equals("{http://www.alfresco.org/model/content/1.0}name"))
                      {
                         sName = nodes[0].getProperties(i).getValue();
                      }

You can access this way to all properties

santigt
Champ in-the-making
Champ in-the-making
When i try to display the properties (please see code)


var myfile = companyhome.childByNamePath(name);
props = myfile.getProperties();

for (i=0;i<props.length;i++){
   txt += "<b>" + props[i].getName() + "</b>:" + props[i].getValue() + "<br>";
}


the variable "props" has "null" value, not an object, and I don't know why. So I look for the properties when I create the Node "name" (createNode function).  What I see in the Java code (please see /HEAD/root/projects/repository/source/java/org/alfresco/repo/jscript/ScriptNode.java) is that properties attribute has "null" value if we don't put anything in properties parameter function. The problem is that I don't know what properties has the Node created.

Thanks a lot!

Regards,



Santigt




reference = new Reference(store, row.getNode().getId(), null);
                   predicate = new Predicate(new Reference[]{reference}, null, null);
                   nodes = repositoryService.get(predicate);
                   
                   for (i=0;i < nodes[0].getProperties().length; i++)
                   {
                      //Nombre
                      if (nodes[0].getProperties(i).getName().equals("{http://www.alfresco.org/model/content/1.0}name"))
                      {
                         sName = nodes[0].getProperties(i).getValue();
                      }

You can access this way to all properties

kevinr
Star Contributor
Star Contributor
When i try to display the properties (please see code)


var myfile = companyhome.childByNamePath(name);
props = myfile.getProperties();

for (i=0;i<props.length;i++){
   txt += "<b>" + props[i].getName() + "</b>:" + props[i].getValue() + "<br>";
}


the variable "props" has "null" value, not an object, and I don't know why. So I look for the properties when I create the Node "name" (createNode function).  What I see in the Java code (please see /HEAD/root/projects/repository/source/java/org/alfresco/repo/jscript/ScriptNode.java) is that properties attribute has "null" value if we don't put anything in properties parameter function.

The code the other user posted was for using WebServices - the code you are trying to use is the JavaScript API - they are quite different and methods/properties are accessed using a different syntax.

I suggest you take a look at the examples in the JavaScript API docs:
http://wiki.alfresco.com/wiki/JavaScript_API
then you'll see that the code you are using will not work at all.

Thanks,

Kevin

santigt
Champ in-the-making
Champ in-the-making
Ok, In my case I want to do a different wizard separately to Alfresco,  using JSP or JavaScript. This wizard must communicate with Alfresco, using JavaScript API or other Alfresco API.

In this moment I use Alfresco 2.1 downloaded by SVN. I can use Web Scripts (the first idea I propose) and the API last versions. So, please, recommend me the best solution,

Thanks again!

Best regards,

Santigt



When i try to display the properties (please see code)


var myfile = companyhome.childByNamePath(name);
props = myfile.getProperties();

for (i=0;i<props.length;i++){
   txt += "<b>" + props[i].getName() + "</b>:" + props[i].getValue() + "<br>";
}


the variable "props" has "null" value, not an object, and I don't know why. So I look for the properties when I create the Node "name" (createNode function).  What I see in the Java code (please see /HEAD/root/projects/repository/source/java/org/alfresco/repo/jscript/ScriptNode.java) is that properties attribute has "null" value if we don't put anything in properties parameter function.

The code the other user posted was for using WebServices - the code you are trying to use is the JavaScript API - they are quite different and methods/properties are accessed using a different syntax.

I suggest you take a look at the examples in the JavaScript API docs:
http://wiki.alfresco.com/wiki/JavaScript_API
then you'll see that the code you are using will not work at all.

Thanks,

Kevin

kevinr
Star Contributor
Star Contributor
Yes using WebScripts and the latest JavaScript/FreeMarker APIs would be a good approach.

Take a look at the WebScripts docs on the wiki - they have been updated again with fresh information in the last few days.

Generally you will want to use FreeMarker as your presentation layer, so rather than use JavaScript to build the output (like you have in your example code) you might want to take a look at a FreeMarker example on the wiki that shows all properties for a node:
http://wiki.alfresco.com/wiki/Template_Guide#Examples

Hope this helps,

Kevin

santigt
Champ in-the-making
Champ in-the-making
And JCR API?? I need a complete and easy Alfresco API, in Java or JavaScript.

I don't know where must i put my Java Files if I want to use JCR API. Can be possible to put my Java Files in a different WAR file that the Alfresco WAR file?

The idea is to create a new Portlet Project that communicates with Alfresco, using JCR API, but a separated project, different that Alfresco.

For example, this header:


package wizard.actions;

import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

I think this code can't be compiled because I haven't got these Classes.I Have also another problem if I try to access to Alfresco, because I don't put anything about Alfresco Java files.

Please help me on this! What is the best option, and why? Thanks so much!

Regards,



Santigt

doblek
Champ in-the-making
Champ in-the-making
Hi,

I think those classes you mention (javax.jcr.*) don't exist.

You can find the JCR classes in the repository.jar file (which is distributed with alfresco) under the following packages:
org.alfresco.jcr.api  
org.alfresco.jcr.dictionary  
org.alfresco.jcr.exporter  
org.alfresco.jcr.importer  
org.alfresco.jcr.item  
org.alfresco.jcr.item.property  
org.alfresco.jcr.query  
org.alfresco.jcr.repository  
org.alfresco.jcr.session  
org.alfresco.jcr.tck  
org.alfresco.jcr.test  
org.alfresco.jcr.util  
org.alfresco.jcr.version

See this link.

Anyway, though JCR was my first choice to create portlets that interact with Alfresco, I was unable to get them to work so I finally used webservices instead.

Maybe you can find a more professional comment on this from an Alfresco developer, but hope that helps.

Regards,
Enrique
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.