[xwiki-users] Velocity + Tables
Hi xwiki-users, I've been playing with the new XWiki Syntax 2.0, but there are still some things possible with the old 1.0 syntax which are impossible in the new 2.0 syntax. One thing that I still cannot figure out is something like the following: {{html wiki=true}} <table id="serverList" class="grid sortable filterable doOddEven"> <tr class="sortHeader"> <th class="selectFilter">Space</th> <th>Class</th> <th>Server Name</th> <th class="unsortable noFilter">Link</th> </tr> {{velocity}} #foreach($serverDocument in $serverDocuments) <tr> <td>$serverDocument.Space</td> <td>$serverDocument.Name</td> <td> #foreach($serverObject in $serverDocument.getObjects($serverClass)) * $serverObject.HostName #end </td> <td>[[$serverDocument]]</td> </tr> #end {{/velocity}} </table> {{/html}} This gives me a lot of <br /> tags (the number of $server in $serverList), and ends up displaying 1 row with the literal string $server.Space, $server.Class, etc. It works if I use the normal table syntax: |=Space|=Class|=Server Name|=Link {{velocity}} #foreach($serverDocument in $serverDocuments) |$serverDocument.Space|$serverDocument.Name|???|[[$serverDocument]] #end {{/velocity}} but I'm not sure how I'd iterate over each object associated with the document in the tag marked '???'. Also, whenever I have a {{velocity}} tag, I end up with a lot of empty <p> elements: * Line 1 {{velocity}} #set($foo = "bar") {{/velocity}} * Line 2 This ends up with a <p> tag between "Line 1" and "Line 2", which seems very strange when rendered (since there's no content when "viewing"). Just my 2 cents on the new syntax. But other than that, creating macros now is a breeze (XWiki + Plexus is just purely amazing!), and I think the new syntax is only inches away from surpassing the old 1.0 syntax :-D Thanks again for the great work!
Hi Lewis, On Feb 22, 2009, at 5:56 PM, Lewis Denizen wrote:
Hi xwiki-users,
I've been playing with the new XWiki Syntax 2.0,
Great, we need feedback on the new syntax from using it in the real world!
but there are still some things possible with the old 1.0 syntax which are impossible in the new 2.0 syntax. One thing that I still cannot figure out is something like the following:
{{html wiki=true}} <table id="serverList" class="grid sortable filterable doOddEven"> <tr class="sortHeader"> <th class="selectFilter">Space</th> <th>Class</th> <th>Server Name</th> <th class="unsortable noFilter">Link</th> </tr> {{velocity}} #foreach($serverDocument in $serverDocuments) <tr> <td>$serverDocument.Space</td> <td>$serverDocument.Name</td> <td> #foreach($serverObject in $serverDocument.getObjects($serverClass)) * $serverObject.HostName #end </td> <td>[[$serverDocument]]</td> </tr> #end {{/velocity}} </table> {{/html}}
I've tried your example and indeed it's not working. I've created the following issue: http://jira.xwiki.org/jira/browse/XWIKI-3258 You can monitor it if you want to follow the progress. I'll be working on it tomorrow. For now you can do the following: {{velocity}}{{html}} instead of {{html}}{{velocity}}
This gives me a lot of <br /> tags (the number of $server in $serverList), and ends up displaying 1 row with the literal string $server.Space, $server.Class, etc. It works if I use the normal table syntax:
|=Space|=Class|=Server Name|=Link {{velocity}} #foreach($serverDocument in $serverDocuments) |$serverDocument.Space|$serverDocument.Name|???|[[$serverDocument]] #end {{/velocity}}
but I'm not sure how I'd iterate over each object associated with the document in the tag marked '???'.
Also, whenever I have a {{velocity}} tag, I end up with a lot of empty <p> elements:
* Line 1
{{velocity}} #set($foo = "bar") {{/velocity}}
* Line 2
This ends up with a <p> tag between "Line 1" and "Line 2", which seems very strange when rendered (since there's no content when "viewing").
This is normal. In the new syntax whitespaces and newlines are honored. Thus if you want only one new line between line1 and line2 you'd need to use: * Line 1 {{velocity}}#set($foo = "bar"){{/velocity}} * Line 2
Just my 2 cents on the new syntax. But other than that, creating macros now is a breeze (XWiki + Plexus is just purely amazing!), and I think the new syntax is only inches away from surpassing the old 1.0 syntax :-D Thanks again for the great work!
Cool. Please keep the feedback coming as you try the new syntax out. Thanks -Vincent http://xwiki.com http://xwiki.org http://massol.net
Hi! Can someone help? My Xwiki http://apleti.normala.hr/xwiki to crashes with this message: Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm] Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm] Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm] com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm] at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.ja va:112) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596) at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:125) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces sor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:596) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:830) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFi lter.java:287) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFi lter.java:112) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandl er.java:471) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1565) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext .java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1517) at org.mortbay.http.HttpServer.service(HttpServer.java:954) at org.mortbay.http.HttpConnection.service(HttpConnection.java:816) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) Wrapped Exception: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'parseTemplate' in class com.xpn.xwiki.api.XWiki threw exception java.lang.OutOfMemoryError: Java heap space @ /templates/view.vm[1,8] at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:300 ) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.ja va:203) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.jav a:294) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:31 8) at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroPro xy.java:194) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav a:170) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:31 8) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement .java:107) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:31 8) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java :178) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java :143) at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.ja va:107) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596) at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:125) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces sor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:596) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:830) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFi lter.java:287) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFi lter.java:112) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandl er.java:471) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1565) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext .java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1517) at org.mortbay.http.HttpServer.service(HttpServer.java:954) at org.mortbay.http.HttpConnection.service(HttpConnection.java:816) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) Caused by: java.lang.OutOfMemoryError: Java heap space
Hi Lewis, On Feb 23, 2009, at 12:14 AM, Vincent Massol wrote:
Hi Lewis,
On Feb 22, 2009, at 5:56 PM, Lewis Denizen wrote:
Hi xwiki-users,
I've been playing with the new XWiki Syntax 2.0,
Great, we need feedback on the new syntax from using it in the real world!
but there are still some things possible with the old 1.0 syntax which are impossible in the new 2.0 syntax. One thing that I still cannot figure out is something like the following:
{{html wiki=true}} <table id="serverList" class="grid sortable filterable doOddEven"> <tr class="sortHeader"> <th class="selectFilter">Space</th> <th>Class</th> <th>Server Name</th> <th class="unsortable noFilter">Link</th> </tr> {{velocity}} #foreach($serverDocument in $serverDocuments) <tr> <td>$serverDocument.Space</td> <td>$serverDocument.Name</td> <td> #foreach($serverObject in $serverDocument.getObjects($serverClass)) * $serverObject.HostName #end </td> <td>[[$serverDocument]]</td> </tr> #end {{/velocity}} </table> {{/html}}
I've tried your example and indeed it's not working. I've created the following issue: http://jira.xwiki.org/jira/browse/XWIKI-3258
You can monitor it if you want to follow the progress. I'll be working on it tomorrow.
Actually I've worked on it and the result is that it's not valid... :) The HTML macro must only contain valid HTML and it's not the case in your example. You need to have the velocity content evaluated first so that the content is valid HTML: {{velocity}}{{html}}... Thanks -Vincent [snip]
Hi Sime, Looks like you have a recursive velocity template include in your skin or in a wiki document. Can you check this? Thanks, Jerome. PS: Please create a new thread instead of replying to an existing one and changing the subject, because it appears as children of another conversation. Thanks! Sime Suljic wrote:
Hi!
Can someone help? My Xwiki http://apleti.normala.hr/xwiki to crashes with this message:
Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm]
Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm]
Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm] com.xpn.xwiki.XWikiException: Error number 4001 in 4: Error while parsing velocity page /templates/view.vm Wrapped Exception: Failed to evaluate content with id [/templates/view.vm] at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.ja va:112) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596) at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:125) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces sor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:596) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:830) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFi lter.java:287) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFi lter.java:112) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandl er.java:471) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1565) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext .java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1517) at org.mortbay.http.HttpServer.service(HttpServer.java:954) at org.mortbay.http.HttpConnection.service(HttpConnection.java:816) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Wrapped Exception:
org.apache.velocity.exception.MethodInvocationException: Invocation of method 'parseTemplate' in class com.xpn.xwiki.api.XWiki threw exception java.lang.OutOfMemoryError: Java heap space @ /templates/view.vm[1,8] at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:300 ) at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.ja va:203) at org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.jav a:294) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:31 8) at org.apache.velocity.runtime.directive.VelocimacroProxy.render(VelocimacroPro xy.java:194) at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.jav a:170) at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:74) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:31 8) at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement .java:107) at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:31 8) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java :178) at org.xwiki.velocity.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java :143) at com.xpn.xwiki.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.ja va:107) at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1596) at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:125) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:226) at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:115) at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces sor.java:431) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:596) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:830) at com.xpn.xwiki.web.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFi lter.java:287) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at com.xpn.xwiki.web.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFi lter.java:112) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebAppl icationHandler.java:821) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandl er.java:471) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1565) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext .java:633) at org.mortbay.http.HttpContext.handle(HttpContext.java:1517) at org.mortbay.http.HttpServer.service(HttpServer.java:954) at org.mortbay.http.HttpConnection.service(HttpConnection.java:816) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:983) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) Caused by: java.lang.OutOfMemoryError: Java heap space
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
Hi Vincent, have to thank you again for such a quick and precise response ;-) Switching the two tags worked perfectly! And apologies for not trying this out before posting! On Mon, Feb 23, 2009 at 9:30 AM, Vincent Massol <[email protected]> wrote:
Hi Lewis,
On Feb 23, 2009, at 12:14 AM, Vincent Massol wrote:
Hi Lewis,
On Feb 22, 2009, at 5:56 PM, Lewis Denizen wrote:
Hi xwiki-users,
I've been playing with the new XWiki Syntax 2.0,
Great, we need feedback on the new syntax from using it in the real world!
but there are still some things possible with the old 1.0 syntax which are impossible in the new 2.0 syntax. One thing that I still cannot figure out is something like the following:
{{html wiki=true}} <table id="serverList" class="grid sortable filterable doOddEven"> <tr class="sortHeader"> <th class="selectFilter">Space</th> <th>Class</th> <th>Server Name</th> <th class="unsortable noFilter">Link</th> </tr> {{velocity}} #foreach($serverDocument in $serverDocuments) <tr> <td>$serverDocument.Space</td> <td>$serverDocument.Name</td> <td> #foreach($serverObject in $serverDocument.getObjects($serverClass)) * $serverObject.HostName #end </td> <td>[[$serverDocument]]</td> </tr> #end {{/velocity}} </table> {{/html}}
I've tried your example and indeed it's not working. I've created the following issue: http://jira.xwiki.org/jira/browse/XWIKI-3258
You can monitor it if you want to follow the progress. I'll be working on it tomorrow.
Actually I've worked on it and the result is that it's not valid... :)
The HTML macro must only contain valid HTML and it's not the case in your example.
You need to have the velocity content evaluated first so that the content is valid HTML:
{{velocity}}{{html}}...
Thanks -Vincent
[snip]
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (4)
-
Jerome Velociter -
Lewis Denizen -
Sime Suljic -
Vincent Massol