Re: velocity.properties

2005-01-17 Thread Ravikanth L
Hi Jecki,

If you are looking for all the properties that can be configured in
velocity.properties file, you can get that sample velocity.properties
file in you velocity.jar file.

Anyhow here are the contents what I have in my velocity.properties
which came in the jar.
#--begin--
#
# These are the default properties for the
# Velocity Runtime. These values are used when
# Runtime.init() is called, and when Runtime.init(properties)
# fails to find the specificed properties file.
#

#
# R U N T I M E  L O G
#

#
#  default LogSystem to use: default: AvalonLogSystem
#

runtime.log.logsystem.class =
org.apache.velocity.runtime.log.AvalonLogSystem,org.apache.velocity.runtime.log.SimpleLog4JLogSystem

#---
# This is the location of the Velocity Runtime log.
#

runtime.log = velocity.log

#
# This controls if Runtime.error(), info() and warn() messages include the
# whole stack trace. The last property controls whether invalid references
# are logged.
#

runtime.log.error.stacktrace = false
runtime.log.warn.stacktrace = false
runtime.log.info.stacktrace = false
runtime.log.invalid.reference = true

#
# Configuration for the Log4JLogSystem.
# You must define the runtime.log.logsystem.class property to be:
#   org.apache.velocity.runtime.log.Log4JLogSystem
#
# You must also include Log4J's .jar files into your classpath. They are
# included with the Velocity distribution in the build/lib directory.
#
# There are several different options that you can configure.
# Uncomment the ones that you want and also define their settings.
#
#runtime.log.logsystem.log4j.pattern=%d - %m%n
#runtime.log.logsystem.log4j.file.size=10
#runtime.log.logsystem.log4j.file.backups=1
#runtime.log.logsystem.log4j.syslogd.host=my.syslog.server.com
#runtime.log.logsystem.log4j.syslogd.facility=LOG_DAEMON
#runtime.log.logsystem.log4j.remote.host=my.remote.server.com
#runtime.log.logsystem.log4j.remote.port=1099
#runtime.log.logsystem.log4j.email.server=localhost
[EMAIL PROTECTED]
[EMAIL PROTECTED]
#runtime.log.logsystem.log4j.email.subject=Velocity Error Report
#runtime.log.logsystem.log4j.email.buffer.size=512

#
# T E M P L A T E  E N C O D I N G
#

input.encoding=ISO-8859-1
output.encoding=ISO-8859-1

#
# F O R E A C H  P R O P E R T I E S
#
# These properties control how the counter is accessed in the #foreach
# directive. By default the reference $velocityCount will be available
# in the body of the #foreach directive. The default starting value
# for this reference is 1.
#

directive.foreach.counter.name = velocityCount
directive.foreach.counter.initial.value = 1

#
# I N C L U D E  P R O P E R T I E S
#
# These are the properties that governed the way #include'd content
# is governed.
#

directive.include.output.errormsg.start = !-- include error :
directive.include.output.errormsg.end   =  see error log --

#
# P A R S E  P R O P E R T I E S
#

directive.parse.max.depth = 10

#
# T E M P L A T E  L O A D E R S
#
#
#
#

resource.loader = file

file.resource.loader.description = Velocity File Resource Loader

Creating objects in template using new keyword

2005-02-28 Thread Ravikanth L
Hi All,

 I would like to create a object reference in template using new
keyword like what we do in java

String obj = new String()

I need to put RenderTool instance in context and use it to fix some
problem. I know that i can put it to context from the java code where
the template is being called or using toolbox.xml  But as my
application is standalone and in production and i don't want to change
the java code to fix the issue, i want to handle it in template.

And also is there any way to get the reference to the context in
templates when Velocity.mergeTemplate() is being used, though the
context reference is not kept in context.

Is it possible to achieve this ? Any suggestions are most welcome. 

-- 
With Regards,
Ravikanth.L

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Creating objects in template using new keyword

2005-03-03 Thread Ravikanth L
Hi Shinobu,

Thank you very much for the information. It was a simple java code
change only to add two new instances to the context from the java
code, but i wanted to avoid java code change.

-- 
With Regards,
Ravikanth.L

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



while loop

2005-09-14 Thread Ravikanth L
Hi All,
 Like #foreach does velocity has support for while loop.
 I am supposed to use a custom api which is having methods like 
hasMoreSubElements(), nextSubElement() etc... on given element. Usually we 
will use while loop for these scenarios. 
 Let me know if we can use #while etc...if so a small sample will be of 
great help.

-- 
With Regards,
Ravikanth.L


Problems with recurse method exception of RenderTool

2005-09-15 Thread Ravikanth L
Hi All,
 Can anyone let me know when will the recurse method of RenderTool throws 
exception. Means what are the scenarios for the recurse method to throw an 
exception.
 I am dynamically creating variables and assigning them values in the 
template like
#foreach($subElementName in $elementSet.keySet())
#* *##set($subElement = $elementSet.get($subElementName))
#* *##foreach( $value in $subElement.getValueList())##
#* *##set($theValue = $!value.getValue())##
#* *#$render.recurse($ctx, '\#set($$subElementName = $theValue)')##
#* *##end##
#end##
It was working without any problem in the production environment as 
wellbut now started giving problems. Now i am getting the error in the 
log as:
Method recurse threw exception for reference $render in template 
transora_cin_catalog.vm at [22,27]
 Is it a problem of null values for $subElementName and $theValue? i tried 
with null value for variable name and as well as value with a similar 
example, it didn't give this error, only got not a valid reference in the 
log for my expected variable. 
 Any suggestions will be of great help.
-- 
With Regards,
Ravikanth.L


Re: Hacking Velocity

2005-09-16 Thread Ravikanth L
Hi Will,
 I was trying the following example (to create a custom class instance 
dynamically in the template) given in the slides
  ## Let's do some mischief and instantiate an arbitrary class
#set ($fileclass = $obj.Class.forName(java.io.File))
#set ($stringclass = $obj.Class.forName(java.lang.String))
#set ($paramlist = [..])
#set ($paramarray = $paramlist.toArray())
#set ($constructors = $fileclass.constructors)
 ## Call the constructor java.io.File(String)
#foreach ($c in $constructors)
#if ($c.toString() == public java.io.File(java.lang.String))
#set ($file = $c.newInstance($paramarray))
$file
#end
#end

where $obj is any object instance. I am neither getting the output nor its 
giving any error in the velocity log. I am using default introspector, not 
changed anything. Does the deault introspector allows to create 
newinstance() etc from template?
 Am i missing anything else otherwise?
 Regards,
Ravi
On 12/7/04, Will Glass-Husain [EMAIL PROTECTED] wrote: 
 
 Thanks for the pointer to my slides from ApacheCon (Hacking Velocity).
 
 For the record there are slides and sample code available on these topics:
 
 -- VelocityViewServlet
 -- Custom directives
 -- Custom resource loaders
 -- Event handlers
 -- Custom introspector
 -- Modifying Velocity syntax with JavaCC
 
 I've put the material on the Wiki for more general availability. Hope this
 is useful to other users.
 http://wiki.apache.org/jakarta-velocity/HackingVelocity
 
 Best, WILL
 
 - Original Message -
 From: Shinobu Kawai [EMAIL PROTECTED]
 To: Velocity Users List velocity-user@jakarta.apache.org
 Sent: Monday, December 06, 2004 2:12 PM
 Subject: Re: [FAQ] How do you check for null?
 
 
  Hi Henning,
 
  With the slides from Will's talk @ ApacheCon, you should be able to
  add a new statement to the VTL so you can do
 
  #ifnull($car.fuel)
 
  Hey, thanks for the idea! Approach #6 : use a custom directive. :)
  I'll look into that.
 
  Best regards,
  -- Shinobu Kawai
 
  --
  Shinobu Kawai [EMAIL PROTECTED]
 


Valid characters for value in VTL - urgent

2005-09-19 Thread Ravikanth L
Hi All,
 I would like to know the valid characters that we can use for a value in 
VTL. I tried the following
#set($var = My string with special chars##)
It throws ParseErrorrException as:
org.apache.velocity.exception.ParseErrorException: Lexical error: 
org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 1, 
column 19. Encountered: EOF after : .
 It didn't complain if i use single #. So, i would like to know what all 
character combinations will result in ParserErrorException without any 
escaping done, bcoz we are reading variable names and their values from an 
XML file and constructing variables dynamically using RenderTool. 
 Tried to find in User docs but no luck. 
 Can anyone pls let me know the list or point me to the link where i can get 
the details.
-- 
With Regards,
Ravikanth.L


Re: Valid characters for value in VTL - urgent

2005-09-19 Thread Ravikanth L
Hi Christoph,
 Thanks a lot for replying back.
 As far as the suggestions you gave, i can't use failsafe escaping apporoach 
as i am not hardcoding the values in the template. As i said earlier, we are 
having an xml file where in we define element name and its value as
element name=myvar
 valueUser can enter what ever text they want here/value
/element
And we are reading the xml and dynamically creating the variables and 
associating them with the values to the context using renderTool as below in 
template
$render.recurse($ctx, '\#set($$nameObj = $theValue)' )
 where $nameObj contains the variable name and the $theValue contains the 
text between value and /value.
 And regarding using single quote approach, as the recurse has to evaluate 
my #set, i think the syntax i have given is correct. Tried changing the 
syntax also by giving single qoutes with escaping for $theValue, but getting 
some parser errors.
 So, if i can get a list of characters which will create problems in #set 
directive like ##, newline etc... i can ask the users not to use them or try 
to escape them in the xml itself 
 Any suggetions will be of great help.

-- 
With Regards,
Ravikanth.L 
 On 9/19/05, Christoph Reck [EMAIL PROTECTED] wrote: 
 
 Hi,
 
 Ravikanth L wrote:
  Hi All,
  I would like to know the valid characters that we can use for a value in
  VTL. I tried the following
  #set($var = My string with special chars##)
 
 Velocity defines a line-comment starting with the characters ##
 Also note that Velocity offers a feature called string interpolation,
 where within a directive (#if and #set) the references inside double
 quotes are evaluated and inserted.
 
 You have detected a parser bug, where it chokes on the fact that the
 EOL-comment is not compatible with the interpolation.
 
 Please consider using single quotes or using a failsafe escaping:
 #set( $var = 'My string with special chars##' )
 #set( $H = '#' )
 #set( $var = My string with special chars$H$H )
 
 I am aware of some issues that are related to the problem (maybe you can
 vote on them):
 http://issues.apache.org/jira/browse/VELOCITY-126 String containing '##' 
 is treated as unterminated String
 http://issues.apache.org/jira/browse/VELOCITY-355 lost '#'s inside 
 #literal()/#end
 http://issues.apache.org/jira/browse/VELOCITY-272 EOF exception when last 
 line is commented out and has no new line at end
 http://issues.apache.org/jira/browse/VELOCITY-253 Enhance whitespace 
 gobbling - involves parser syntax simplification
 
 Hope this helped,
 Christoph
 
  It throws ParseErrorrException as:
  org.apache.velocity.exception.ParseErrorException: Lexical error:
  org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line 
 1,
  column 19. Encountered: EOF after : .
  It didn't complain if i use single #. So, i would like to know what all
  character combinations will result in ParserErrorException without any
  escaping done, bcoz we are reading variable names and their values from 
 an
  XML file and constructing variables dynamically using RenderTool.
  Tried to find in User docs but no luck.
  Can anyone pls let me know the list or point me to the link where i can 
 get
  the details.
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Valid characters for value in VTL - urgent

2005-09-20 Thread Ravikanth L
Hi Christoph,
Thanks a lot for replying back.
Its a good idea to filter/escape all suspicious characters, i will follow 
your suggestion. Anyhow i am going to vote for the bugs related to it.
 Thanks,
 With Regards,
Ravi

 On 9/19/05, Christoph Reck [EMAIL PROTECTED] wrote: 
 
 Hi Ravikanth,
 
 there is no such list of unallowed characthers in a string. Only the
 velocity syntax exists. Therefore up to Velocity 1.4, a string may not
 contain the quote character itself and a new-line character.
 Additionally you need care with the other symbols: \ $ #
 which have a meaning to velocity during string interpolation - plus
 some minor bugs (see below or look at http://issues.apache.org/jira ).
 
 With the 1.5 version coming up (nightly snapshot), to my knowledge,
 you will be able to have multi-line strings, quotes witin quoted
 strings (by doubling the quote character! - like in excel CSV exports).
 
 In your use-case you might need a filter (like a simple reg-ex
 replacing) to filter out things that make problems in velocity before
 you forward things to your render recursion, example:
 #set( $str = $theValue.replaceall(##\), $H$H)) )
 $render.recurse( $ctx, '\#set($$nameObj = $str)' )
 Maybe replace all #s altogehter , if you are not using macros or
 directives in your recursion evaluation.
 
 If you provide patches or vote on the below stated issues, there are
 chances that the 1.5 final will not choke on the ## within a string.
 (Please be aware that Apache Jakarta projects are done on a free will
 basis and contributions are welcome. People who have an itch are
 kindly asked to help on solutions.)
 
 Cheers,
 Christoph
 
 



Re: Disable echo in VTL

2006-02-07 Thread Ravikanth L
Hi,
Use as below
#foreach($elem in $rootelem.getChildren())##
   #set ($elemname = $elem.getName())##
   #set( $sometext = $userprops.get($elemname)  )##
   #set($tempVariable = $elem.setText( $sometext ))##
#end##

to ignore the return value from setText, just pretend as assigning to a
variable ( its the way i used in my templates). If anyone has a better way
to ignore such unneccesary return values from printing, pls let me know.

For unnecessary new lines, in your for loop, there will be new lines each
after a statement. So if you put ## i.e comment as EOL, it will ignore those
new lines. There are lot of bugs reported for formatting and new lines in
velocity. Please go through the forum mails for further reference.

Regards,
Ravi

On 2/7/06, Anagha [EMAIL PROTECTED] wrote:

 Hi,
 I'm building the XML in the VTL.
 At some point I retrieve the value of an element and set its text as
 $elem.setText( $sometext )

 #foreach($elem in $rootelem.getChildren())
#set ($elemname = $elem.getName())
#set( $sometext = $userprops.get($elemname)  )
$elem.setText( $sometext )

 #end

 In the output I get each element printed as --- [Element:
 serviceName/]
 where serviceName is the the element name.
 This happens for all the elements in the for loop. I want to disable this
 output on the console/file which comes from setText

 I tried :
 VelocityEngine ve = new VelocityEngine();
 ve.setProperty(VelocityEngine.VM_MESSAGES_ON, false);

 But still the elements are printed which is not desired.
 Also I get a lot of new lines in the output which I want to disable.

 Any pointers?
 --
 Thanks  Regards,
 Anagha