You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Al Sutton <al...@alsutton.com> on 2008/01/30 20:26:42 UTC

[S2.1] One Step On.... the Dojo plugin tree problem

OK, it would appear that if any node in the tree has a null for the value of 
the child property the following error is reported by FreeMarker;

Expression stack.findValue(parameters.childCollectionProperty.toString()) is 
undefined on line 24, column 8 in template/ajax/treenode-include.ftl.
The problematic instruction:
----------
==> list stack.findValue(parameters.childCollectionProperty.toString()) as 
child [on line 24, column 1 in template/ajax/treenode-include.ftl]
 in include "/${parameters.templateDir}/ajax/treenode-include.ftl" [on line 
26, column 5 in template/ajax/treenode-include.ftl]
 in include "/${parameters.templateDir}/ajax/treenode-include.ftl" [on line 
26, column 5 in template/ajax/treenode-include.ftl]
 in include "/${parameters.templateDir}/ajax/treenode-include.ftl" [on line 
124, column 5 in template/ajax/tree.ftl]
----------

which in turn was causing the problem with Sitemesh I was seeing.

Now here's the question; Are we going to allow users to represent leaf nodes 
in the tree by having a null for the child property, or are we going to say 
that all nodes must return a valid instance of a java.util.Collection when 
the child property is fetched?

Al.


----- Original Message ----- 
From: "Al Sutton" <al...@alsutton.com>
To: "Struts Developers List" <de...@struts.apache.org>
Sent: Wednesday, January 30, 2008 7:07 PM
Subject: Re: [S2.1] Dojo plugin tree problem


> Bingo :).
>
> Now I've got to work out why I'm getting the following error in sitemesh;
>
> java.lang.ArrayIndexOutOfBoundsException: -1
> com.opensymphony.module.sitemesh.html.HTMLProcessor$1.currentBuffer(HTMLProcessor.java:74) 
> com.opensymphony.module.sitemesh.html.State.handleText(State.java:64) 
> com.opensymphony.module.sitemesh.html.HTMLProcessor$2.text(HTMLProcessor.java:103) 
> com.opensymphony.module.sitemesh.html.tokenizer.Parser.parsedText(Parser.java:295) 
> com.opensymphony.module.sitemesh.html.tokenizer.Parser.parseTag(Parser.java:160) 
> com.opensymphony.module.sitemesh.html.tokenizer.Parser.start(Parser.java:112) 
> com.opensymphony.module.sitemesh.html.tokenizer.TagTokenizer.start(TagTokenizer.java:33) 
> com.opensymphony.module.sitemesh.html.HTMLProcessor.process(HTMLProcessor.java:90) 
> com.opensymphony.module.sitemesh.parser.HTMLPageParser.parse(HTMLPageParser.java:52) 
> com.opensymphony.module.sitemesh.filter.Buffer.parse(Buffer.java:49) 
> com.opensymphony.module.sitemesh.filter.PageResponseWrapper.getPage(PageResponseWrapper.java:165) 
> com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:12
> 4) 
> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55) 
> org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:96)----- 
> Original Message -----From: "Musachy Barroso" <mu...@gmail.com>To: 
> "Struts Developers List" <de...@struts.apache.org>Sent: Wednesday, January 
> 30, 2008 6:48 PMSubject: Re: [S2.1] Dojo plugin tree problem> you are 
> missing sd:head on the page.>> musachy>> On Jan 30, 2008 12:50 PM, Al 
> Sutton <al...@alsutton.com> wrote:>> I think I've found a problem in 
> the dojo plugin but I'd like someone to>> double check I'm not doing 
> anything whacky before raising a JIRA ticket.>>>> I've got a webapp with 
> the latest snapshots of core and dojo plugin. Ialso>> have a jsp with;>>>> 
> <%@taglib prefix="sd" uri="/struts-dojo-tags"%>>> ....>>>>   <sd:tree 
> id="objectTree">>      rootNode="%{#session.objectTree}">> 
> nodeIdProperty="id">>      nodeTitleProperty="name">> 
> childCollectionProperty="children"/>>>>> When I try to load the page I get 
> an NPE on line 257 of Tree.java whichis;>>>>         boolean generateId 
> =>> !(Boolean)stack.getContext().get(Head.PARSE_CONTENT);>>>>>> from what 
> I can tell stack.getContext().get(Head.PARSE_CONTENT) returns a>> null 
> instead of a default value, and thus the !..... with autoboxing ofthe>> 
> boolean causes the NPE.>>>> Is there suppose to be a default set or have I 
> missed a step which wouldset>> this 
> up?>>>>>> --------------------------------------------------------------------->> 
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org>> For additional 
> commands, e-mail: dev-help@struts.apache.org>>>>>>>> --> "Hey you! Would 
> you help me to carry the stone?" Pink 
> Floyd>> ---------------------------------------------------------------------> 
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org> For additional 
> commands, e-mail: dev-help@struts.apache.org>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] [S2.1] One Step On.... the Dojo plugin tree problem

Posted by Al Sutton <al...@alsutton.com>.
Dale,

Thanks for the tips. I've updated the ftl file with a default that works 
with a null returned by the child property, so I'll be putting a patch into 
JIRA.

Al.

----- Original Message ----- 
From: "Dale Newfield" <Da...@Newfield.org>
To: "Struts Developers List" <de...@struts.apache.org>
Sent: Wednesday, January 30, 2008 8:07 PM
Subject: Re: [struts-dev] [S2.1] One Step On.... the Dojo plugin tree 
problem


> Dale Newfield wrote:
>> A previous example has a three character solution: 
>> https://issues.apache.org/struts/browse/WW-2383 , for this one it appears 
>> that a single "!" may be sufficient.
>>
>> Excerpted from 
>> <http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_default>: 
>> If the default value is omitted, then it will be empty string and empty 
>> sequence and empty hash at the same time.
>
> Now that I read it again, the single character addition would probably 
> have been sufficient for the previous bug, too.  If we want to be 
> explicit, I think "![]" will use an empty sequence as the default value 
> here, but it seems unnecessary (and from the docs I'm still unclear 
> whether that syntax is valid).
>
> -Dale
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] [S2.1] One Step On.... the Dojo plugin tree problem

Posted by Dale Newfield <Da...@Newfield.org>.
Dale Newfield wrote:
> A previous example has a three 
> character solution:  https://issues.apache.org/struts/browse/WW-2383 , 
> for this one it appears that a single "!" may be sufficient.
> 
> Excerpted from 
> <http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_default>: 
>  If the default value is omitted, then it will be empty string and empty 
> sequence and empty hash at the same time.

Now that I read it again, the single character addition would probably 
have been sufficient for the previous bug, too.  If we want to be 
explicit, I think "![]" will use an empty sequence as the default value 
here, but it seems unnecessary (and from the docs I'm still unclear 
whether that syntax is valid).

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [struts-dev] [S2.1] One Step On.... the Dojo plugin tree problem

Posted by Dale Newfield <Da...@Newfield.org>.
Al Sutton wrote:
> OK, it would appear that if any node in the tree has a null for the 
> value of the child property the following error is reported by FreeMarker;

This is really another example of a broader problem with many of the 
.ftl templates in the struts2 codebase.  A previous example has a three 
character solution:  https://issues.apache.org/struts/browse/WW-2383 , 
for this one it appears that a single "!" may be sufficient.

Excerpted from 
<http://freemarker.org/docs/dgui_template_exp.html#dgui_template_exp_missing_default>: 
  If the default value is omitted, then it will be empty string and 
empty sequence and empty hash at the same time.

> Expression 
> stack.findValue(parameters.childCollectionProperty.toString()) is 
> undefined on line 24, column 8 in template/ajax/treenode-include.ftl.
> The problematic instruction:

I'm not sure how to describe this well, but I'd suggest a broad jira 
ticket to look through and provide defaults in the .ftl templates for 
pretty much anywhere there's a "stack.findValue()" call...

> Now here's the question; Are we going to allow users to represent leaf 
> nodes in the tree by having a null for the child property, or are we 
> going to say that all nodes must return a valid instance of a 
> java.util.Collection when the child property is fetched?

This basically means all those db objects with collections as attributes 
need to replace the simple "return FOO" in their getters with "if 
(FOO==null) return new mumble(); else return FOO".  While this isn't a 
bad idea, I would hate to have the presentation layer break if it's not 
done..

-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org