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?

 

 

 

  • how to get Components ID ?
    2014/01/27 11:47

    bhadreshshiroya <p> I have to created components and &nbsp;components using &nbsp;the&nbsp;AbstractFilter &nbsp;after add to the Template page ,</p> <p> First Time add&nbsp;components &nbsp;in&nbsp;Template page</p> <p> After Second&nbsp;Time add&nbsp;components &nbsp;in&nbsp;same page below the code&nbsp;</p> <blockquote> <div> public String prepare(RenderContext renderContext, Resource resource, RenderChain chain) throws Exception {</div> <div> &nbsp;<span class="Apple-tab-span" style="white-space:pre"> </span></div> <div> &nbsp; &nbsp; &nbsp; String category = resource.getNode().getPropertyAsString(&quot;category&quot;);</div> <div> &nbsp; &nbsp; &nbsp; &nbsp;String tags = resource.getNode().getPropertyAsString(&quot;tags&quot;);</div> <div> &nbsp; &nbsp; &nbsp; &nbsp;String sortOrder = resource.getNode().getPropertyAsString(&quot;sortOrder&quot;);</div> <div> &nbsp; &nbsp; &nbsp; &nbsp;String maxResults = resource.getNode().getPropertyAsString(&quot;maxResults&quot;);</div> <div> &nbsp; &nbsp; &nbsp; &nbsp;String title = resource.getNode().getPropertyAsString(&quot;jcr:title&quot;);</div> <div> &nbsp;&nbsp;</div> </blockquote> <div> &nbsp;</div> <p> &nbsp;how to get &nbsp;unique id each components &nbsp;\</p> <p> And Attribute Name list in jahia any documents?</p> <p> &nbsp;</p> <p> &nbsp;</p> <p> &nbsp;</p>

  • Number of messages  18
    Registration date Jan 27, 2014
    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,

  • Re : how to get Components ID ?
    2014/01/27 14:02

    fabu <p> Hi Bhadresh, what you are looking for, I guess, is getPropertiesAsString() in JCRNodeWrapper.java and specially for unique id:</p> <blockquote> <p> <span style="background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; font-style: italic; line-height: 20px;">String uuid = resource.getNode().getPropertyAsString(&quot;jcr:uuid&quot;);</span></p> </blockquote> <p> Best regards,</p>

  • Number of messages  28
    Registration date Jan 27, 2014
    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 

  • Re: Re : how to get Components ID ?
    2014/01/29 08:42

    bhadreshshiroya <blockquote> <p> Hi Bhadresh, what you are looking for, I guess, is getPropertiesAsString() in JCRNodeWrapper.java and specially for unique id:</p> <blockquote> <p> <span style="background-color: rgb(238, 238, 238); color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; font-style: italic; line-height: 20px;">String uuid = resource.getNode().getPropertyAsString(&quot;jcr:uuid&quot;);</span></p> </blockquote> <p> Best regards,</p> </blockquote> <p> but uuid very long&nbsp;</p> <p> can i get small like componants id?</p> <p> must be unique&nbsp;</p>

  • Number of messages  18
    Registration date Jan 29, 2014
    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