Re: creating a Template from a String

2005-06-30 Thread Shinobu Kawai
 Isn't the simplest way to do this to create your own resource loader?

Like this one?  ;)
  http://issues.apache.org/bugzilla/show_bug.cgi?id=20677

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Multi-dimensional arrays, velocimacros, and navigation menu lists

2005-06-30 Thread Shinobu Kawai
Hi Chris,

 Does VTL support multi-dimensional arrays (e.g. an array of arrays) and what
 would be the syntax to access values stored in them?
 
 I've been looking around (googling, Velocity user + developer guides,
 Gradecki's book) but can't seem to find anything dealing with this sort of
 thing - maybe because its not possible?

It doesn't support arrays other than in the #foreach directive, but
you can use ListTool.
  http://jakarta.apache.org/velocity/user-guide.html#Loops
  http://wiki.apache.org/jakarta-velocity/ListTool

 The reason I ask is: I want to be able to write a velocimacro to construct a
 navigation menu and add a class to a selected list item to highlight the
 current page.
 
 A sample menu in HTML might look like this:
 
 map id=menu title=Site navigation
  ul
li class=selecteda href=Menu Item 1/a/li
lia href=Menu Item 2/a
  ul class=subnav
lia href=Sub-Menu Item 1/a/li
lia href=Sub-Menu Item 2/a/li
  /ul
/li
lia href=Menu Item 3/a/li
  /ul
 /map
 
 At the top of the each page would be a velocity #set directive like this:
 #set ( $pageID = menu_item_1 )
 
 What I had in mind was writing a velocimacro which would iterate through
 each item of a supplied array, performing some kind of test (not worked out
 yet) to see whether it matches $pageID, then writing out the list items
 (with the class=selected if necessary)
 
 Any ideas or suggestions? Your help is, as always, very much appreciated.

I guess we can start with what you have now.  Doesn't seem like it
shouldn't work.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: newbie question about encoding

2005-06-30 Thread Shinobu Kawai
Hi William,

 However, there's one thing that I thought could be clearer:
 automatically escaping all HTML-sensitive characters in HTML templates.

## snip

 I'm busily writing one of these right now. If I produce something worth
 sharing, how would I go about passing it along to the right people?

The wiki would be a good place to share your stuff.  ;)
  http://wiki.apache.org/jakarta-velocity/FrontPage

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Passing Variables through velocity

2005-06-30 Thread Shinobu Kawai
Hi Jonathan,

 Hi. I'm a bit new to Velocity and Java.  I've been reading all the docs
 online, but I'm stuck at this one point.  I'm trying to pass a variable
 off from the build.xml I'm using to my site.vtl file (using the Anakia
 example).  I'm using the command line 'ant -Dfilename=getrel'.  Filename
 is the variable I have set in my build.xml and the variable I'm setting
 to getrel.  I want to be able to pass the variable off to my site.vtl
 where I can then work with it within the .vtl file for a #foreach and an
 #if statement.

I don't think there's a way to get a string into the Anakia Context,
but you might want to check out Customizing the Anakia Context.
  
http://jakarta.apache.org/velocity/anakia.html#Customizing%20the%20Anakia%20Context

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: how to generate adifferent vm from a raw vm

2005-06-30 Thread Shinobu Kawai
Hi Nagendra,

 I am using velocity . It is nice and works fine.
 I want to generate a language specific file whose extension is .vm with
 the help of languange specific properties file and using a raw vm file.
 In this case what should i do, please mention all the step which will
 following me.
 
 I have a raw vm and language specific property file. In raw vm, we use
 dynamic varriable and choose its value from language file.
 We want to make a language specifc vm in specific location with the help
 of these two files.

Sorry, but I don't quite understand what you are trying to do.  Can
you give a simple example of a raw vm file, a languange specific
properties file, and a language specifc vm?

Instinct tells me that Texen might give a clue.
  http://jakarta.apache.org/velocity/texen.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Have a strange problem

2005-06-30 Thread Shinobu Kawai
Hi Paul,

 I have developed my web app in windows using net beans 4.1 and its
 included webserver (tomcat 5.5.7).  Under the NetBeans webserver my web
 app works fine.  When I took the war file that was created by the
 NetBeans  program and placed it into my Linux Tomcat server (Tomcat
 5.0.27-9) I got a VelocityViewServlet Exception

## snip

 I think the problem is that the page is looking for my properties file
 and can't find it.  What I don't understand is how it works in one
 version of tomcat and it doesnn't in another? Any suggestions? The web
 app has to work on a 2.3 spec tomcat at least.

That puzzles me, too.  What's keeping you from running the Linux
server with Tomcat 5.5, BTW?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: velocity error page

2005-06-08 Thread Shinobu Kawai
Hi Michael,

 I've been trying to make a velocity error page but I've been having some
 troubles.  The correct velocity template gets displayed but the error
 information doesn't seem to be in the request.  For example the
 attribute ${errorData.statusCode} and/or
 ${pageContext.errorData.throwable}appear in the page literally without
 displaying their correct values.  The same page written as a jsp using
 jstl and EL works fine but I'd like to avoid using a mixed environment
 of jsp and vm.  Is there something else I have to do to pass those
 values to the template?

errorData/pageContext is a JSP thing.  It doesn't apply to general
view components.

BUT, as stated in the servlet specs (SRV 9.9.1), corresponding request
attributes are set.  You should be able to get them via the request.
  $request.getAttribute(javax.servlet.error.status_code)

It might be a nice RFE to have them easily accessible to the Context,
though.  ;)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: A way to (easily) access Velocity parser and get a list of variables/properties/methods

2005-06-08 Thread Shinobu Kawai
Hi Tim,

 I was wondering if there was an easy way of asking velocity to parse a
 template and (rather than merge it with a context) extract from its
 parse-tree a list of all the variables/properties/methods (as, say,
 strings)...  I imagine I could do this with a regexp, but would rather
 not, if velocity can do this already.

Take a look at the TemplateTool.
  
http://svn.apache.org/repos/asf/jakarta/velocity/trunk/contrib/temporary/templatetool/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: classloading

2005-06-07 Thread Shinobu Kawai
Hi max,

 I'm talking about
 
 FieldMethodizer
 RuntimeInstance
 LogManager
 ResourceManagerImpl
 ResourceLoaderFactory
 Generator

I guess you can start by filing an issue.  :)
  http://issues.apache.org/bugzilla/enter_bug.cgi?product=Velocity

 While on the subject of things that messes up J2EE/Eclipse environments.
 
 Why is so much stuff logged as WARN/ERROR in Velocity ?
 
 Like:
 ERROR: ResourceManager : unable to find resource 'VM_global_library.vm'
 in any resource loader.
 
 That should at least only be a WARN and it should be in a ResourceManager
 category so you could disable it.

Solved in the repository.
  http://issues.apache.org/bugzilla/show_bug.cgi?id=9938

 And:
 Warning! The iterative  is an Iterator in the #foreach() loop at [0,0] in
 template pojo/javaclass.vm. Because it's not resetable, if used in more
 than once, this may lead to unexpected results.
 
 Again, I undestand why this is there - but it should only be done on
 objects that is directly in the context (if at all). Printing out this
 warning
 for every iterator is simply not very usefull... e.g. printing this
 warning for a methodcall that does someList.iterator() is just noise.
 
 I removed this last one by providing my own UberSpectImpl, but it should
 not be necessary IMO.

And this one is here (not that it's fixed, though):
  http://issues.apache.org/bugzilla/show_bug.cgi?id=7975

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: classloading

2005-06-07 Thread Shinobu Kawai
Hi Steve,

 I'm having a similar problem with Velocity (1.4) being able to
 instantiate a custom resource loader [see stack trace below].
 
 Would the fix to class
ClasspathResourceLoader
 fix this problem also if applied to class:
 
 org.apache.velocity.runtime.resource.loader.ResourceLoaderFactory.getLoader
 ?

It would be great if you could try it and report it back to the list. 
And maybe submit a patch.  :)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: NullPointerException problem

2005-06-07 Thread Shinobu Kawai
Hi Paul,

 Here is the Action.java Velocity template and the properties file.  If
 anyone want's more send me your email address and I'll send you a copy
 of it.  I don't want my entire code on the web.

Ok, I have a feeling that your Struts is not loaded correctly.  Can
you check your configuration files and see if they are correct?  In
your original postings, they were not even in xml format.  :(
- web.xml
- struts-config.xml

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: NullPointerException problem

2005-06-07 Thread Shinobu Kawai
Hi Paul,

 I just checked both my web.xml and struts-conf.xml.  They both look fine
 to me but then again this is the first time I am developing a  web
 program.  I mighht not know the correct syntax.  However I am pretty
 sure that my web.xml and struts-config.xml are correct.
 
 Is there anything missing from my struts-config.xml file or my web.xml
 file that would make my webpage throw the NullPointerException?
 
 Here is an updated version of my struts-config.xml and web.xml files

AFAICT, these two don't mix.

 
 struts-conf.xml
 

## snip

 _
 web.xml
 _

## snip

init-param
  param-nameconfig/param-name
  param-value/WEB-INF/conf/struts-config.xml/param-value
/init-param

Are you sure that the Struts part is working?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: classloading

2005-06-06 Thread Shinobu Kawai
Hi max,

 Any particular reason why velocity only do Class.forName() where
 it should first look in thread context classloader and THEN do
 Class.forName() ?
 
 (it gives some issues when running in environments with changing
 classloaders, like
 J2EE and Eclipse)

Are we talking about the ClasspathResourceLoader?  Then it's fixed in
the latest repository.
  http://issues.apache.org/bugzilla/show_bug.cgi?id=22419
For the latest in the repository:
  http://cvs.apache.org/snapshots/velocity/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: NullPointerException problem

2005-06-06 Thread Shinobu Kawai
Hi Paul,

 I have written a few java files and rewrote a template to be more like a
 template rather then standard html.  When I tried to view the webpage I
 found that I have a NullPointerException.  Usually when there is a NPE
 the compiler tells me where in my code the NPE is coming from.  However
 it just starts out with
 org.apache.velocity.tools.struts.StrutsUtils.getMessageResources(StrutsUtils.java:211)

Source says, you didn't give it a ServletContext, or a ModuleConfig
could not be found.
return (MessageResources)app.getAttribute(Globals.MESSAGES_KEY +
  moduleConfig.getPrefix());

 I think the problem is that the properties file I defined is not moved
 to the classes directory when the javacode is compiled.  How do I do
 that if I am using Ant to compiule my source code?  However when I did
 move the properties file into the right directory, I still get the same
 error.  Oh yeah this happens on all velocity  pages that I  created
 before  I changed the code.
 
 If you need to see the entire error please let me know and I will
 provide it.

I think it would.  Better yet, you could show us some minimal code to
reproduce your problem.  ;)

As for the Ant question, the Ant User List would be a better place to ask.
  http://ant.apache.org/mail.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Quick question about properties files

2005-06-06 Thread Shinobu Kawai
Hi Paul,

 I am trying to fiure out why I am getting a Null Pointer Exception when
 I  try to view any Velocity pages.  The exception comes from the
 velocity tools packages.  I was looking at the web.xml file in the
 velstruts.war  (app1) and I found a init-param for a properties file.
 So my question is do I have to add a parameter for my properties file?

Only if you want to override the properties.
  
http://jakarta.apache.org/velocity/tools/view/index.html#Velocity%20Configuration
  
http://jakarta.apache.org/velocity/developer-guide.html#Velocity%20Configuration%20Keys%20and%20Values

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: compare float?

2005-06-06 Thread Shinobu Kawai
Hi Nick,

 1) We have been using velocity 1.3.1-rc2 and have a requirement where we
 need to compare floats in velocity templates.  So we need to do
 something like
 
  #set($afloat=$floatObject.gpa)
 
  #set($gpaWarning = 2.7)
 
  #if ($afloat = $gpaWarning)
 
 academic probation letter
 
 
 
 Can this be done in 1.5-dev?  If we need to put the gpaWarning value
 into context, we can do that if it cannot be declared in the template.
 Is that needed?

Yes it can, so no it's not.  As an alternative, you can create a
$floatObject.isGpaUnderWarningValue() method.  :)

 2) We have quite a bit of code that depends on 1.3.1-rc2, is 1.5-dev in
 a stable state?

The developers are trying their best to keep the code base working.  I
would trust it, but it's up to you to decide.

 3) What is the URL to get the Velocity 1.5-dev version?

http://cvs.apache.org/snapshots/velocity/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: handling -ve currency in $number.format('currency',$myNumber) in velocity templates

2005-06-03 Thread Shinobu Kawai
Hi Kailash,

  If I use the  $number.format('currency',$myNumber) for a -ve number,
  the output becomes ($number)
 
  $myNumber - -13.55
  $number.format('currency',$myNumber)-  ( $13.55)
 
  How to show with -ve sign  without parenthesis bracket after
 formatting?

I'm not sure what a -ve sign is, but you can give NumberTool a
custom format like this:
  $number.format('$0.00',$myNumber)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Having trouble moving between velocity pages with struts

2005-06-02 Thread Shinobu Kawai
Hi Paul,

 Here it is,  I am developing a small program  that utilizes Struts, Java
 and Apache Velocity Templates.  I am trying to move from one page to
 another via struts.  Every time I try to move to another page I get a
 404 Error in Tomcat.  Here is my struts-conf.xml file as well as my
 web.xml file.  Could someone please tell me what is wrng with it.

How are you setting the URL in your template?  The output is likely an
invalid URL.  What does the URL in your output page look like?

Also, what versions of Struts and VelocityTools are you using?  For
Struts 1.2, you should use VelocityTools 1.2, which is still under
development.  You can get nightly snapshots here:
  http://cvs.apache.org/snapshots/velocity-tools/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: SEVERE: Error deploying web application archive simple.war

2005-06-02 Thread Shinobu Kawai
Hi Bob,

 I have just built velocity-tools-1.1 and I copied
 simple.war into jakarta-tomcat-5.5.9/webapps/. When I
 start up the server, I can see on the console:

I got an OutOfMemoryError.  :(
Looks like commons-logging is part of the cause.  It works if you
remove the commons-logging.properties from the classes directory.
## Need to look furthur into this...

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: SEVERE: Error deploying web application archive simple.war

2005-06-02 Thread Shinobu Kawai
 I got an OutOfMemoryError.  :(
 Looks like commons-logging is part of the cause.  It works if you
 remove the commons-logging.properties from the classes directory.
 ## Need to look furthur into this...

1. VVS sets Velocity to output logs to the Servlet logger
2. commons-logging.properties sets logs to commons-logging to be
handled by Velocity.  (This was meant for logs by commons-digester.)

And I guess that Tomcat outputs Servlet logs using commons-logging. 
(Haven't checked that, though.)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: velocity.properties documentation

2005-05-27 Thread Shinobu Kawai
Hi lane,

 Please point me in the direction of the velocity.properties documentation
 (i.e. what properties can be defined, and what effect it has).

Try the developer guide.
  
http://jakarta.apache.org/velocity/developer-guide.html#Velocity%20Configuration%20Keys%20and%20Values

 I'm trying to move my .vm files to a protected folder, but tomcat complains
 Can't find resource unless I put the full path in the #parse statement.

And maybe the WebappLoader as well.  :)
  
http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/view/servlet/WebappLoader.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Velocity doesn't work with Tomcat

2005-05-26 Thread Shinobu Kawai
Hi Song,

 I'm using Tomcat 5. I did:

## snip

 But it doesn't work: 404. What am I missing here? Thx.

I suggest taking a look at VelocityTools.  It's the now-preferred way
to use Velocity in a web application.
  http://jakarta.apache.org/velocity/tools/view/index.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: IteratorTool question

2005-05-25 Thread Shinobu Kawai
Hi JohnE,

 In the end I did it the long term correct way.  I did the wise, extra 
 programming that would only return the 30 records I require to the request.

Depending on what you want to do, the AbstractPagerTool might be of use.
  
http://svn.apache.org/repos/asf/jakarta/velocity-tools/trunk/src/java/org/apache/velocity/tools/view/tools/AbstractPagerTool.java

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



VelocityAndSpringTips

2005-05-24 Thread Shinobu Kawai
Hi guys,

I created a wiki page to gather tips on using Velocity with Spring.
  http://wiki.apache.org/jakarta-velocity/VelocityAndSpringTips

Everyone using Spring, it'll be great if we can share our tips!

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: VelocityAndSpringTips

2005-05-24 Thread Shinobu Kawai
Hi Charlie,

 I'm not 100% sure from looking at the site...  Are the patches to
 both the VelocityToolboxView and VelocityLayoutView in Spring 1.2?

They were made against the CVS HEAD, but it should work for 1.2.
## The original patches were for 1.2rc2.  I wanted to make the old
ones invalid, but don't know if I can...

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Re[4]: Custom Resource Loader

2005-05-24 Thread Shinobu Kawai
## remembered an old posting...

 I'm wondering how we might leverage the two pieces (Spring and Toolbox) so
 that Spring can add pre-wired objects into the VContext.

Any solutions yet?  I'm all ears.  :)

And here's a great place to put it:
   http://wiki.apache.org/jakarta-velocity/VelocityAndSpringTips

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Error in User Guide?

2005-05-23 Thread Shinobu Kawai
Hi Cefn,

 In the User Guide I find the following surprising comment in example
 code...
 
 $sisyphus.pushRock()
 ## Velocity assumes I mean $sisyphus.getRock()
 
 ...is Velocity really capable of doing such an imprecise translation?
 Or am I missing something?

Very misleading comment.  if I write $sisyphus.rock should follow. 
ie. you need to spell out the method name if it doesn't respond to the
JavaBean contract.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: IteratorTool question

2005-05-23 Thread Shinobu Kawai
Hi JohnE,

 I am wondering if you can help me with a looping question.  I looked through 
 the user forum and found a good example by Shinobu.  In trying to duplicate 
 it, I am getting odd results.   My use is below:
 
  #set ($wrapper = $iteratorWrap.wrap($largeCollectionOfStuff))
  #foreach ($item in $wrapper)
#if ($velocityCount = $endingRecord)
  $wrapper.stop()
#elseif ($velocityCount = $beginningRecord)
   $item.toString()
#end
  #end
 
 This seems pretty straight forward, but using it as such only causes one item 
 to print out once.  It only executes the foreach once.
 
 When I place $wrapper.more() before the last #end, it causes it to cycle 
 through all of the records but it also causes the records to print out.  I do 
 not want a print out.

more() needs to be called in order to go forward.  You can do something like
  #set($garbage = $wrapper.more())
to not print the result.  But maybe a wantMore() will be a good RFE.  ;)

 Also I am wondering how a continue might be handled.   I am not very sure 
 how velocity parsing would be handled if it has to parse to the last #end on 
 each loop when the #end can be past lots of logic.I would think having 
 not just a #stop (aka break) would be useful, but a #continue.

Actually, #stop stops Velocity, not just #foreach.  Using #if is the
only solution for a continue that I can think of right now.
  http://jakarta.apache.org/velocity/user-guide.html#Stop

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Getting the key out of a Hashtable

2005-05-23 Thread Shinobu Kawai
Hi Jack,

 I have Spring Web Flow with which I'm using Velocity.  I am using a
 Hashtable to pass info to the Velocity template and can successfully
 get the value side of each entry using code like this ($routeList is
 the Hashtable):
 
 #foreach($route in $routeList)
  $route
 #end
 
 How would I get the key of each entry?
 
 Do I need to use a Vector of Vectors instead perhaps?  What would you suggest?

How about reading the FAQ?  ;)
  http://wiki.apache.org/jakarta-velocity/VelocityFAQ

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Velocity and Spring - Step by Step

2005-05-19 Thread Shinobu Kawai
Hi,

 I posted a page with supplemental information for using Velocity in
 the step-by-step article for Spring.
  http://wiki.apache.org/jakarta-velocity/VelocityAndSpringStepByStep

I fixed the TODO, erasing the dependency to VelocityViewServlet.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: can't get the strutslinktool to work.

2005-05-19 Thread Shinobu Kawai
Hi Marc,

 I have just started playing with velocity and struts.
 
 But got a problem with the setAction in strutslinktool. Every time I try
 to use it just fills in blanks. That be in a link or in a form. Just BLANK.
 
 I can use the  setForward just fin.
 
 Any ideas?

Which versions of Struts/VelocityTools are you using?  For Struts 1.2,
you need VelocityTools 1.2, which is still under development.
   http://cvs.apache.org/snapshots/velocity-tools/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Velocity and Spring - Step by Step

2005-05-18 Thread Shinobu Kawai
Hi all,

I posted a page with supplemental information for using Velocity in
the step-by-step article for Spring.
  http://wiki.apache.org/jakarta-velocity/VelocityAndSpringStepByStep

cf. The original article Developing a Spring Framework MVC
application step-by-step by Thomas Risberg.
  
http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html

Any comments welcome.  :)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: poroblem with linefeed in velocity templates

2005-05-18 Thread Shinobu Kawai
Hi Mike,

 But now after changes to
 
 textfield_one:#if($ref_variable_one != ) $ref_variable_one #end
 textfield_two:#if($ref_variable_two != ) $ref_variable_two #end
 
 textfield_three:  #if($ref_variable_three != ) $ref_variable_three
 #end
 textfield_four:#if($ref_variable_four != ) $ref_variable_four #end
 
 it will be render to:
 
 textfield_one:one textfield_two:two
 textfield_three:  three textfield_four:four
 
 Did anyone know a solution for this problem?

Another case of VelocityWhitespaceGobbling.
  http://jakarta.apache.org/velocity/user-guide.html#VTL:%20Formatting%20Issues
  http://wiki.apache.org/jakarta-velocity/VelocityWhitespaceGobbling

One thing you can do, is add a line feed before the #end.

textfield_one:#if($ref_variable_one != ) $ref_variable_one
#end
textfield_two:#if($ref_variable_two != ) $ref_variable_two
#end

textfield_three:  #if($ref_variable_three != ) $ref_variable_three
#end
textfield_four:#if($ref_variable_four != ) $ref_variable_four
#end

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: A couple of wording suggestions

2005-05-18 Thread Shinobu Kawai
Hi Richard,

 I do have a couple of suggestions for slight wording changes where the
 language doesn't sound right (from a UK English point of view, at
 least):
 
 1) In the Velocimacros section, there is a sentence that ends: ...but
 when the Velocimacro is invoked, it must be called with the same number
 of arguments with which it was defined.  I'm not sure that's
 grammatically correct, and a colleague of mine suggests changing the end
 to: ...same number of arguments as in its definition.  I had
 considered simply inserting as before the final with as an
 alternative, but that may be a little cumbersome.
 
 2) In the Case Substitution section, there is a sentence ending: ...its
 developers have strove to catch and correct user errors wherever
 possible.  We believe have strove is incorrect and should either
 simply be strove (i.e., removing the have; though that does change
 the tense) or more likely should be have striven.

I'm no master of English, but maybe you could file this in the
bugzilla so it doesn't get forgotten.  :)
  
http://issues.apache.org/bugzilla/enter_bug.cgi?product=Velocitycomponent=Documentation

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Need inline map creation badly

2005-05-13 Thread Shinobu Kawai
Hi Geir,

 Why doesn't it work?  it should have been in there a while ago...

I've updated the bugzilla entry with details.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33113

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Passing data into a Velocity Template from a Spring Controller

2005-05-13 Thread Shinobu Kawai
TWIMC,

 1) follow the Spring mvc tutorial (which makes it happen for jsps) and
 then modify it for velocity (basically just by changing your view
 resolver as per the ch 13 (views) of the spring ref.)
 http://www.springframework.org/docs/MVC-step-by-step/Spring-MVC-step-by-step.html

I just started creating a supplemental document for Velocity here:
   http://wiki.apache.org/jakarta-velocity/VelocityAndSpringStepByStep

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Help using velocity tools

2005-05-13 Thread Shinobu Kawai
Hi Wayne,

 I need to be able to do some date processing in my macros, I saw the
 velocitytools stuff and it will do what I need, but how do I access/use
 the tools in my macros?

Just put it in the Context.
   http://jakarta.apache.org/velocity/developer-guide.html#The%20Context

Or if you're using VelocityViewServlet, put it in the toolbox.xml.
   
http://jakarta.apache.org/velocity/tools/view/index.html#Toolbox%20Configuration

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Need inline map creation badly

2005-05-12 Thread Shinobu Kawai
Hi Adam,

 I am using the 1.5-dev, 20050411105406 snapshot. It doesn't have it. I
 need it, but I don't really have time to fix it. The bug is here
 http://issues.apache.org/bugzilla/show_bug.cgi?id=33113
 
 I will pay $100, by way of paypal, to the first person to make it
 work. I presume you will need to give the patch to the development
 team, who will likely require unit tests.

Wow, that's a lot of money!  I'll show you a work-around for 2 cents.  ;)

Say, you wanted to do this:
  $dohickey.acceptMap({foo : bar, hoge : moge})
Instead, do this:
  #set($mapForDohickey = {foo : bar, hoge : moge})
  $dohickey.acceptMap($mapForDohickey)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: deployment of applet class

2005-05-12 Thread Shinobu Kawai
Hi Jill,

 1. applet class without package

## snip

But in this way, it really slowed down the process of drawing a
 graph.  It seems it will load the applet forever.

Depending on the environment, I think the browser will cache the jars,
making it faster to load from the second time.

 2. applet with package
I build a applet class with package. and then place it into a
 corresponding folder in WEB-INF/classes/
Such  applet tag in a velocity template will not work anymore:
 
table cellpadding=0 cellspacing=0 border=0 width=808
APPLET CODEBASE='$content.getURI
  (WEB-INF/classes/com/correspondingclassfolder/)'
  code = 'CustomObject.class'  WIDTH = 300 HEIGHT = 300
/APPLET
 
/table
It will be such 'ClassNoFound' error.
 So, my bottom line question is how to integrate applet class into the
 velocity page, where to put it.

Applets are client-side technology.  So it will not have access to the
unexposed WEB-INF directory.  I suggest you put what is needed by the
applet in a jar and refer to it with the archive attribute like in
1.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: applet

2005-05-09 Thread Shinobu Kawai
Hi jill,

 I moved Star.class to the folder where the template sits. And change the
 applet tag to
 
 table cellpadding=0 cellspacing=0 border=0 width=808
 APPLET CODE='Star.class' WIDTH = 300 HEIGHT = 300  /APPLET
 /table
 
 The message from Jave Console is like:

## snip

 java.lang.ClassFormatError: Star (Bad magic number)

Something definitely messed up your class file.
  http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassFormatError.html

I suggest that you first test your applet without Velocity, and move
on to Velocity once you get it working.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: cactus and velocity

2005-05-09 Thread Shinobu Kawai
Hi Rob,

 I want to use Cactus to test some filters that are mapped to velocity pages.
 
 It is working for the most part. The problem is in the endXXX methods
 and the WebResponse object (both Cactus default and HttpUnit). They
 never return any text -- using webResponse.getText() is always empty.
 The WebResponse object does return the status code as 200 and that the
 response contentType as correct (text/html).
 
 Are there any tricks to get the response to include the velocity
 rendered page?

Can you provide some code snippet that reproduces the problem?
## A few whiles ago, I think there was a thread about Cactus not
working on a not-so-well-configured VelocityViewServlet...

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: cactus and velocity

2005-05-09 Thread Shinobu Kawai
  Are there any tricks to get the response to include the velocity
  rendered page?
 
 Can you provide some code snippet that reproduces the problem?

I just tried out Cactus and it worked fine for me.  Other than the
usual web.xml for web applications, I posted my sample test code on
the wiki.
   http://wiki.apache.org/jakarta-velocity/TestingVelocity

Hope that helps.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Ifnotnull

2005-05-06 Thread Shinobu Kawai
Hi jeichels,

 I had previously upgraded to 1.5-dev and things are working well with the one 
 email templating thing I had found help here on.
 
 Since the upgrade, however, I seem to be getting some RHS of #set statement 
 is null. things i don't remember getting before.
 
 I explored a bit and found:  
 http://wiki.apache.org/jakarta-velocity/CheckingForNull
 
 I added these to my velocity property file:
   userdirective = org.apache.velocity.tools.generic.directive.Ifnull
   userdirective = org.apache.velocity.tools.generic.directive.Ifnotnull

## Wow!  First person I've heard using it!

 And changed my template code as follows:
 #ifnotnull( $form )
 #set ($attr = $form.getBean())
 #end
 
 And get this error:
 
 Encountered #end\r\n at line 3, column 1. Was expecting one of: ( ... ... 
 ... ...  ... \\ ... ... ... *# ... *# ... ... ... ... ... ... ... 
 ... ... ... ... { ... } ...
 
 org.apache.velocity.exception.ParseErrorException: Encountered #end\r\n at 
 line 3, column 1.

The error suggests that you aren't configuring the directive
correctly.  Have you added it to your codebase/classpath?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Problems with Overloaded Methods

2005-05-06 Thread Shinobu Kawai
Hi Tim,

 I noticed that Attila Szegedi (from 2002 - see
 http://mail-archives.apache.org/mod_mbox/jakarta-velocity-dev/200203.mbox/[EMAIL
  PROTECTED]).
 was offering to change the (then) current velocity mechanism for
 introspecting the correct overload so it matched the JLS mechanism...
 Did this ever happen?

Looks like it was reflected on SVN revision 75625.  So yours might be
another problem.

http://svn.apache.org/viewcvs.cgi/jakarta/velocity/trunk/src/java/org/apache/velocity/util/introspection/MethodMap.java?rev=75625view=log

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Problems with Overloaded Methods

2005-05-06 Thread Shinobu Kawai
Hi Tim,

  I noticed that Attila Szegedi (from 2002 - see
  http://mail-archives.apache.org/mod_mbox/jakarta-velocity-dev/200203.mbox/[EMAIL
   PROTECTED]).
  was offering to change the (then) current velocity mechanism for
  introspecting the correct overload so it matched the JLS mechanism...
  Did this ever happen?
 
 Looks like it was reflected on SVN revision 75625.  So yours might be
 another problem.

I just tried a few, but it works for me.  Could you give an example of
the failing code?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Ifnotnull

2005-05-06 Thread Shinobu Kawai
Hi JohnE,

 I like velocity very much, but I do not like its handling of null in general. 
  I do not want to have to put a isNull check into every object being checked. 
  This at least seems a somewhat straight forward directive.   I am not sure 
 how efficient it is in comparison to the other methods of checking and 
 efficiency is important always.

Performance never bugged me, but any benchmarks results are welcome.  :)

 In terms of configuring,  I have very recent Velocity and Velocity Tools from 
 Subversion.  Besides that, all I did was do what the link directed me to do 
 which was to put in those two properties in the velocity.properties file.
 
 Should I do something else?  If so maybe the document should be updated?

You need to actually compile the directive and put it in your class
path.  It's not part of VelocityTools.
  http://wiki.apache.org/jakarta-velocity/IfNullDirective
  http://wiki.apache.org/jakarta-velocity/IfNotNullDirective

 Also maybe you can mention something on performance and whether this is a 
 good way to go about it all.  There were like five ways mentioned.

As I said, performance never bugged me, but my otherwise comments are
written in the Note:s for each approach.  In your case, I think
approach #1 might do best.
  #if( $form )
#set ($attr = $form.getBean())
  #end

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Testing Velocity with JUnit.

2005-05-06 Thread Shinobu Kawai
Hi all,

My server has been down for like half an year, so I decided to put all
this in the wiki:
http://wiki.apache.org/jakarta-velocity/TestingVelocity

On 11/9/04, Shinobu Kawai [EMAIL PROTECTED] wrote:
 Hi all,
 
 I'd like to share how I've been testing Velocity with JUnit lately.
 
 First, I made a base TestCase class, AbstractVelocityTestCase.
 
 http://sylow.no-ip.com/maven/site/ShinobuDemo/xref/org/ieee/shinobu/demo/velocity/AbstractVelocityTestCase.html
 This class has the properties needed to test VTL:
 - engine : The VelocityEngine to use for template processing.
 - template : The VTL String to process.
 - context : The Context to use when processing the template.
 - expected : The expected result String.
 
 After configuring these properties, I call assertVelocity(), which
 will process the template and compare it with the expected result.
 PublicFieldUberspectTest shows an example of the general flow.
  
 http://sylow.no-ip.com/maven/site/ShinobuDemo/xref-test/org/apache/velocity/tools/generic/introspection/PublicFieldUberspectTest.html
 
 Many other example tests can be found at:
  
 http://sylow.no-ip.com/maven/site/ShinobuDemo/xref-test/org/ieee/shinobu/demo/velocity/package-summary.html
 
 For testing ViewTools, I have made AbstractVelocityMockStrutsTestCase
 which uses strutstestcase.
  
 http://sylow.no-ip.com/maven/site/ShinobuDemo/xref/org/ieee/shinobu/demo/velocity/AbstractVelocityMockStrutsTestCase.html
 cf. http://strutstestcase.sourceforge.net/
 The flow of testing remains the same.
 
 As always, any comments are welcome.  :)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: List of variables from template

2005-05-03 Thread Shinobu Kawai
Hi Jerry,

 I'm looking for a way to get a list of the variables referenced in a
 template.  I found a message titled List of variables present in template?
 http://mail-archives.apache.org/mod_mbox/jakarta-velocity-user/200111.mbox/[EMAIL
  PROTECTED]
 with a comment from Geir Magnusson Jr. (I believe, hard to follow the
 's) saying he was going to work on implementing this, but I can't
 find more information on if this was done.

Probably this:

http://svn.apache.org/repos/asf/jakarta/velocity/trunk/contrib/temporary/templatetool/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Junit and Debugging of Velocity Templates

2005-05-02 Thread Shinobu Kawai
Hi Llewellyn,

 I would like to know which flag to set so when I run my junit tests
 
 #parse (fileWithErrorInIt)
 
 $real.unknownfield.call()
 
 #if ($real.unknowfield())  #end
 
 $real.returnsNull().doSomething()
 
 will all throw errors so my test will fail and I can realize I did something 
 stupid.

You should be able to use a customary Introspector.  See the
Pluggable Introspection here:

http://jakarta.apache.org/velocity/developer-guide.html#Velocity%20Configuration%20Keys%20and%20Values

But instead of doing all those tricky stuff, I suggest you read JUnit
Recipes by J. B. Rainsberger.  There is a nice recipe for testing
Velocity templates.
http://www.amazon.com/exec/obidos/tg/detail/-/1932394230

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: byte order mark and InputStreamReader problem

2005-05-02 Thread Shinobu Kawai
Hi Jian,

 I created a template in UTF8 encoding on my windows machine. When I
 rendered it on the web, the browser connected to the server fine but
 then it waited infinitely.
 
 I then modified the problematic template and got rid of the byte order
 mark (BOM) at the very beginning of the template. This time, the page
 loaded  successfully in the browser.
 
 What I am getting at is, Velocity uses java.io.InputStreamReader, and
 given UTF8 encoding, the InputStreamReader does not handle the byte
 order mark.
 
 I also read somewhere that this problem of not able to handle BOM  has
 been a long standing bug with JDK implementation.
 
 Now, just want to know you guys idea if Velocity should be hacked to
 use a custom-made InputStreamReader that could open the file, detect
 the encoding, and discard the byte order mark, if applicable.

Currently, there's a ResourceLoader which handles this issue up on bugzilla.
http://issues.apache.org/bugzilla/show_bug.cgi?id=21582

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: byte order mark and InputStreamReader problem

2005-05-02 Thread Shinobu Kawai
Hi,

 It is bad that SUN never bothers to fix the InputStreamReader BOM issue.

Everybody interested, let's vote for it.  ;)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: #cparse

2005-04-29 Thread Shinobu Kawai
Hi,

 Can you let us know which version of Velocity Tools you're using? I
 suspect this precise method wouldn't work with the latest dev version as
 it no longer uses the Velocity Singleton.

I also put it on the FAQ, but the ViewRenderTool implementation should
give an idea of how to do it.
http://wiki.apache.org/jakarta-velocity/VelocityFAQ

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: How to use Map ?

2005-04-29 Thread Shinobu Kawai
Hi Bertrand,

 I ve got some problem to use the map or associative table, my LOC is
 
 #set ($tableauCouleur= {2 : [Rouge, RougeSel, #BF5726, #EA9066
 ]})
 
 And Velocity indicates a Lexical Error  from the parser ...
 
 I m using the velocity 1.3.

The map feature is available only from Velocity 1.5.  You can get
1.5-dev (still under development) here:
http://jakarta.apache.org/velocity/install.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: how to set null value

2005-04-29 Thread Shinobu Kawai
Hi Jian,

 Thanks for sending me the useful information. After much
 investigation, I plan to do the following hack for setting null value
 in the context:
 
 1) In the ASTSetDirective, in the render method, comment out the if block
if ( value  == null)
{
  
 Basically, this will allow the set null process to go ahread.
 
 2) in the AbstractContext, remove the key from the context if the
 value to be set is null:
 
else if (value == null)
{
this.internalRemove(key);
return null;
}
 
 So, this should remove the variable in the context if it is assigned a
 null value,

I believe so.

 and it will be consistent with future release in Velocity,
 right?

Can't be sure about that.  The community has not yet reached consensus
on what to do with this issue.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: #cparse

2005-04-27 Thread Shinobu Kawai
Hi Chris,

 Hi Shinobu - thanks again for your help and my apologies for my java
 ignorance! (RTFM, as they say ;D )

:)

 I have added the cparse macro to VM_global_library.vm and added the
 necessary entry to the toolbox.xml, as described in the maillist archive URL
 below.

## snip

 However, the #cparse instruction is not working for some reason which I am
 unable to diagnose so far :(
 
 Being new to Java and Velocity, I'm probably missing something very obvious!
 
 If anyone can tell me what I am doing wrong, I would be extremely grateful.

We're going to need a bit more information before we can help you. 
Minimal information needed to reproduce your problem, and description
of HOW it is not working.

As you are new to this world, I suggest going through bit by bit. 
Deploying the example webapp in VelocityTools is a good place to start
for Velocity.
http://jakarta.apache.org/velocity/tools/view/index.html#Examples

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: out of memory error using GZIPOutputStream

2005-04-27 Thread Shinobu Kawai
Hi Jian,

 I have the following GZIPOutputStream on top of the servlet response
 outputstrream to render the html to the browser.
 
 String encodings = req.getHeader(Accept-Encoding);
 if (encodings != null  encodings.indexOf(gzip) != -1) // GZIP
 {
resp.setHeader(Content-Encoding, gzip);
GZIPOutputStream gos = new GZIPOutputStream(resp.getOutputStream());
OutputStreamWriter out = new OutputStreamWriter(gos, UTF8);
evaluate(template, ctx, out);
out.flush();
gos.finish();
 }
 else // No compression
 {
resp.setCharacterEncoding(UTF8);
evaluate(template, ctx, resp.getWriter());
 }

## Are you sure the flush() and finish() should be in that order?

 So, when the velocity template page is huge, then, I get a out of memory 
 error.
 
 Also, this only happens when the server uses GZIPOutputStream (i.e,
 the browser accepts GZIP). If I comment out the if () block so to use
 no compression, the response is streamed back to the browser and there
 is no problem.
 
 Any ideas?

Will it fail on the first time?  If not, maybe you aren't releasing
some resources.

Does increasing your memory solve your problem?  If not, maybe there's
something wrong with GOS (like an infinite loop).

I suggest running it on a profiler and see who's taking up all that memory.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: how to set null value

2005-04-27 Thread Shinobu Kawai
Hi Jian,

 I know this has been talked about and I wanted to search for a
 solution from past emails. However, the Velocity site does not provide
 the search capability anymore. Anyway.

It has been talked about so much, it has its own page on the Wiki.  ;)
http://wiki.apache.org/jakarta-velocity/VelocityNullSupport

 BTW,  I am a big fan of search engine technologies, and am interested
 in providing search capability to Velocity mailing list.

I wonder what happened to it?  You can try this:
http://www.google.com/search?q=velocity+site:mail-archives.apache.org

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: #cparse

2005-04-26 Thread Shinobu Kawai
Hi Christopher,

 Hi - I posted yesterday with a problem about getting velocity up and
 running. I'm pleased to say that I got a really helpful response and
 velocity is now up and running!

Good to hear your progress!  :)

 So, I have one more question: I would like to use the #cparse (silent parse)
 command which is described here:
 http://mail-archives.apache.org/mod_mbox/jakarta-velocity-user/200406.mbox/%
 [EMAIL PROTECTED]
 
 I understand the bit about adding to toolbox.xml, but what do I have to do
 with the other bits of code described there (concerning package and macro)?

The package can be anything you want.  As for the macros, check out
the user guide.  VM_global_library.vm should be a good place to put
it.
http://jakarta.apache.org/velocity/user-guide.html#Velocimacros

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: velocity config.getInitParameter()

2005-04-25 Thread Shinobu Kawai
Hi Andrew,

 I'm having some trouble getting a  Velocity Servlet to read an init-param
 from tomcat. So far i've tried the following:
 
 public class SiteStructure extends VelocityServlet{

First, I suggest using VelocityViewServlet, as VelocityServlet is
deprecated and will be removed in future versions.
http://jakarta.apache.org/velocity/tools/view/index.html

  private String base_dir = null;
 
 protected Properties loadConfiguration(ServletConfig config) throws
 IOException,FileNotFoundException{
 
 ...
 String path = config.getServletContext().getRealPath(/);
 this.base_dir = config.getInitParameter(basedir);
 
   ...
 }
 
 in my web.xml file i've tried these two options, although not at the same
 time.
 
  init-param
param-namebasedir/param-name
param-valuetest/param-value
   /init-param
 
   context-param
param-namebasedir/param-name
param-valuetest/param-value
/context-param
 
 Its probably quite simple but i've looked all through both my tomcat books and
 velocity books and i can't see any  examples of this being done. The velocity
 docs say that the loadConfiguration() is called from init(), which is where
 all of the Tomcat servlet examples have called the getInitParameter() method
 from.

I don't see anything wrong so far, but I can't tell until I see all
the relevant code.  Does it work with a regular servlet?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: How to tell the difference of the similar template engine crew?

2005-04-25 Thread Shinobu Kawai
Hi Sam,

 I found a lot of different kinds of template engines out there. They are
 StringTemplate from SabbleCC, FreeMarker, JByte, Jamon. They seems to serve
 the same goal with different forms of capabilities. I wonder how to tell the
 difference and use them properly in different situations. Thanks!

You can check out the Comparisons section in the Velocity document for
stuff about Velocity and JSP/WebMacro/XMLC.
http://jakarta.apache.org/velocity/

My best advice is to check them all out yourself.  Each product should
have some kind of sample.  I think your opinion is more important to
you than anyone else's.  And nobody is going to stop you from writing
a report with a neat matrix on the wiki page.  ;)
http://wiki.apache.org/jakarta-velocity/FrontPage

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: How to tell the difference of the similar template engine crew?

2005-04-25 Thread Shinobu Kawai
Hi Andrew,

 I've had a look at the API for the VelocityViewServlet. I've just finished
 writing a set of Servlets that use the VelocityServlet. Is it advisable to
 re-do these based on the VelocityViewServlet now?

I like VVS because I don't have to subclass it or anything in order to
make it work.  It makes it so simple to use Velocity as the view layer
(like JSP).  But of course, that's only MY opinion.  ;)

 Also when the next version
 of Velocity comes out, will i have to then change these source files to use
 org.apache.velocity.servlet.VelocityVeiwServlet or will it keep its existing
 package name?

 Will there be any actual requirement to upgrade velocity, or any advantages to
 doing so? 1.4 is very very good IMHO and is by far the best templating
 solution i've seen.

If it's keeping you satisfied, I say let it stay.  These are some of
the features coming up on 1.5.
http://jakarta.apache.org/velocity/changes.html
If you think any one them is cool, there's your reason for considering
an upgrade.  The Velocity developers are also trying their best to
keep upgrades backward compatible.  (In the scope of 1.x, of course.)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Help! Simple velocity 1.4 setup with Tomcat 5.5.9

2005-04-25 Thread Shinobu Kawai
Hi Christopher,

 - The problem:
 I need to set up Velocity 1.4 to run under Tomcat 5.5.9 in order to
 replicate certain templating facilities available on our (somewhat
 unreliable) staging server on my local development machine.

## snip

 - The question:
 Does anyone out there know of a good idiots guide to getting
 tomcat+velocity up and running?

Inside your VelocityTools download, there are a couple war files. 
Just deploy and enjoy.  :)

 Can anyone tell me what the basic steps are to get velocity handling #parse
 and #include instructions in .html files?

Now that's something new.  Are you sure you don't want all the other
goodies Velocity has to offer?
http://jakarta.apache.org/velocity/user-guide.html

It is by all means possible to map html files to Velocity.  Just
change/add the servlet-mapping settings.
http://jakarta.apache.org/velocity/tools/view/index.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Velocity security

2005-04-22 Thread Shinobu Kawai
Hi Tony,

 Thanks for the tips. The main security concern that I have is for an end
 user who enters an arbitrary file to the #parse directive. I'm not sure if
 this concern is substantiated, but I'll assume it is until proven otherwise.

Will's article offers some solutions for this.  :)

 I have an old JSP application lying around that I thought I'd convert to
 Velocity just to get up to speed. However, while JSP has tag libraries that
 allow execution of Java, Velocity seems to lack this ability (and rightly so
 according to its design intention). Consider a JSP taglib that encodes a URL
 using java.net.URLEncoder.encode: t:url encode=/blah blah/ What is the
 equivalent scenario for Velocity? Do I create a macro? Does such a macro
 already exist?

You are looking for tools.  By putting POJOs in the Context, all the
public methods will be available in the templates.
http://jakarta.apache.org/velocity/tools/index.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Next Release 1.5 ??

2005-04-21 Thread Shinobu Kawai
Hi Harald,

 I´m waiting for the next release (R1.5). Is there a release roadmap
 available. The current version 1.4 include some bugs which I really wish get
 rid of. Some of them are covered in 1.5 dev. When is a new release (or
 release candidate) available?

Check out answers in a recent thread.  :)

http://mail-archives.apache.org/mod_mbox/jakarta-velocity-user/200504.mbox/[EMAIL
 PROTECTED]

Basically, there's no current plan, but you can sure help by submitting patches.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Velocity security

2005-04-21 Thread Shinobu Kawai
Hi Tony,

 I had a bit of a fiddle with Velocity a while back, and I'm considering
 using it in a J2EE project that is coming up. A requirement that I have is
 that users should be able to submit their preferred format for rendering of
 their web page, for which I thought Velocity would be entirely appropriate.

:)

 The issue I have is security-related. I had a look through the Velocity user
 guide and the only real potential hole that I see is the use of the #parse
 or #include directive. I shouldn't expect users will use this, but I need to
 protect against it nonetheless (are there any other potential holes that I
 can't see?).

I'll let you answer what risks you are considering to Malcolm.  ;)

 The user document talks about the 'TEMPLATE_ROOT' (what is that
 exactly?) being the only place from which the referenced files can be
 included/parsed,

The so-called 'TEMPLATE_ROOT' refers to wherever the ResourceLoader
looks for templates.  It will depend on how you configure Velocity.
http://jakarta.apache.org/velocity/developer-guide.html#FAQ2

eg, if you use VelocityViewServlet, it will be the root directory of
your webapp.
http://jakarta.apache.org/velocity/tools/view/index.html

I guess you could subclass VVS in VelocityTools 1.2-dev and create a
one-VelocityEngine-per-user servlet to handle your requests.

 but I'm wondering if Velocity provides something to solve
 what I believe would be a common problem, perhaps by preventing
 include/parse directives altogether - or perhaps some unforeseen solution
 that is more wll suited.

I think there was a thread before about disabling directives.

Some more security issues are mentioned here:
http://wiki.apache.org/jakarta-velocity/HackingVelocity

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: comparing long values

2005-04-20 Thread Shinobu Kawai
Hi Paul,

 If I have the following code in a velocity template:
 
 #if($myNumber  0) yes # else no #end
 
 If $myNumber is an Integer, it works, but if it is a Long, it doesn't.
 Is there any way to check if a Long is greater or less than an int?

Long arithmetic will be available from 1.5.  Which you need to get
from the nightly snapshots or build it from source.
http://jakarta.apache.org/velocity/install.html

As a 1.4 solution, (haven't tried, but) you might be able to use compareTo.
#if($myNumber.compareTo(0)  0) yes # else no #end

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: ResourceNotFoundException

2005-04-19 Thread Shinobu Kawai
Hi Gibbons,

 Hi thanks for your respsonse,

No problem.  :)

 Its not liable to be a permissions error as i am running tomcat on my local
 pc and have installed it myself.
 
 I should state i am a total newbie to velocity and just installed it
 yesterday.

Ok, if you're new here, I'll give you a great offer.  Try
VelocityViewServlet instead of VelocityServlet.  VelocityServlet is
deprecated and probably will be gone in following versions.
http://jakarta.apache.org/velocity/tools/view/

The download also comes with sample wars.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: printing errors in error.vm page

2005-04-19 Thread Shinobu Kawai
Hi Tanveer,

 I m using velocity with turbine. When we get an error ,error.vm is called.
 Is there a method to print the corresponding error on the error.vm page.

I would ask the turbine guys about that.
http://jakarta.apache.org/site/mail2.html#Turbine

Actually, if the exception object was set to the Context, all the
public methods should be available to the template.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Newbie question: Formal notation for #if #else #end

2005-04-15 Thread Shinobu Kawai
Hi Ken,

 Suppose I have the following:
 
 123#if(1==1)456#end789
 
 I want the result to be 123456789. I ran a test
 and Velocity doesn't seem to recognize #end. So I
 tried formal notation as mentioned in
 (http://jakarta.apache.org/velocity/user-guide.html#Directives)
 with the following code:
 
 123#if(1==1)456#{end}789
 
 Velocity still blows up. It doesn't look like the
 formal notation is recognized. I found a hack to
 do it like the following (which works):
 
 123#if(1==1)456#end$!{DELIM}789
 
 Question: Is this a known issue? When will it be
 fixed?

This feature will be available from Velocity 1.5.  Not being released
yet, you can get it directly from the Subversion repository, or from
the nightly snapshots.  :)
http://jakarta.apache.org/velocity/install.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Programming Velocity

2005-04-13 Thread Shinobu Kawai
Hi Matthias,

 I have a question on a programmatic way to use velocity.
 
 I have a class *hooked* into our framework that should use Velocity
 to generate dynamic output.
 
 Example:

## snip

 I used the EventCartridge clazz, added a custom 
 ReferenceInsertionEventHandler.
 Now I was able to replase $foo and $bar with some other HTML code. But I want 
 to
 *replace* $foo with another template code.
 
 for example something like:

## snip

 Ok, when I return it as a String (the second template code) it gets printed,
 but when in VelocityContext I have an Array under key list.
 
 So I think it must be generate a dynamic table in my case, but it only prints 
 the template code
 as a String.
 
 So is there no way to relpase a Velocity expression/statement (e.g. $foo)
 with an other template code?

I'm not sure how you're using the EventCartridge, but might the
(View)RenderTool help?  Well, at least the source for it should.  ;)

http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/RenderTool.html
http://jakarta.apache.org/velocity/tools/view/ViewRenderTool.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: ADD Function in Velocity

2005-04-13 Thread Shinobu Kawai
Hi Sashi,

  I am trying to use add functionality with external data
 
  #set ( $value = $templet.getLongValue()  )
 
  suppose now $value has value of 1
 
  #set ( $value = $value + 1  )
 
 Still the total shows 1. Actually its not adding  value . Here
 $templet.getLongValue()   returns a long Value

Long arithmetic gets supported from Velocity 1.5.  As for 1.4, you can
use the MathTool.  :)
http://jakarta.apache.org/velocity/tools/generic/MathTool.html#add()

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Problem with decimal in most recent snapshot

2005-04-12 Thread Shinobu Kawai
Hi,

 I just pulled down this morning's snapshot.  I compiled and ran it and still 
 got
 
 COLUMN SIZE IS 6.333

I guess it's not in there yet.  The latest from SVN worked fine.
You can wait until tomorrow's build, or check it out from the repository.
http://jakarta.apache.org/velocity/install.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Using foreach loops on String[][]

2005-04-11 Thread Shinobu Kawai
Hi Jason,

 I didn't see this in the Velocity documentation but can string arrays of
 string arrays be iterated through via typical foreach handling or is it
 necessary to enumerate everything out. On that note, if I use
 Arrays.asList(String[][]) to put a List into the context, can I then
 access the individual String arrays as $Foo[0] $Foo[1]?

Is there a difference between your phrases iterated through and
enumerate everything out?  To me, it sounds the same, and yes, I
believe you can nest #foreach loops for that purpose.

As for getting the elements directly, check out the ListTool.  :)
http://wiki.apache.org/jakarta-velocity/ListTool

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: instanceof

2005-04-11 Thread Shinobu Kawai
Hi Ross,

 Does anyone know of a way to do instanceof checks from VTL? At the
 moment I'm providing a simple isA method on objects, but I am thinking
 there must be another way...
 
 The isA method works, but (at the moment) only checks the actual
 classname (not superclasses). Before I go about working this out, I just
 wondered if I had missed something crucial ... ?

None in Velocity, but I'll bet you can make a tool that does that.  ;)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Map creation outside of #set

2005-04-11 Thread Shinobu Kawai
Hi adam,

 I really need the ability to define a Map outside of a #set. For instance:
 
$form.select('model.property', { 'onChange' : 'doSomethingCool()',
 'style' : 'color: red' })
 
 Right now, with what is in cvs (when is 1.5 going to be released,
 btw?), as far as I can tell, I have to do this:
 
#set($attrs = { 'onChange' : 'doSomethingCool()', 'style' : 'color: red' })
$form.select('model.property', $attrs)
 
 Ugh.
 
 Please tell me I am wrong. I looked at the Velocity source, and I am
 99.9% certain that I am not. How hard would it be to get this? Maybe
 the real question should be, why doesn't Velocity have this already?

Answering your real question, because it's a known bug.  :(
http://issues.apache.org/bugzilla/show_bug.cgi?id=33113

## We need to fix the parser.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Map creation outside of #set

2005-04-11 Thread Shinobu Kawai
Hi adam,

  Answering your real question, because it's a known bug.  :(
  http://issues.apache.org/bugzilla/show_bug.cgi?id=33113
 
  ## We need to fix the parser.
 
  Best regards,
  -- Shinobu
 
 Thank you, Shinobu. Any idea when that might happen? Looks like the
 bug has be outstanding for three months? I would love to fix it, but I
 have never worked on a parser before... outside of a SAX one, anyway
 ;)

Yeah, I know.  Lots of bugs have been left alone for a while.  Looks
like the committers and contributors have been quite busy lately. 
(I'd work on it if I had *enough* consecutive free time.)

Anyways, if you're planning to take a shot at it, I guess you'll need
to understand how JavaCC works.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Velocity 1.5 release? (was Re: Map creation outside of #set)

2005-04-11 Thread Shinobu Kawai
Hi Jian,

 Talking about the bug fix, can someone kindly give me an idea if there
 will be a major release in the near future? say, 6 months?
 
 It seems to me that the development of Velocity core has been kind of stalled.

I'm not sure about the release, but remember, this is open source and
you can help get that release out.  :)
http://wiki.apache.org/jakarta-velocity/IssuePriorities

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Problem with decimal in most recent snapshot

2005-04-11 Thread Shinobu Kawai
Hi JohnE,

 Basically I am getting a decimal when I should be getting an int with the 
 following code I use in production already:
 
 #set ($colSize = ($jpPop.size() / 3) - 1)
 THE COLUMN SIZE IS $colSize
 
 when colSize is printed out it gives a number like 6.333 when all values 
 in this calculation are integer.   I should get 6 as an int according to the 
 documentation.

The User Guide says:
When a division operation is performed between two integers, the
result will be an integer.
http://jakarta.apache.org/velocity/user-guide.html#Math

The MathUtils#divide javadoc says:
Integer-types will be returned as Integer-type if and only if the
modulo of the two numbers is 0.

http://svn.apache.org/repos/asf/jakarta/velocity/trunk/src/java/org/apache/velocity/runtime/parser/node/MathUtils.java

They can't both be right.  If you consider backward compatibility, the
user guide should be correct.  But my mind says the javadoc is more
convenient...  Will?
cf. http://issues.apache.org/bugzilla/show_bug.cgi?id=25874

http://mail-archives.eu.apache.org/mod_mbox/jakarta-velocity-dev/200501.mbox/[EMAIL
 PROTECTED]

 From what I can see there is no way to make a float an integer either.  This 
 too I would imagine could be a problem.

For now, you can use the MathTool.
http://jakarta.apache.org/velocity/tools/generic/MathTool.html#toInteger()

 I was hoping to push this into production tonight but it will have to wait 
 till I can figure out what to do with the potential affects this could have 
 to the whole system or...it gets resolved.

Which, I guess, makes a good reason for the user guide to be right.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Weird execution of code

2005-04-08 Thread Shinobu Kawai
Hi Manish,

 Something weird is happening here...
 I have this piece of code in my Velocity template file -
 
 $request.getLocalAddr()
 
 This works fine on other machine and gives the correct local IP, however on
 other machine this results in null value, why is it so?
 What configuration issue could affect this? Any other ideas? I am lost...

You can investigate by checking the difference between the working and
non-working machines.
- Which servlet container?  Which version?  What configuration?
- Which platform?  Which hardware?  Whatever...

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: tools 1.2dev

2005-04-08 Thread Shinobu Kawai
Hi Israel,

 I'm starting with Velocity and wanted to get it working with struts so
 I was checking into changelog for velocity tools and it seemed best
 choice to download 1.2dev due to its improvements relationed with newer
 versions of struts. Download site wouldn't have link for that version,
 do i have to checkout from cvs?

You can get a nightly snapshot here:
http://cvs.apache.org/snapshots/velocity-tools/

## Subversion, BTW.  ;)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: variables in a variable (recursive).

2005-04-08 Thread Shinobu Kawai
Hi David,

 Anyway know if Velocity supports variables in a variable? (not #parse, I
 know this one, but you have to created a separated template for it)
 
 What I need is sth.  like this in the template.
 
 $a, $b, lkjlk, #recurse($somevariable),.
 
 ^ this somevariable will have imbedded
 $variables in it.
 
 Anyone has some idea about it?

Check out (View)RenderTool.  :)

http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/RenderTool.html
http://jakarta.apache.org/velocity/tools/view/ViewRenderTool.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Writing to File

2005-04-06 Thread Shinobu Kawai
Hi Sashi,

 I am  writing some data to file using Templet..
 
fileName = C:/cs_db.xml;
BufferedWriter writer = new BufferedWriter(
new FileWriter(fileName));
 
if ( template != null)
template.merge(context, writer);
 
is it possible to specify the encoding format (like ebcidic
 or utf-8 etc..) Also I need to write data in different encoding formats..

For encodings of the template, check out here:

http://jakarta.apache.org/velocity/developer-guide.html#Template%20Encoding%20for%20Internationalization

For encodings of the output file, check out here:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/OutputStreamWriter.html

For general information on i18n, check out here:
http://java.sun.com/j2se/1.5.0/docs/guide/intl/index.html

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Email Text

2005-04-06 Thread Shinobu Kawai
Hi Subbiah,

 I am trying to create templates in velocity of emails that my app needs to
 send out.
 How do make special changes in email text like hyperlinks/ bold etc.
 
 I used to do this by setting my content type as text/html in email and
 writig a html file, so do I have to create a same HTML for template in
 velocity to be read by mt email engine.

Velocity is only a template engine.  Whether it's a web site or HTML
mail, the templates should be the same.  :)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: creating macro libraries

2005-04-06 Thread Shinobu Kawai
Hi uday,

 Till now i created a macro for a combo box , textfield, and a screen which
 gets data from a screen class  where it can be dynamically displayed .
 I need to design a screen , where that screen is divided into two parts ,
 if u select data on one part of the screen  so it will be added to the other
 part of the screen.

Do you know how it is done in regular HTML?  (Well, DHTML maybe.) 
Then you're half way there.  Just let your macro render that HTML.  :)

When I develop a dynamic page, I usually make a static one first. 
Once I get a working one, just change the variables to dynamic content
bit by bit.  And whola!  It evolves into a dynamic page, each step
working.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Writing to File

2005-04-06 Thread Shinobu Kawai
Hi Sashi,

Let's keep the discussion on the list.  I'm not the only one with
great ideas.  :)

  I am trying something ike this
 
  $templet.getValue(name)
 
  which returns byte[]
 
  using following
 
 Writer writer = new BufferedWriter(new OutputStreamWriter(new
 FileOutputStream(fileName)));
 if ( template != null)
template.merge(context, writer);
 
 But the output value is some thing like this [EMAIL PROTECTED] (calling 
 toString
 on byte[])  but its not actually writing the byte array.

Because that's how it was meant to be.  I don't think there's a tool
currently to convert byte arrays to Strings, but it can be made
easily.  The constructor of String can be used.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#String(byte[],
java.lang.String)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Writing to File

2005-04-06 Thread Shinobu Kawai
Hi Sashi,

 Hi Sorry to reply like this... Iam unable to reply  from the main page..
 (first time user)

Two things you can try.
- Reply to all.  (Or whatever is the same in your mail client)
- Change the TO before you send the mail.

## Annoyingly, GMail inserts a Reply-To field (unavoidable), but the
ML manager is smart enough to add the list address to it.

 new String(byte[])
 
 will return the string value if its a normal byte[], but case is its
 encoded to EBCDIC  Still it converts but there is some difference..
 
 converting normal byte[] and EXCDIC bute[].,

Poke around the other constructors.  You should be able to find one
that you can specify the encoding.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Streaming from the middle of a template?

2005-04-05 Thread Shinobu Kawai
Hi Evan,

 Here's what I'm doing: I've written a reusable html-control model for
 creating html components within the struts framework using velocity. These
 components use velocity themselves to render their content. These controls
 may also themselves contain other sub-controls, and so on.  It seems
 ineffecient for me for each of these sub-controls, to have to create a
 single large string and return it to its parent control to render it. I
 would rather pass a writer down through the execution hierarchy having each
 subcontrol add its output to the parents writer, thus using a single writer
 to achieve the total output, instead of a segmented writer.toString -
 writer.toString - writer.toString sort of process.
 
 Does that make more sense?

If all the components uses Velocity to render the content, you must be
using Template#merge or Velocity(Engine)#mergeTemplate or
Velocity(Engine)#evaluate in each of your components, correct?  If so,
you can just put the Writer in the Context before rendering.
context.put(writer, writer)
And in the template,
$component.render($writer)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: SortedMap/TreeMap in a tool does not sort

2005-04-05 Thread Shinobu Kawai
Hi Rob,

 I had assumed 'natural order' meant the order I put it in (never used
 SortedMap before...). The question's answers are correct because the
 keys are like q1, q2, q3.

Just for you.  ;)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedHashMap.html

If you're using a version less than 1.4, you can use commons-collections
http://jakarta.apache.org/commons/collections/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Streaming from the middle of a template?

2005-04-05 Thread Shinobu Kawai
Hi Evan,

  If all the components uses Velocity to render the content, you must be
  using Template#merge or Velocity(Engine)#mergeTemplate or
  Velocity(Engine)#evaluate in each of your components, correct?
  If so, you can just put the Writer in the Context before rendering.
  context.put(writer, writer)
  And in the template,
  $component.render($writer)
 
 Right right, exactly, but how to I get the writer?
 
 How do I get the writer from the parent velocity template such that I can
 pass it to the child templates and have there output slip right into the
 output of the parent?

I might not be understanding your situation quite well...

Right now, how exactly are you calling Velocity in your most-parent component?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Streaming from the middle of a template?

2005-04-05 Thread Shinobu Kawai
Hi Evan,

 The root is calling velocity through the VelocityViewServlet. It is setup in
 a standard way in my web.xml to handle all requests with a certain file
 extension.

OK, that part's understood.  You said that each sub-component also
uses Velocity.  How do you intend to do that?  I mean, inside the
#streamToOutput method of your first post.  If you're just getting a
template and rendering it, I think you should check out the #parse
directive like Mike said.
http://jakarta.apache.org/velocity/user-guide.html#Parse

## You can hack VelocityViewServlet#mergeTemplate and put the Writer
in the Context there.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



creating macro libraries

2005-04-02 Thread Shinobu Kawai
Hi uday,

 Can u pls help me regarding velocity macros .
 how to create a macro library and also i would like to use a macro  to
 embedd a tree structure in web page

Take a peek here:
 http://jakarta.apache.org/velocity/user-guide.html#Velocimacros

Some questions to help us help:
- What do you want to do?
- What have you tried so far?
- What results did you get?
- What results did you expect?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Velocity - Double Rendering

2005-04-01 Thread Shinobu Kawai
Hi Krishnan,

 I am trying to render a Velocity page using double rendering 
 Technique(Velocity generates Velocity)

Check out the RenderTool.  :)
http://jakarta.apache.org/velocity/tools/generic/

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Loading templates from classpath

2005-04-01 Thread Shinobu Kawai
Hi seba,

 I am in the following situation: I'm running a Velocity servlet in
 Jetty, and everything works fine until I load the template (which
 Velocity can't found). I would like getTemplate() to load the template
 from the classpath (i.e., from the jar file), so to have a completely
 self-contained application. I think this is possible using a classpath
 loader, but after a lot of reading a couldn't find a single example (and
 exploring all possibilities is daunting).
 
 I would be immensely grateful to anybody pointing me at a code snippet
 that shows how to do it...

What have you tried so far?  Let's start from there.

Some documents you might want to read:
http://jakarta.apache.org/velocity/developer-guide.html#Resource%20Loaders

http://jakarta.apache.org/velocity/api/org/apache/velocity/runtime/resource/loader/ClasspathResourceLoader.html
http://issues.apache.org/bugzilla/show_bug.cgi?id=22419
http://issues.apache.org/bugzilla/show_bug.cgi?id=31703

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: macro help (was need implement like AOP)

2005-04-01 Thread Shinobu Kawai
Hi uday,

 Ok collection object is working , i need to use an Hash Map.
 Can any one of u help me ...

Can you show us how you would want to use it?

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Loading templates from classpath

2005-04-01 Thread Shinobu Kawai
Hi seba,

Let's keep it on the list.  No secrets.  ;)

 My problem is that I would like to set the loader programmatically. I do
 not want to set up web.xml or similar. I just want to start jetty and
 have the servlet initialisation code (or whatever initialisation code
 must be) set the loader to the ClasspathResourceLoader, and finally have
 templates read from the jar.

If you aren't going to customise your web.xml, how are you going to
let the servlet container know which servlet to use?  Or am I missing
something about jetty?
Anyways, _if_ you're willing to edit your web.xml, it's as simple as
setting your velocity.properties.
 http://jakarta.apache.org/velocity/tools/view/

 I have the idea that this should be doable by overriding
 loadConfiguration() and setting something either in the Velocity runtime
 or in the properties obtained by super.loadConfiguration( config ).
 Again I could not find any examples about this.

You got the picture!  A partial sample can be found here:
 
http://jakarta.apache.org/velocity/developer-guide.html#Miscellaneous%20Details

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Loading templates from classpath

2005-04-01 Thread Shinobu Kawai
Hi seba,

 You read my mind. 8^) Here's the catch: put this in the servlet.
 
 protected Properties loadConfiguration( final ServletConfig config ) throws 
 FileNotFoundException, IOException {
Properties p = super.loadConfiguration( config );
p.setProperty( resource.loader, class );
p.setProperty( class.resource.loader.class, 
 ClasspathResourceLoader.class.getName() );
return p;
 }

Thanks for sharing your solution with us!  Maybe someday it'll get into the FAQ.
 http://wiki.apache.org/jakarta-velocity/VelocityFAQ
## Anyone can update the wiki, BTW.  B)

 What was completely confusing me is that Velocity defines a number of
 final static constant strings for properties, but apparently not for
 *all* properties. class.resource.loader.class is not in, or I couldn't
 find it. Anyway...

FYI, there's one for resource.loader.  :)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Comparing null...

2005-03-30 Thread Shinobu Kawai
Hi Sashi,

 Can we compare null condition in velocity
 
  # if ($type != null)
 
  #end

Check out here for more...
   http://wiki.apache.org/jakarta-velocity/VelocityFAQ

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Trying to download veltags

2005-03-30 Thread Shinobu Kawai
Hi Ryan,

 I was trying to get the velocity tag libraries to work.. but the
 first thing the ant script tries to do  is download jjar, which
 fails... Where can I find jjar?

You can find it here:
http://jakarta.apache.org/commons/sandbox/jjar/

I'm sure you're reading here:

http://jakarta.apache.org/velocity/veltag.html#Building%20The%20Velocity%20Taglib

So, if one way fails, try the other.
http://jakarta.apache.org/velocity/veltag.html#nonJJAR%20build

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Trying to download veltags

2005-03-30 Thread Shinobu Kawai
Hi Ryan,

Let's keep it on the list.

 I might be missing something... But the first thing that happens when
 you run ant is that it tries to use jjar?

If you read here (Build Using JJAR):
http://jakarta.apache.org/velocity/veltag.html#JJAR%20build
it tells you to first obtain jjar by
ant getjars

Which fails of the moment, so you'll need to do the Non-JJAR
Traditional Build.  Doesn't seem to be documented, but I think you'll
need to use the build_nojjar.xml ant script.

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



Re: Accessing Java System properties using Velocity

2005-03-29 Thread Shinobu Kawai
Hi Pras,

  How do I read System.getProperty(foo) within a Velocity file? I need
 this to read a property and take corresponding action at the time of
 initialization of my application. I can not put this code in any of the
 methods within my Servlets and call the corresponding method from my
 Velocity as during init-time, none of my Servlet classes are being invoked
 until the user clicks on any one of the links in the web page.

How are you processing the Velocity templates?  You always have the
option to subclass VelocityViewServlet.
http://jakarta.apache.org/velocity/tools/view/

Anyways, since you can't directly read System properties from
templates, you can:
- Put the System properties that you will use in the Context.
- Put the whole System properties in the Context.
- Put a tool that gets System properties in the Context.
And get all you need via the Context.
http://jakarta.apache.org/velocity/developer-guide.html#The%20Context

 Probably might be a newbie question because it's just my 2nd week working on
 Velocity. Any thoughts would be sincerely appreciated.

Don't worry, that's how we all start.  ;)

Best regards,
-- Shinobu

--
Shinobu Kawai [EMAIL PROTECTED]

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



  1   2   3   4   >