Jahia Dev Forum > Getting the currentNode...

0 (0 Good)
0 (0 Bad)

Getting the currentNode in JSP

by  rvt »  2011/07/12 02:09

Hello,

I created a variable in my cnd like this: - show_components (boolean) = true

How do I get this Boolean within my JSP?

I was hoping to do something like : Boolean foo=currentNode.getProperty("show_components").getBoolean(); but currentNode doesn't seems to exists and I have no idea where to find 'currentNode' for my Module. It's late, so I must have missed something simpel?

Ries

 

 

  • Getting the currentNode in JSP
    2011/07/12 02:09

    rvt <p> Hello,</p> <p> I created a variable in my cnd like this:&nbsp;- show_components (boolean) = true</p> <p> How do I get this Boolean within my JSP?</p> <p> I was hoping to do something like :&nbsp;Boolean foo=currentNode.getProperty(&quot;show_components&quot;).getBoolean(); but currentNode doesn&#39;t seems to exists and I have no idea where to find &#39;currentNode&#39; for my Module. It&#39;s late, so I must have missed something simpel?</p> <p> Ries</p> <p> &nbsp;</p> <p> &nbsp;</p>

  • Number of messages  185
    Registration date Jul 12, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: Getting the currentNode in JSP

    by  rvt »  2011/07/12 15:31

    How do I get this Boolean within my JSP?

     

    Simply define the property like this WITH the autocreated:

    - show_components (boolean) = true autocreated

    Then get the currentNode in the scriplet like this:

    JCRNodeWrapper currentNode=(JCRNodeWrapper)request.getAttribute("currentNode");

    So you can get the boolean like this:

    Boolean foo=currentNode.hasProperty("show_components") && currentNode.getProperty("show_components").getBoolean();

    That's al there is to it!

     

  • Re: Getting the currentNode in JSP
    2011/07/12 15:31

    rvt <blockquote> <p> How do I get this Boolean within my JSP?</p> </blockquote> <p> &nbsp;</p> <p> Simply define the property like this <em>WITH</em> the autocreated:</p> <p> - show_components (boolean) = true <b>autocreated</b></p> <p> Then get the currentNode in the scriplet like this:</p> <p> JCRNodeWrapper currentNode=(JCRNodeWrapper)request.getAttribute(&quot;currentNode&quot;);</p> <p> So you can get the boolean like this:</p> <p> Boolean foo=currentNode.hasProperty(&quot;show_components&quot;) &amp;&amp; currentNode.getProperty(&quot;show_components&quot;).getBoolean();</p> <p> That&#39;s al there is to it!</p> <p> &nbsp;</p>

  • Number of messages  185
    Registration date Jul 12, 2011
    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