Return-Path: Delivered-To: apmail-velocity-commits-archive@minotaur.apache.org Received: (qmail 7592 invoked from network); 16 Dec 2010 15:01:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Dec 2010 15:01:51 -0000 Received: (qmail 89180 invoked by uid 500); 16 Dec 2010 15:01:51 -0000 Delivered-To: apmail-velocity-commits-archive@velocity.apache.org Received: (qmail 89130 invoked by uid 500); 16 Dec 2010 15:01:50 -0000 Mailing-List: contact commits-help@velocity.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@velocity.apache.org Delivered-To: mailing list commits@velocity.apache.org Received: (qmail 89118 invoked by uid 99); 16 Dec 2010 15:01:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Dec 2010 15:01:49 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Dec 2010 15:01:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 70B2C2388A43; Thu, 16 Dec 2010 15:01:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1049996 [2/2] - in /velocity/tools/trunk: ./ maven-velocity-tools-plugin/ maven-velocity-tools-plugin/src/ maven-velocity-tools-plugin/src/main/ maven-velocity-tools-plugin/src/main/java/ maven-velocity-tools-plugin/src/main/java/org/ mave... Date: Thu, 16 Dec 2010 15:01:17 -0000 To: commits@velocity.apache.org From: apetrelli@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101216150118.70B2C2388A43@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/pom.xml URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/pom.xml?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/pom.xml (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/pom.xml Thu Dec 16 15:01:15 2010 @@ -89,5 +89,29 @@ 2.1.0-SNAPSHOT runtime + + org.apache.velocity + velocity-tools-view-jsp + 2.1.0-SNAPSHOT + jar + compile + + + javax.servlet + jstl + 1.2 + + + javax.servlet.jsp + jsp-api + 2.1 + jar + provided + + + org.apache.velocity + displaytag-directive + 2.1.0-SNAPSHOT + \ No newline at end of file Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/Person.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/Person.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/Person.java (added) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/Person.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,34 @@ +package org.apache.velocity.tools.examples.showcase.sample; + +public class Person +{ + + private String name; + + private String surname; + + private String role; + + public Person(String name, String surname, String role) + { + this.name = name; + this.surname = surname; + this.role = role; + } + + public String getName() + { + return name; + } + + public String getSurname() + { + return surname; + } + + public String getRole() + { + return role; + } + +} Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/SampleListInitializer.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/SampleListInitializer.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/SampleListInitializer.java (added) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/java/org/apache/velocity/tools/examples/showcase/sample/SampleListInitializer.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,34 @@ +package org.apache.velocity.tools.examples.showcase.sample; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +public class SampleListInitializer implements ServletContextListener +{ + + public void contextInitialized(ServletContextEvent event) + { + List people = new ArrayList(); + people.add(new Person("Claude", "Brisson", "PMC Member")); + people.add(new Person("Nathan", "Bubna", "PMC Member")); + people.add(new Person("Will", "Glass-Husain", "PMC Chair")); + people.add(new Person("Marinó A.", "Jónsson", "PMC Member")); + people.add(new Person("Geir", "Magnusson Jr.", "PMC Member")); + people.add(new Person("Daniel", "Rall", "PMC Member")); + people.add(new Person("Henning P.", "Schmiedehausen", "PMC Member")); + people.add(new Person("Jon S.", "Stevens", "Emeritus")); + people.add(new Person("Jason", "van Zyl", "Emeritus")); + people.add(new Person("Christopher", "Schultz", "Java developer")); + people.add(new Person("Antonio", "Petrelli", "PMC Member")); + event.getServletContext().setAttribute("people", people); + } + + public void contextDestroyed(ServletContextEvent event) + { + // It does nothing. + } + +} Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/DISPLAYTAG-LICENSE.txt URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/DISPLAYTAG-LICENSE.txt?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/DISPLAYTAG-LICENSE.txt (added) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/DISPLAYTAG-LICENSE.txt Thu Dec 16 15:01:15 2010 @@ -0,0 +1,118 @@ + +The Artistic License + +Preamble + + The intent of this document is to state the conditions under which a + Package may be copied, such that the Copyright Holder maintains some + semblance of artistic control over the development of the package, + while giving the users of the package the right to use and distribute + the Package in a more-or-less customary fashion, plus the right to make + reasonable modifications. + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + + + 1. You may make and give away verbatim copies of the source form of the + Standard Version of this Package without restriction, provided that you + duplicate all of the original copyright notices and associated disclaimers. + + + 2. You may apply bug fixes, portability fixes and other modifications + derived from the Public Domain or from the Copyright Holder. A Package + modified in such a way shall still be considered the Standard Version. + + + 3. You may otherwise modify your copy of this Package in any way, provided + that you insert a prominent notice in each changed file stating how and + when you changed that file, and provided that you do at least ONE of the + following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as ftp.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + + + 4. You may distribute the programs of this Package in object code or + executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) accompany any non-standard executables with their corresponding + Standard Version executables, giving the non-standard executables + non-standard names, and clearly documenting the differences in manual + pages (or equivalent), together with instructions on where to get + the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + + + 5. You may charge a reasonable copying fee for any distribution of this + Package. You may charge any fee you choose for support of this Package. + You may not charge a fee for this Package itself. However, + you may distribute this Package in aggregate with other (possibly + commercial) programs as part of a larger (possibly commercial) software + distribution provided that you do not advertise this Package as a + product of your own. + + + 6. The scripts and library files supplied as input to or produced as + output from the programs of this Package do not automatically fall + under the copyright of this Package, but belong to whomever generated + them, and may be sold commercially, and may be aggregated with this + Package. + + + 7. C or perl subroutines supplied by you and linked into this Package + shall not be considered part of this Package. + + + 8. The name of the Copyright Holder may not be used to endorse or promote + products derived from this software without specific prior written permission. + + + 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + The End \ No newline at end of file Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/NOTICE URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/NOTICE?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/NOTICE (added) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/NOTICE Thu Dec 16 15:01:15 2010 @@ -0,0 +1,17 @@ +Apache Velocity Tools +Showcase application + +Copyright (C) 2000-2010 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Support for using SSL with Struts is provided using +the sslext library package, which is open source software +under the Apache Software License 1.1 with copyright attributed +to The Apache Software Foundation. +This software is available from http://sslext.sourceforge.net/ + +This package contains Display Tag Library: + http://www.displaytag.org/ +distributed under the Artistic License. See DISPLAYTAG-LICENSE.txt Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/resources/resources.properties Thu Dec 16 15:01:15 2010 @@ -31,7 +31,7 @@ css.name = CSS Layout css.issuesHeader = Known Issues css.issues = This layout fails in IE4.5/Mac. That browser has poor support for CSS absolute positioning, yet it recognizes and executes the CSS @import statement used to hide CSS from broken browsers. Currently, there is no known solution. css.niftyHeader = Nifty Layout Techniques -css.nifty = All sorts of nifty layout can be accomplished using cascading style sheets (CSS). Check out bluerobot.com and the Layout Reservoir +css.nifty = All sorts of nifty layout can be accomplished using cascading style sheets (CSS). Check out bluerobot.com and the Layout Reservoir ## Print.vm print.name = Print Layout @@ -75,6 +75,7 @@ tools.esc = EscapeTool tools.field = FieldTool tools.include = IncludeTool tools.import = ImportTool +tools.jsp = JSP taglib tools.link = LinkTool tools.lists = ListTool tools.math = MathTool @@ -216,7 +217,7 @@ convert.parseDate_StringObject = Parses convert.parseDate_StringObject.param1 = ''8-1-79'' convert.parseDate_StringObject.param2 = ''M-d-yy'' convert.parseDate_StringStringObject = Parses a String to an instance of Date using the specified format and Locale -convert.parseDate.String = +convert.parseDate.String = convert.parseDate_StringStringObjectTimeZone = Parses a String to an instance of Date using the specified format, Locale and TimeZone convert.toCalendar = Converts an object to an instance of Calendar using the format returned by $convert.dateFormat and the Locale returned by $convert.locale. convert.toCalendar.Object = $date @@ -363,8 +364,8 @@ Node in the internal Node list for this there is no value for that attribute in this element, then this will return null. xml.attributes = Returns a Map of all attributes for the first/sole \ Node held internally by this instance. If that Node is not an Element, this will return null. -xml.isEmpty = Returns true if there are no Nodes internally held by this instance. -xml.size = Returns the number of Nodes internally held by this instance. +xml.isEmpty = Returns true if there are no Nodes internally held by this instance. +xml.size = Returns the number of Nodes internally held by this instance. xml.iterator = Returns an Iterator that returns new XmlTool instances for each Node held internally by this instance. xml.getFirst = Returns a new instance that wraps only the first Node from this instance''s internal Node list. xml.getLast = Returns a new instance that wraps only the last Node from this instance''s internal Node list. Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/velocity.properties URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/velocity.properties?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/velocity.properties (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/velocity.properties Thu Dec 16 15:01:15 2010 @@ -31,3 +31,10 @@ tools.view.servlet.layout.directory = la # relative to the layout directory # NOT relative to the root directory of the webapp! tools.view.servlet.layout.default.template = Default.vm + +userdirective=org.apache.velocity.tools.examples.displaytag.CaptionTagDirective,\ + org.apache.velocity.tools.examples.displaytag.ColumnTagDirective,\ + org.apache.velocity.tools.examples.displaytag.SetPropertyTagDirective,\ + org.apache.velocity.tools.examples.displaytag.TableFooterTagDirective,\ + org.apache.velocity.tools.examples.displaytag.TableTagDirective + Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/web.xml?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/web.xml (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/WEB-INF/web.xml Thu Dec 16 15:01:15 2010 @@ -1,5 +1,4 @@ - - + velocity org.apache.velocity.tools.view.VelocityLayoutServlet @@ -44,4 +46,7 @@ index.vm + + org.apache.velocity.tools.examples.showcase.sample.SampleListInitializer + Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/css/displaytag.css URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/css/displaytag.css?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/css/displaytag.css (added) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/css/displaytag.css Thu Dec 16 15:01:15 2010 @@ -0,0 +1,145 @@ +table { + border: 1px solid #666; + width: 80%; + margin: 20px 0 20px 0 !important; +} + +th,td { + padding: 2px 4px 2px 4px !important; + text-align: left; + vertical-align: top; +} + +thead tr { + background-color: #fc0; +} + +th.sorted { + background-color: orange; +} + +th a,th a:visited { + color: black; +} + +th a:hover { + text-decoration: underline; + color: black; +} + +th.sorted a,th.sortable a { + background-position: right; + display: block; + width: 100%; +} + +th.sortable a { + background-image: url(../img/arrow_off.png); + background-repeat: no-repeat; +} + +th.order1 a { + background-image: url(../img/arrow_down.png); + background-repeat: no-repeat; +} + +th.order2 a { + background-image: url(../img/arrow_up.png); + background-repeat: no-repeat; +} + +tr.odd { + background-color: #fff +} + +tr.tableRowEven,tr.even { + background-color: #fea +} + +div.exportlinks { + background-color: #eee; + border: 1px dotted #999; + padding: 2px 4px 2px 4px; + margin: 2px 0 10px 0; + width: 79%; +} + +span.export { + padding: 0 4px 1px 20px; + display: inline; + display: inline-block; + cursor: pointer; +} + +span.excel { + background-image: url(../img/ico_file_excel.png); +} + +span.csv { + background-image: url(../img/ico_file_csv.png); +} + +span.xml { + background-image: url(../img/ico_file_xml.png); +} + +span.pdf { + background-image: url(../img/ico_file_pdf.png); +} + +span.rtf { + background-image: url(../img/ico_file_rtf.png); +} + +span.pagebanner { + background-color: #eee; + border: 1px dotted #999; + padding: 2px 4px 2px 4px; + width: 79%; + margin-top: 10px; + display: block; + border-bottom: none; +} + +span.pagelinks { + background-color: #eee; + border: 1px dotted #999; + padding: 2px 4px 2px 4px; + width: 79%; + display: block; + border-top: none; + margin-bottom: -5px; +} + + +.group-1 { + font-weight:bold; + padding-bottom:10px; + border-top:1px solid black; +} +.group-2 { + font-style:italic; + border-top: 1px solid black; + +} +.subtotal-sum, .grandtotal-sum { + font-weight:bold; + text-align:right; +} +.subtotal-header { + padding-bottom: 0px; + border-top: 1px solid white; +} +.subtotal-label, .grandtotal-label { + border-top: 1px solid white; + font-weight: bold; +} +.grouped-table tr.even { + background-color: #fff; +} +.grouped-table tr.odd { + background-color: #fff; +} +.grandtotal-row { + border-top: 2px solid black; +} Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_down.png URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_down.png?rev=1049996&view=auto ============================================================================== Binary file - no diff available. Propchange: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_down.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_off.png URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_off.png?rev=1049996&view=auto ============================================================================== Binary file - no diff available. Propchange: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_off.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_up.png URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_up.png?rev=1049996&view=auto ============================================================================== Binary file - no diff available. Propchange: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/displaytag/img/arrow_up.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/header.vm URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/header.vm?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/header.vm (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/header.vm Thu Dec 16 15:01:15 2010 @@ -20,5 +20,8 @@ #if( $stylesheet ) #end +#if( $displayTagStylesheet ) + +#end Added: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/jsp.vm URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/jsp.vm?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/jsp.vm (added) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/jsp.vm Thu Dec 16 15:01:15 2010 @@ -0,0 +1,29 @@ +## Licensed to the Apache Software Foundation (ASF) under one +## or more contributor license agreements. See the NOTICE file +## distributed with this work for additional information +## regarding copyright ownership. The ASF licenses this file +## to you under the Apache License, Version 2.0 (the +## "License"); you may not use this file except in compliance +## with the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, +## software distributed under the License is distributed on an +## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +## KIND, either express or implied. See the License for the +## specific language governing permissions and limitations +## under the License. +#title( 'Maven Taglib2Directive example' ) +

+#set( $demo = $text.demo ) +This is not a 'real' tool, but a Maven plugin that +generates Velocity directives from a JSP Tag library. Here you can see an example +that shows DisplayTag included using Velocity directives. +

+$request.setAttribute("list", $people) +#display_table({"name": "list", "pagesize": 5, "sort": "list"}) + #display_column({"property": "name", "title": "Name", "sortable": true})#end + #display_column({"property": "surname", "title": "Surname", "sortable": true})#end + #display_column({"property": "role", "title": "Role", "sortable": true})#end +#end Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/layout/Default.vm URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/layout/Default.vm?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/layout/Default.vm (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/layout/Default.vm Thu Dec 16 15:01:15 2010 @@ -19,6 +19,7 @@ "http://www.w3.org/TR/html4/strict.dtd"> #set( $stylesheet = '/layout/layout.css' ) +#set( $displayTagStylesheet = '/displaytag/css/displaytag.css' ) #set( $css = $text.css ) #parse( 'header.vm' ) Modified: velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm?rev=1049996&r1=1049995&r2=1049996&view=diff ============================================================================== --- velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm (original) +++ velocity/tools/trunk/velocity-tools-examples/velocity-tools-examples-showcase/src/main/webapp/toolmenu.vm Thu Dec 16 15:01:15 2010 @@ -34,6 +34,7 @@ #toolMenuItem( $llink 'field' ) #toolMenuItem( $llink 'import' ) #toolMenuItem( $llink 'include' ) +#toolMenuItem( $llink 'jsp' ) #toolMenuItem( $llink 'link' ) #toolMenuItem( $llink 'loop' ) #toolMenuItem( $llink 'math' ) Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/TaglibDirective.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/TaglibDirective.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/TaglibDirective.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/TaglibDirective.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,49 @@ +package org.apache.velocity.tools.view.jsp.taglib; + +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.jsp.PageContext; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.runtime.directive.Directive; +import org.apache.velocity.runtime.parser.node.Node; +import org.apache.velocity.tools.view.ViewContext; +import org.apache.velocity.tools.view.jsp.taglib.jspimpl.VelocityPageContext; + +public class TaglibDirective extends Directive +{ + + private static final String PAGE_CONTEXT_ATTRIBUTE_NAME = "org.apache.velocity.tools.view.jsp.taglib.PAGE_CONTEXT"; + + @Override + public String getName() + { + return "taglib"; + } + + @Override + public int getType() + { + return LINE; + } + + @Override + public boolean render(InternalContextAdapter context, Writer writer, Node node) + throws IOException, ResourceNotFoundException, ParseErrorException, + MethodInvocationException + { + ViewContext viewContext = (ViewContext) context + .getInternalUserContext(); + PageContext pageContext = (PageContext) context.get(PAGE_CONTEXT_ATTRIBUTE_NAME); + if (pageContext == null) { + pageContext = new VelocityPageContext(context, writer, viewContext); + context.put(PAGE_CONTEXT_ATTRIBUTE_NAME, pageContext); + } + return true; + } + +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/ExternalWriterHttpServletResponse.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/ExternalWriterHttpServletResponse.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/ExternalWriterHttpServletResponse.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/ExternalWriterHttpServletResponse.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,62 @@ +/* + * $Id: ExternalWriterHttpServletResponse.java 892369 2009-12-18 20:21:36Z apetrelli $ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +/** + * Copied from Tiles Request sandbox. + * + * Wraps an HTTP response and overrides its print writer. + * + * @version $Rev: 892369 $ $Date: 2009-12-18 21:21:36 +0100 (ven, 18 dic 2009) $ + * @since 2.2.0 + */ +public class ExternalWriterHttpServletResponse extends + HttpServletResponseWrapper { + + /** + * The print writer to use, instead of the response's one. + */ + private PrintWriter writer; + + /** + * Constructor. + * + * @param response The response to wrap. + * @param writer The print writer to use, instead of the response's one. + * @since 2.2.0 + */ + public ExternalWriterHttpServletResponse(HttpServletResponse response, PrintWriter writer) { + super(response); + this.writer = writer; + } + + /** {@inheritDoc} */ + @Override + public PrintWriter getWriter() { + return writer; + } +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspUtils.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspUtils.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspUtils.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspUtils.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,84 @@ +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.PageContext; +import javax.servlet.jsp.tagext.BodyContent; +import javax.servlet.jsp.tagext.BodyTag; +import javax.servlet.jsp.tagext.JspTag; +import javax.servlet.jsp.tagext.SimpleTag; +import javax.servlet.jsp.tagext.Tag; +import javax.servlet.jsp.tagext.TagAdapter; + +import org.apache.velocity.context.Context; +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.runtime.parser.node.ASTBlock; +import org.apache.velocity.runtime.parser.node.Node; + +public class JspUtils +{ + private final static String LATEST_TAG_ATTRIBUTE_NAME = "org.apache.velocity.tools.view.jsp.taglib.jspimpl.LATEST_TAG"; + + public static void setLatestTag(Context context, JspTag tag) { + context.put(LATEST_TAG_ATTRIBUTE_NAME, tag); + } + + public static JspTag getLatestJspTag(Context context) { + return (JspTag) context.get(LATEST_TAG_ATTRIBUTE_NAME); + } + + public static Tag wrapTag(JspTag tag) { + if (tag == null) { + return null; + } + if (tag instanceof Tag) + { + return (Tag) tag; + } + if (tag instanceof SimpleTag) + { + return new TagAdapter((SimpleTag) tag); + } + throw new VelocityToolsJspException( + "Cannot get tag that is not a Tag nor a SimpleTag, class " + + tag.getClass().getCanonicalName()); + } + + public static void executeSimpleTag(InternalContextAdapter context, + Node node, PageContext pageContext, SimpleTag tag) + throws JspException, IOException + { + tag.setJspBody(new VelocityJspFragment(pageContext, (ASTBlock) node + .jjtGetChild(1), context)); + tag.doTag(); + } + + public static void executeTag(InternalContextAdapter context, Node node, + PageContext pageContext, Tag tag) throws JspException + { + int result = tag.doStartTag(); + if (tag instanceof BodyTag) + { + BodyTag bodyTag = (BodyTag) tag; + BodyContent bodyContent = new VelocityBodyContent( + pageContext.getOut(), (ASTBlock) node.jjtGetChild(1), + context); + switch (result) + { + case BodyTag.EVAL_BODY_BUFFERED: + bodyTag.setBodyContent(bodyContent); + bodyTag.doInitBody(); + case BodyTag.EVAL_BODY_INCLUDE: + bodyContent.getString(); + default: + break; + } + while (bodyTag.doAfterBody() == BodyTag.EVAL_BODY_AGAIN) { + bodyContent.getString(); + } + } + tag.doEndTag(); + } + +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspWriterImpl.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspWriterImpl.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspWriterImpl.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/JspWriterImpl.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,394 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.jsp.JspWriter; + +/** + * Copied and modified from Tomcat 6.0.x source. + * + * Write text to a character-output stream, buffering characters so as + * to provide for the efficient writing of single characters, arrays, + * and strings. + * + * Provide support for discarding for the output that has been + * buffered. + * + * This needs revisiting when the buffering problems in the JSP spec + * are fixed -akv + * + * @author Anil K. Vijendran + */ +public class JspWriterImpl extends JspWriter { + + private Writer out; + + /** + * Create a buffered character-output stream that uses a default-sized + * output buffer. + * + * @param out The writer. + */ + public JspWriterImpl(Writer out) { + super(0, true); + this.out = out; + } + + /** + * Discard the output buffer. + */ + public final void clear() throws IOException { + throw new IllegalStateException("Cannot clear after an unbuffered output"); + } + + public void clearBuffer() throws IOException { + throw new IllegalStateException("Cannot clear after an unbuffered output"); + } + + /** + * Flush the stream. + * + */ + public void flush() throws IOException { + out.flush(); + } + + /** + * Close the stream. + * + */ + public void close() throws IOException { + out.close(); + } + + /** + * @return the number of bytes unused in the buffer + */ + public int getRemaining() { + return 0; + } + + + /** + * Write a single character. + */ + public void write(int c) throws IOException { + out.write(c); + } + + /** + * Write a portion of an array of characters. + * + *

Ordinarily this method stores characters from the given array into + * this stream's buffer, flushing the buffer to the underlying stream as + * needed. If the requested length is at least as large as the buffer, + * however, then this method will flush the buffer and write the characters + * directly to the underlying stream. Thus redundant + * DiscardableBufferedWriters will not copy data unnecessarily. + * + * @param cbuf A character array + * @param off Offset from which to start reading characters + * @param len Number of characters to write + */ + public void write(char cbuf[], int off, int len) + throws IOException + { + out.write(cbuf, off, len); + } + + /** + * Write an array of characters. This method cannot be inherited from the + * Writer class because it must suppress I/O exceptions. + */ + public void write(char buf[]) throws IOException { + write(buf, 0, buf.length); + } + + /** + * Write a portion of a String. + * + * @param s String to be written + * @param off Offset from which to start reading characters + * @param len Number of characters to be written + */ + public void write(String s, int off, int len) throws IOException { + out.write(s, off, len); + } + + /** + * Write a string. This method cannot be inherited from the Writer class + * because it must suppress I/O exceptions. + */ + public void write(String s) throws IOException { + // Simple fix for Bugzilla 35410 + // Calling the other write function so as to init the buffer anyways + if(s == null) { + write(s, 0, 0); + } else { + write(s, 0, s.length()); + } + } + + + static String lineSeparator = System.getProperty("line.separator"); + + /** + * Write a line separator. The line separator string is defined by the + * system property line.separator, and is not necessarily a single + * newline ('\n') character. + * + * @exception IOException If an I/O error occurs + */ + + public void newLine() throws IOException { + write(lineSeparator); + } + + + /* Methods that do not terminate lines */ + + /** + * Print a boolean value. The string produced by {@link + * java.lang.String#valueOf(boolean)} is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the {@link + * #write(int)} method. + * + * @param b The boolean to be printed + */ + public void print(boolean b) throws IOException { + write(b ? "true" : "false"); + } + + /** + * Print a character. The character is translated into one or more bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the {@link + * #write(int)} method. + * + * @param c The char to be printed + */ + public void print(char c) throws IOException { + write(String.valueOf(c)); + } + + /** + * Print an integer. The string produced by {@link + * java.lang.String#valueOf(int)} is translated into bytes according + * to the platform's default character encoding, and these bytes are + * written in exactly the manner of the {@link #write(int)} + * method. + * + * @param i The int to be printed + */ + public void print(int i) throws IOException { + write(String.valueOf(i)); + } + + /** + * Print a long integer. The string produced by {@link + * java.lang.String#valueOf(long)} is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the {@link #write(int)} + * method. + * + * @param l The long to be printed + */ + public void print(long l) throws IOException { + write(String.valueOf(l)); + } + + /** + * Print a floating-point number. The string produced by {@link + * java.lang.String#valueOf(float)} is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the {@link #write(int)} + * method. + * + * @param f The float to be printed + */ + public void print(float f) throws IOException { + write(String.valueOf(f)); + } + + /** + * Print a double-precision floating-point number. The string produced by + * {@link java.lang.String#valueOf(double)} is translated into + * bytes according to the platform's default character encoding, and these + * bytes are written in exactly the manner of the {@link + * #write(int)} method. + * + * @param d The double to be printed + */ + public void print(double d) throws IOException { + write(String.valueOf(d)); + } + + /** + * Print an array of characters. The characters are converted into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the {@link #write(int)} + * method. + * + * @param s The array of chars to be printed + * + * @throws NullPointerException If s is null + */ + public void print(char s[]) throws IOException { + write(s); + } + + /** + * Print a string. If the argument is null then the string + * "null" is printed. Otherwise, the string's characters are + * converted into bytes according to the platform's default character + * encoding, and these bytes are written in exactly the manner of the + * {@link #write(int)} method. + * + * @param s The String to be printed + */ + public void print(String s) throws IOException { + if (s == null) { + s = "null"; + } + write(s); + } + + /** + * Print an object. The string produced by the {@link + * java.lang.String#valueOf(Object)} method is translated into bytes + * according to the platform's default character encoding, and these bytes + * are written in exactly the manner of the {@link #write(int)} + * method. + * + * @param obj The Object to be printed + */ + public void print(Object obj) throws IOException { + write(String.valueOf(obj)); + } + + /* Methods that do terminate lines */ + + /** + * Terminate the current line by writing the line separator string. The + * line separator string is defined by the system property + * line.separator, and is not necessarily a single newline + * character ('\n'). + * + * Need to change this from PrintWriter because the default + * println() writes to the sink directly instead of through the + * write method... + */ + public void println() throws IOException { + newLine(); + } + + /** + * Print a boolean value and then terminate the line. This method behaves + * as though it invokes {@link #print(boolean)} and then + * {@link #println()}. + */ + public void println(boolean x) throws IOException { + print(x); + println(); + } + + /** + * Print a character and then terminate the line. This method behaves as + * though it invokes {@link #print(char)} and then {@link + * #println()}. + */ + public void println(char x) throws IOException { + print(x); + println(); + } + + /** + * Print an integer and then terminate the line. This method behaves as + * though it invokes {@link #print(int)} and then {@link + * #println()}. + */ + public void println(int x) throws IOException { + print(x); + println(); + } + + /** + * Print a long integer and then terminate the line. This method behaves + * as though it invokes {@link #print(long)} and then + * {@link #println()}. + */ + public void println(long x) throws IOException { + print(x); + println(); + } + + /** + * Print a floating-point number and then terminate the line. This method + * behaves as though it invokes {@link #print(float)} and then + * {@link #println()}. + */ + public void println(float x) throws IOException { + print(x); + println(); + } + + /** + * Print a double-precision floating-point number and then terminate the + * line. This method behaves as though it invokes {@link + * #print(double)} and then {@link #println()}. + */ + public void println(double x) throws IOException { + print(x); + println(); + } + + /** + * Print an array of characters and then terminate the line. This method + * behaves as though it invokes {@link #print(char[])} and then + * {@link #println()}. + */ + public void println(char x[]) throws IOException { + print(x); + println(); + } + + /** + * Print a String and then terminate the line. This method behaves as + * though it invokes {@link #print(String)} and then + * {@link #println()}. + */ + public void println(String x) throws IOException { + print(x); + println(); + } + + /** + * Print an Object and then terminate the line. This method behaves as + * though it invokes {@link #print(Object)} and then + * {@link #println()}. + */ + public void println(Object x) throws IOException { + print(x); + println(); + } + +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityBodyContent.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityBodyContent.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityBodyContent.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityBodyContent.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,219 @@ +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; + +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.tagext.BodyContent; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.exception.MethodInvocationException; +import org.apache.velocity.exception.ParseErrorException; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.runtime.parser.node.ASTBlock; + +public class VelocityBodyContent extends BodyContent +{ + + private ASTBlock block; + + private InternalContextAdapter context; + + public VelocityBodyContent(JspWriter jspWriter, ASTBlock block, + InternalContextAdapter context) + { + super(jspWriter); + this.block = block; + this.context = context; + } + + @Override + public Reader getReader() + { + return new StringReader(getString()); + } + + @Override + public String getString() + { + StringWriter stringWriter = new StringWriter(); + try + { + block.render(context, stringWriter); + stringWriter.close(); + return stringWriter.toString(); + } catch (MethodInvocationException e) + { + throw new VelocityToolsJspException("Cannot invoke a method while rendering a body", e); + } catch (ResourceNotFoundException e) + { + throw new VelocityToolsJspException("Cannot find a resource while rendering a body", e); + } catch (ParseErrorException e) + { + throw new VelocityToolsJspException("Cannot parse while rendering a body", e); + } catch (IOException e) + { + throw new VelocityToolsJspException("I/O exception while rendering a body", e); + } + } + + @Override + public void writeOut(Writer out) throws IOException + { + block.render(context, out); + } + + @Override + public void newLine() throws IOException + { + getEnclosingWriter().newLine(); + } + + @Override + public void print(boolean b) throws IOException + { + getEnclosingWriter().print(b); + } + + @Override + public void print(char c) throws IOException + { + getEnclosingWriter().print(c); + } + + @Override + public void print(int i) throws IOException + { + getEnclosingWriter().print(i); + } + + @Override + public void print(long l) throws IOException + { + getEnclosingWriter().print(l); + } + + @Override + public void print(float f) throws IOException + { + getEnclosingWriter().print(f); + } + + @Override + public void print(double d) throws IOException + { + getEnclosingWriter().print(d); + } + + @Override + public void print(char[] s) throws IOException + { + getEnclosingWriter().print(s); + } + + @Override + public void print(String s) throws IOException + { + getEnclosingWriter().print(s); + } + + @Override + public void print(Object obj) throws IOException + { + getEnclosingWriter().print(obj); + } + + @Override + public void println() throws IOException + { + getEnclosingWriter().println(); + } + + @Override + public void println(boolean x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(char x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(int x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(long x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(float x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(double x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(char[] x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(String x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void println(Object x) throws IOException + { + getEnclosingWriter().println(x); + } + + @Override + public void clear() throws IOException + { + getEnclosingWriter().clear(); + } + + @Override + public void clearBuffer() throws IOException + { + getEnclosingWriter().clearBuffer(); + } + + @Override + public void close() throws IOException + { + getEnclosingWriter().close(); + } + + @Override + public int getRemaining() + { + return getEnclosingWriter().getRemaining(); + } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException + { + getEnclosingWriter().write(cbuf, off, len); + } + +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityJspFragment.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityJspFragment.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityJspFragment.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityJspFragment.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,43 @@ +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +import java.io.IOException; +import java.io.Writer; + +import javax.servlet.jsp.JspContext; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.PageContext; +import javax.servlet.jsp.tagext.JspFragment; + +import org.apache.velocity.context.InternalContextAdapter; +import org.apache.velocity.runtime.parser.node.ASTBlock; + +public class VelocityJspFragment extends JspFragment +{ + + private PageContext pageContext; + + private ASTBlock block; + + private InternalContextAdapter context; + + public VelocityJspFragment(PageContext pageContext, ASTBlock block, + InternalContextAdapter context) + { + this.pageContext = pageContext; + this.block = block; + this.context = context; + } + + @Override + public void invoke(Writer out) throws JspException, IOException + { + block.render(context, out); + } + + @Override + public JspContext getJspContext() + { + return pageContext; + } + +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityPageContext.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityPageContext.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityPageContext.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityPageContext.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,384 @@ +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.Writer; +import java.util.Enumeration; +import java.util.NoSuchElementException; + +import javax.el.ELContext; +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.PageContext; + +import org.apache.velocity.context.Context; +import org.apache.velocity.tools.view.ViewContext; + +public class VelocityPageContext extends PageContext { + + private Context velocityContext; + + private Writer velocityWriter; + + private ViewContext viewContext; + + private JspWriter jspWriter; + + private HttpServletRequest request; + + private HttpServletResponse response; + + public VelocityPageContext(Context velocityContext, Writer velocityWriter, ViewContext viewContext) + { + super(); + this.velocityContext = velocityContext; + this.velocityWriter = velocityWriter; + this.viewContext = viewContext; + this.request = viewContext.getRequest(); + this.response = viewContext.getResponse(); + jspWriter = new JspWriterImpl(velocityWriter); + velocityContext.put("out", jspWriter); + } + + @Override + public void initialize(Servlet servlet, ServletRequest request, + ServletResponse response, String errorPageURL, + boolean needsSession, int bufferSize, boolean autoFlush) + throws IOException, IllegalStateException, IllegalArgumentException { + // We never call it and we discard this object at the end of the page call. + } + + @Override + public void release() { + // We never call it and we discard this object at the end of the page call. + } + + @Override + public HttpSession getSession() { + return request.getSession(false); + } + + @Override + public Object getPage() { + return viewContext; + } + + @Override + public ServletRequest getRequest() { + return request; + } + + @Override + public ServletResponse getResponse() { + return response; + } + + @Override + public Exception getException() { + return null; + } + + @Override + public ServletConfig getServletConfig() { + throw new UnsupportedOperationException("Servlet config is not supported"); + } + + @Override + public ServletContext getServletContext() { + return viewContext.getServletContext(); + } + + @Override + public void forward(String relativeUrlPath) throws ServletException, + IOException { + RequestDispatcher dispatcher = request.getRequestDispatcher(relativeUrlPath); + if (dispatcher == null) { + throw new IllegalArgumentException("Cannot forward to '" +relativeUrlPath + "'"); + } + dispatcher.forward(request, new ExternalWriterHttpServletResponse(response, new PrintWriter(velocityWriter))); + + } + + @Override + public void include(String relativeUrlPath) throws ServletException, + IOException { + include(relativeUrlPath, true); + } + + @Override + public void include(String relativeUrlPath, boolean flush) + throws ServletException, IOException { + if (flush) { + velocityWriter.flush(); + } + RequestDispatcher dispatcher = request.getRequestDispatcher(relativeUrlPath); + if (dispatcher == null) { + throw new IllegalArgumentException("Cannot include '" +relativeUrlPath + "'"); + } + dispatcher.include(request, new ExternalWriterHttpServletResponse(response, new PrintWriter(velocityWriter))); + } + + @Override + public void handlePageException(Exception e) throws ServletException, + IOException { + handlePageException((Throwable) e); + } + + @Override + public void handlePageException(Throwable t) throws ServletException, + IOException { + if (t instanceof RuntimeException) + { + throw (RuntimeException) t; + } + if (t instanceof Error) + { + throw (Error) t; + } + throw new ServletException("Rethrowing unmanaged exception", t); + } + + @Override + public void setAttribute(String name, Object value) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + velocityContext.put(name, value); + } + + @Override + public void setAttribute(String name, Object value, int scope) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + switch (scope) + { + case PAGE_SCOPE: + velocityContext.put(name, value); + break; + case REQUEST_SCOPE: + request.setAttribute(name, value); + break; + case SESSION_SCOPE: + if (value == null) { + HttpSession session = request.getSession(false); + if (session != null) { + session.removeAttribute(name); + } + } else { + HttpSession session = request.getSession(); + session.setAttribute(name, value); + } + break; + case APPLICATION_SCOPE: + viewContext.getServletContext().setAttribute(name, value); + break; + default: + throw new IllegalArgumentException("Invalid scope constant value: " + scope); + } + } + + @Override + public Object getAttribute(String name) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + return velocityContext.get(name); + } + + @Override + public Object getAttribute(String name, int scope) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + switch (scope) + { + case PAGE_SCOPE: + return velocityContext.get(name); + case REQUEST_SCOPE: + return request.getAttribute(name); + case SESSION_SCOPE: + HttpSession session = request.getSession(false); + if (session != null) { + return session.getAttribute(name); + } else { + return null; + } + case APPLICATION_SCOPE: + return viewContext.getServletContext().getAttribute(name); + default: + throw new IllegalArgumentException("Invalid scope constant value: " + scope); + } + } + + @Override + public Object findAttribute(String name) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + Object candidate = velocityContext.get(name); + if (candidate == null) { + candidate = request.getAttribute(name); + if (candidate == null) { + HttpSession session = request.getSession(false); + if (session != null) { + candidate = session.getAttribute(name); + } + if (candidate == null) { + candidate = viewContext.getServletContext().getAttribute(name); + } + } + } + return candidate; + } + + @Override + public void removeAttribute(String name) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + velocityContext.remove(name); + request.removeAttribute(name); + HttpSession session = request.getSession(false); + if (session != null) { + session.removeAttribute(name); + } + viewContext.getServletContext().removeAttribute(name); + } + + @Override + public void removeAttribute(String name, int scope) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + switch (scope) + { + case PAGE_SCOPE: + velocityContext.remove(name); + break; + case REQUEST_SCOPE: + request.removeAttribute(name); + break; + case SESSION_SCOPE: + HttpSession session = request.getSession(false); + if (session != null) { + session.removeAttribute(name); + } + break; + case APPLICATION_SCOPE: + viewContext.getServletContext().removeAttribute(name); + break; + default: + throw new IllegalArgumentException("Invalid scope constant value: " + scope); + } + } + + @Override + public int getAttributesScope(String name) { + if (name == null) { + throw new NullPointerException("The attribute name is null"); + } + if (velocityContext.get(name) != null) { + return PAGE_SCOPE; + } + if (request.getAttribute(name) != null) { + return REQUEST_SCOPE; + } + HttpSession session = request.getSession(false); + if (session != null) { + if (session.getAttribute(name) != null) { + return SESSION_SCOPE; + } + } + if (viewContext.getServletContext().getAttribute(name) != null) { + return APPLICATION_SCOPE; + } + return 0; + } + + @SuppressWarnings("unchecked") + @Override + public Enumeration getAttributeNamesInScope(int scope) { + switch (scope) + { + case PAGE_SCOPE: + return new Enumeration() + { + + private int index = 0; + + private Object[] keys = velocityContext.getKeys(); + + public boolean hasMoreElements() + { + return index < keys.length; + } + + public String nextElement() + { + String retValue = (String) keys[index]; + index++; + return retValue; + } + }; + case REQUEST_SCOPE: + return request.getAttributeNames(); + case SESSION_SCOPE: + HttpSession session = request.getSession(false); + if (session != null) { + return session.getAttributeNames(); + } + return new Enumeration() + { + + public boolean hasMoreElements() + { + return false; + } + + public String nextElement() + { + throw new NoSuchElementException("This is an empty enumeration"); + } + }; + case APPLICATION_SCOPE: + return viewContext.getServletContext().getAttributeNames(); + default: + throw new IllegalArgumentException("Invalid scope constant value: " + scope); + } + } + + @Override + public JspWriter getOut() { + return jspWriter; + } + + @SuppressWarnings("deprecation") + @Override + public javax.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator() { + // Really, who cares? + throw new UnsupportedOperationException("This class works only with JSP 2.1"); + } + + @SuppressWarnings("deprecation") + @Override + public javax.servlet.jsp.el.VariableResolver getVariableResolver() { + // Really, who cares? + throw new UnsupportedOperationException("This class works only with JSP 2.1"); + } + + @Override + public ELContext getELContext() { + // Really, who cares? + throw new UnsupportedOperationException("EL not available at this point"); + } +} Added: velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityToolsJspException.java URL: http://svn.apache.org/viewvc/velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityToolsJspException.java?rev=1049996&view=auto ============================================================================== --- velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityToolsJspException.java (added) +++ velocity/tools/trunk/velocity-tools-view-jsp/src/main/java/org/apache/velocity/tools/view/jsp/taglib/jspimpl/VelocityToolsJspException.java Thu Dec 16 15:01:15 2010 @@ -0,0 +1,30 @@ +package org.apache.velocity.tools.view.jsp.taglib.jspimpl; + +public class VelocityToolsJspException extends RuntimeException +{ + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 7627800888526325645L; + + public VelocityToolsJspException() + { + } + + public VelocityToolsJspException(String message) + { + super(message); + } + + public VelocityToolsJspException(Throwable cause) + { + super(cause); + } + + public VelocityToolsJspException(String message, Throwable cause) + { + super(message, cause); + } + +}