You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2008/02/27 16:46:16 UTC

Re: [jira] Commented: (SLING-282) missing node functions in node wrapper

Hi,

Am Mittwoch, den 27.02.2008, 07:33 -0800 schrieb Carsten Ziegeler
(JIRA):
> I think we should remove "resource.node" completly, it causes too many problems.
> The proper way is to use "currentNode".

+1, and as this has been discussed before, I think we just should go
ahead, create an issue and do it ;-)

> 
> > missing node functions in node wrapper
> > --------------------------------------
> ...
> > (this is on Launchpad revision 629151 running on top of crx)
> > got an esp template that looks like:
> >     <h1><%= resource.node %>: <%= resource.node.getName() %></h1>
> >     
> >     <%
> >        var child = resource.node.getNode("2008-02")
> > 	 if (child.getProperty("sling:resourceType") == "emailListMonth") {
> > 		%>yay<%
> > 	}
> >     %>
> > .getName() and .getNode("...") works OK, but .getProperty throws an exception:
> > TypeError: getProperty is not a function
> > same for .getNodes()
> 

I am confused. We decided to provide JavaScript-like API, that is JCR
node properties are properties of the JavaScript Node object, thus the
sling:resourceType property would be accessed as
child["sling:resourceType"]. Therefore, I do not see a need for
Node.getProperty(String), but then we might just as well add them ...

But then, we should probably add each and every method defined in the
Node and Property (and Item) interfaces to the wrappers ....

Regards
Felix


Re: [jira] Commented: (SLING-282) missing node functions in node wrapper

Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger schrieb:
> Hi,
> 
> Am Mittwoch, den 27.02.2008, 07:33 -0800 schrieb Carsten Ziegeler
> (JIRA):
>> I think we should remove "resource.node" completly, it causes too many problems.
>> The proper way is to use "currentNode".
> 
> +1, and as this has been discussed before, I think we just should go
> ahead, create an issue and do it ;-)
> 
I created SLING-283 for this.

Carsten


-- 
Carsten Ziegeler
cziegeler@apache.org

Re: [jira] Commented: (SLING-282) missing node functions in node wrapper

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Wed, Feb 27, 2008 at 4:46 PM, Felix Meschberger <fm...@gmail.com> wrote:

> ... I am confused. We decided to provide JavaScript-like API, that is JCR
>  node properties are properties of the JavaScript Node object, thus the
>  sling:resourceType property would be accessed as
>  child["sling:resourceType"]. Therefore, I do not see a need for
>  Node.getProperty(String), but then we might just as well add them ...

I think so, for consistency's sake.

And IIUC Michael's missing getNodes(String namePattern) which is not
the same as enumerating a javascript array.

> ... But then, we should probably add each and every method defined in the
>  Node and Property (and Item) interfaces to the wrappers ....

Agreed, that's the goal of SLING-154. But last time I looked I had
some problems with collections not being properly converted to
wrappers, I'll try to find some time to have another look.

-Bertrand