Jahia Dev Forum > how to get Components...

0 (0 Good)
0 (0 Bad)

how to get Components ID ?

by  bhadreshshiroya »  2014/01/27 11:44

I have to created components and  components using  the AbstractFilter  after add to the Template page ,

First Time add components  in Template page

After Second Time add components  in same page below the code 

public String prepare(RenderContext renderContext, Resource resource, RenderChain chain) throws Exception {
 
      String category = resource.getNode().getPropertyAsString("category");
       String tags = resource.getNode().getPropertyAsString("tags");
       String sortOrder = resource.getNode().getPropertyAsString("sortOrder");
       String maxResults = resource.getNode().getPropertyAsString("maxResults");
       String title = resource.getNode().getPropertyAsString("jcr:title");
  
 

 how to get  unique id each components  \

And Attribute Name list in jahia any documents?

 

 

 

  (bhadreshshiroya)

Number of messages  18
Registration date
0 (0 Good)
0 (0 Bad)

Re : how to get Components ID ?

by  fabu »  2014/01/27 14:02

Hi Bhadresh, what you are looking for, I guess, is getPropertiesAsString() in JCRNodeWrapper.java and specially for unique id:

String uuid = resource.getNode().getPropertyAsString("jcr:uuid");

Best regards,

  (fabu)

Number of messages  28
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re : how to get Components ID ?

by  bhadreshshiroya »  2014/01/29 08:42

Hi Bhadresh, what you are looking for, I guess, is getPropertiesAsString() in JCRNodeWrapper.java and specially for unique id:

String uuid = resource.getNode().getPropertyAsString("jcr:uuid");

Best regards,

but uuid very long 

can i get small like componants id?

must be unique 

  (bhadreshshiroya)

Number of messages  18
Registration date
1 (1 Good)
0 (0 Bad)

Re: Re: Re : how to get Components ID ?

by  shuber »  2014/01/29 08:54

Actually the proper way to retrieve a node's identifier is this : 

String uuid = resource.getNode().getIdentifier()

You can find more information about this identifier here : 

http://wiki.apache.org/jackrabbit/mix%3Areferenceable

The UUID is a generated ID that is guaranteed to be unique in time and place, meaning that even on a cluster it will be unique.

If you need a shorter unique identifier you will have to generate it yourself and store it in your own custom property, but I wonder why you think UUIDs are too long ? Are you intending to use them in URLs ? Even so they are that long but not necessarily SEO friendly. So people prefer to use the path in URLs but that might not be shorter.

Best regards,

  Serge Huber.

Serge Huber (shuber)

Number of messages  271
Registration date
Contact
Share
Feedback

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page