Changing Header.vm file on Locale change

2007-04-17 Thread santas

Hi
What i want to do is that whenever i change Locale  of my application
depending on that locale i want to change my 
header.vm files contetnt for Meta tag.

On my first page i am having one link that will chage my Locale  of
application now suppose i click on link and now new Locale is en  then i
want meta  tag for en to be used by browser.

  Whenever i change my Locale one portlet is called and that calls another
class to set this locale in session for that user. I tryid to put that in 
Velocity context but 

Now i am very much new to this velocity and trying lot many things but
getting nothing.
And my big confusion is that is this header.vm is called before that
portlet is called.
Can anybody give me proper direction please.


Thanks 


-- 
View this message in context: 
http://www.nabble.com/Changing-Header.vm-file-on-Locale-change-tf3589047.html#a10029907
Sent from the Velocity - Dev mailing list archive at Nabble.com.


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



Changing Header.vm file on Locale change

2007-04-17 Thread santas

Hi
What i want to do is that whenever i change Locale  of my application
depending on that locale i want to change my 
header.vm files contetnt for Meta tag.

On my first page i am having one link that will chage my Locale  of
application now suppose i click on link and now new Locale is en  then i
want meta  tag for en to be used by browser.

  Whenever i change my Locale one portlet is called and that calls another
class to set this locale in session for that user. I tryid to put that in 
Velocity context but dont know how to use it in header.vm.

Now i am very much new to this velocity and trying lot many things but
getting nothing.
And my big confusion is that is this header.vm is called before that
portlet is called.
Can anybody give me proper direction please.


Thanks 


-- 
View this message in context: 
http://www.nabble.com/Changing-Header.vm-file-on-Locale-change-tf3589049.html#a10029910
Sent from the Velocity - Dev mailing list archive at Nabble.com.


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



[jira] Commented: (VELOCITY-223) VMs that use a large number of directives and macros use excessive amounts of memory - over 4-6MB RAM per form

2007-04-17 Thread Alexey Panchenko (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489376
 ] 

Alexey Panchenko commented on VELOCITY-223:
---

Synchronization

stringImagePool.get(image) should be inside synchronized block too.

Memory Usage

The memory held by private static MapString, String stringImagePool will be 
never released. The same applies to String.intern().


 VMs that use a large number of directives and macros use excessive amounts of 
 memory - over 4-6MB RAM per form
 --

 Key: VELOCITY-223
 URL: https://issues.apache.org/jira/browse/VELOCITY-223
 Project: Velocity
  Issue Type: Bug
  Components: Engine
Affects Versions: 1.3.1
 Environment: Operating System: All
 Platform: All
Reporter: Christian Nichols
 Fix For: 1.6

 Attachments: 223-patch.txt, AllVelocityMemoryByClass.html, 
 StringImagePool.java, VelocityCharStream.java, VelocityMemory.JPG


 Our application FinanceCenter is based on Velocity as the template engine.  
 We 
 have a library of about 200 macros and about 400 VM files.  Because the 
 velocity parser copies the macro body into the VM during parsing, macros that 
 are frequently used (even though identical and using local contexts) use up 
 large amounts of memory.  On our Linux server (running Redhat 7.2 with Sun 
 JDK 
 1.4.1_04) we can easily use up over 1GB of RAM simply by opening up many 
 forms 
 (about 150) - the server starts out using 60MB after startup.  This memory 
 times out after 5 minutes and is returned which tells me that it is screen 
 memory.  Our problem is that the NT JVM and Linux JVM (32 bit) are currently 
 limited to about 1.6 - 2.0 GB of ram for heap space.  Thus, using a fair 
 number 
 of forms in the application leaves little space for user session data.
 We have implemented a caching mechanism for compiled templates and integrated 
 it into Velocity so that cached objects are timed out of the cache but the 
 server is still using large amounts of memory.  We finally had to rewrite 
 many 
 of our macros into Java so that memory usage would be reduced (note that 
 these 
 macros were doing complex screen formatting not business logic).  Doing this 
 has reduced our memory by about 30%.  This is currently our biggest issue 
 with 
 Velocity and is causing us to review our decision to stay with Velocity going 
 forward.  This is because we will likely end up with close to 1,000 forms by 
 the end of next year and need to know that Velocity can deal with this.  Is 
 there any work underway to share compiled macro AST's?  This would greatly 
 reduce the amount of memory used.  I have reviewed the parser code that is 
 doing this but it seems that this is an embedded part of the design and not 
 easily changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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



[jira] Commented: (VELOCITY-223) VMs that use a large number of directives and macros use excessive amounts of memory - over 4-6MB RAM per form

2007-04-17 Thread Christopher Schultz (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489392
 ] 

Christopher Schultz commented on VELOCITY-223:
--

Since Velocity already depends on commons-collections, why not use a 
ReferenceMap with non-hard references within StringImagePool? This way, you 
essentially get timeout behavior where old, unused keys (and values) will be 
GC'd.


 VMs that use a large number of directives and macros use excessive amounts of 
 memory - over 4-6MB RAM per form
 --

 Key: VELOCITY-223
 URL: https://issues.apache.org/jira/browse/VELOCITY-223
 Project: Velocity
  Issue Type: Bug
  Components: Engine
Affects Versions: 1.3.1
 Environment: Operating System: All
 Platform: All
Reporter: Christian Nichols
 Fix For: 1.6

 Attachments: 223-patch.txt, AllVelocityMemoryByClass.html, 
 StringImagePool.java, VelocityCharStream.java, VelocityMemory.JPG


 Our application FinanceCenter is based on Velocity as the template engine.  
 We 
 have a library of about 200 macros and about 400 VM files.  Because the 
 velocity parser copies the macro body into the VM during parsing, macros that 
 are frequently used (even though identical and using local contexts) use up 
 large amounts of memory.  On our Linux server (running Redhat 7.2 with Sun 
 JDK 
 1.4.1_04) we can easily use up over 1GB of RAM simply by opening up many 
 forms 
 (about 150) - the server starts out using 60MB after startup.  This memory 
 times out after 5 minutes and is returned which tells me that it is screen 
 memory.  Our problem is that the NT JVM and Linux JVM (32 bit) are currently 
 limited to about 1.6 - 2.0 GB of ram for heap space.  Thus, using a fair 
 number 
 of forms in the application leaves little space for user session data.
 We have implemented a caching mechanism for compiled templates and integrated 
 it into Velocity so that cached objects are timed out of the cache but the 
 server is still using large amounts of memory.  We finally had to rewrite 
 many 
 of our macros into Java so that memory usage would be reduced (note that 
 these 
 macros were doing complex screen formatting not business logic).  Doing this 
 has reduced our memory by about 30%.  This is currently our biggest issue 
 with 
 Velocity and is causing us to review our decision to stay with Velocity going 
 forward.  This is because we will likely end up with close to 1,000 forms by 
 the end of next year and need to know that Velocity can deal with this.  Is 
 there any work underway to share compiled macro AST's?  This would greatly 
 reduce the amount of memory used.  I have reviewed the parser code that is 
 doing this but it seems that this is an embedded part of the design and not 
 easily changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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



Re: Changing Header.vm file on Locale change

2007-04-17 Thread Nathan Bubna

Please don't cross-post.  This is a user list question.  Wait a few
days to get a reply there before you try this list.

On 4/16/07, santas [EMAIL PROTECTED] wrote:


Hi
What i want to do is that whenever i change Locale  of my application
depending on that locale i want to change my
header.vm files contetnt for Meta tag.

On my first page i am having one link that will chage my Locale  of
application now suppose i click on link and now new Locale is en  then i
want meta  tag for en to be used by browser.

  Whenever i change my Locale one portlet is called and that calls another
class to set this locale in session for that user. I tryid to put that in
Velocity context but dont know how to use it in header.vm.

Now i am very much new to this velocity and trying lot many things but
getting nothing.
And my big confusion is that is this header.vm is called before that
portlet is called.
Can anybody give me proper direction please.


Thanks


--
View this message in context: 
http://www.nabble.com/Changing-Header.vm-file-on-Locale-change-tf3589049.html#a10029910
Sent from the Velocity - Dev mailing list archive at Nabble.com.


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




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



[jira] Commented: (VELOCITY-223) VMs that use a large number of directives and macros use excessive amounts of memory - over 4-6MB RAM per form

2007-04-17 Thread Will Glass-Husain (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489416
 ] 

Will Glass-Husain commented on VELOCITY-223:


that makes sense to me.  the memory issue is a good explanation of why it'd be 
useful to keep our own pool rather than use String intern()

 VMs that use a large number of directives and macros use excessive amounts of 
 memory - over 4-6MB RAM per form
 --

 Key: VELOCITY-223
 URL: https://issues.apache.org/jira/browse/VELOCITY-223
 Project: Velocity
  Issue Type: Bug
  Components: Engine
Affects Versions: 1.3.1
 Environment: Operating System: All
 Platform: All
Reporter: Christian Nichols
 Fix For: 1.6

 Attachments: 223-patch.txt, AllVelocityMemoryByClass.html, 
 StringImagePool.java, VelocityCharStream.java, VelocityMemory.JPG


 Our application FinanceCenter is based on Velocity as the template engine.  
 We 
 have a library of about 200 macros and about 400 VM files.  Because the 
 velocity parser copies the macro body into the VM during parsing, macros that 
 are frequently used (even though identical and using local contexts) use up 
 large amounts of memory.  On our Linux server (running Redhat 7.2 with Sun 
 JDK 
 1.4.1_04) we can easily use up over 1GB of RAM simply by opening up many 
 forms 
 (about 150) - the server starts out using 60MB after startup.  This memory 
 times out after 5 minutes and is returned which tells me that it is screen 
 memory.  Our problem is that the NT JVM and Linux JVM (32 bit) are currently 
 limited to about 1.6 - 2.0 GB of ram for heap space.  Thus, using a fair 
 number 
 of forms in the application leaves little space for user session data.
 We have implemented a caching mechanism for compiled templates and integrated 
 it into Velocity so that cached objects are timed out of the cache but the 
 server is still using large amounts of memory.  We finally had to rewrite 
 many 
 of our macros into Java so that memory usage would be reduced (note that 
 these 
 macros were doing complex screen formatting not business logic).  Doing this 
 has reduced our memory by about 30%.  This is currently our biggest issue 
 with 
 Velocity and is causing us to review our decision to stay with Velocity going 
 forward.  This is because we will likely end up with close to 1,000 forms by 
 the end of next year and need to know that Velocity can deal with this.  Is 
 there any work underway to share compiled macro AST's?  This would greatly 
 reduce the amount of memory used.  I have reviewed the parser code that is 
 doing this but it seems that this is an embedded part of the design and not 
 easily changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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



[jira] Commented: (VELOCITY-223) VMs that use a large number of directives and macros use excessive amounts of memory - over 4-6MB RAM per form

2007-04-17 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489435
 ] 

Nathan Bubna commented on VELOCITY-223:
---

Oh, and to finish out my conversation with Lei, he acknowledged that the 
synchronization of put() is useless and can be removed:

On 4/2/07, Lei Gu [EMAIL PROTECTED] wrote:
 
 You got me there. I thought put will be called a lot less than get but you
 are right,
 we should be able to remove it as well.
 -- Lei
 
 
 Nathan Bubna wrote:
 
  On 4/2/07, Lei Gu [EMAIL PROTECTED] wrote:
 
  Hi Nathan,
  a) In the original code, a new copy of string image is constructed and
  returned as part of the token, which is part of a node. When we cache
  templates, these nodes stay in memory forever or until the template
  itself
  is booted from the cache. We improved this by checking against the string
  image pool. If the image already exists in the pool, the reference for
  the
  image is used instead of the newly created string. The newly created
  string
  will be garbage collected.
 
  cool. thanks for the explanation!
 
  b) This image pool is being called constantly and that's why we don't
  want
  to synchronized on the get call. It is okay to have one thread overwrites
  the other's string image and the overwritten images won't be lost if
  there
  could be existing references to them.
 
  i thought so.  so why synchronize put() at all?  doesn't it only delay
  the overwriting and slow things down needlessly?
 
  Thanks.
  -- Lei
 

 VMs that use a large number of directives and macros use excessive amounts of 
 memory - over 4-6MB RAM per form
 --

 Key: VELOCITY-223
 URL: https://issues.apache.org/jira/browse/VELOCITY-223
 Project: Velocity
  Issue Type: Bug
  Components: Engine
Affects Versions: 1.3.1
 Environment: Operating System: All
 Platform: All
Reporter: Christian Nichols
 Fix For: 1.6

 Attachments: 223-patch.txt, AllVelocityMemoryByClass.html, 
 StringImagePool.java, VelocityCharStream.java, VelocityMemory.JPG


 Our application FinanceCenter is based on Velocity as the template engine.  
 We 
 have a library of about 200 macros and about 400 VM files.  Because the 
 velocity parser copies the macro body into the VM during parsing, macros that 
 are frequently used (even though identical and using local contexts) use up 
 large amounts of memory.  On our Linux server (running Redhat 7.2 with Sun 
 JDK 
 1.4.1_04) we can easily use up over 1GB of RAM simply by opening up many 
 forms 
 (about 150) - the server starts out using 60MB after startup.  This memory 
 times out after 5 minutes and is returned which tells me that it is screen 
 memory.  Our problem is that the NT JVM and Linux JVM (32 bit) are currently 
 limited to about 1.6 - 2.0 GB of ram for heap space.  Thus, using a fair 
 number 
 of forms in the application leaves little space for user session data.
 We have implemented a caching mechanism for compiled templates and integrated 
 it into Velocity so that cached objects are timed out of the cache but the 
 server is still using large amounts of memory.  We finally had to rewrite 
 many 
 of our macros into Java so that memory usage would be reduced (note that 
 these 
 macros were doing complex screen formatting not business logic).  Doing this 
 has reduced our memory by about 30%.  This is currently our biggest issue 
 with 
 Velocity and is causing us to review our decision to stay with Velocity going 
 forward.  This is because we will likely end up with close to 1,000 forms by 
 the end of next year and need to know that Velocity can deal with this.  Is 
 there any work underway to share compiled macro AST's?  This would greatly 
 reduce the amount of memory used.  I have reviewed the parser code that is 
 doing this but it seems that this is an embedded part of the design and not 
 easily changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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



Re: Changing Header.vm file on Locale change

2007-04-17 Thread Nathan Bubna

This looks like it might be a good situation to use the
MultiViewsTool to find the appropriate header.vm file:

http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/view/i18n/MultiViewsTool.html

I haven't used it myself, but my understanding is that you use it to
find the appropriate template name for a specified locale (or the
default locale if there is none for the specified locale).  And then
you use the #parse() or #include() directives to load that
template/file.

So, assuming that you are using VelocityTools and the MultiViewsTool
is in the context as $i18n, you would probably do something like:

#parse( $i18n.findLocalizedResource(header.vm, $request.locale) )


of course, i don't know if you are using VelocityTools or the
VelocityViewServlet.  You mentioned portlets.  Are you using a
specific portlet framework?  You might consider asking them for advice
on this too.  It could be challenging to set up VelocityTools with
that framework; i'm not really sure how that would work...

On 4/16/07, santas [EMAIL PROTECTED] wrote:


Hi
What i want to do is that whenever i change Locale  of my application
depending on that locale i want to change my
header.vm files contetnt for Meta tag.

On my first page i am having one link that will chage my Locale  of
application now suppose i click on link and now new Locale is en  then i
want meta  tag for en to be used by browser.

  Whenever i change my Locale one portlet is called and that calls another
class to set this locale in session for that user. I tryid to put that in
Velocity context but

Now i am very much new to this velocity and trying lot many things but
getting nothing.
And my big confusion is that is this header.vm is called before that
portlet is called.
Can anybody give me proper direction please.


Thanks


--
View this message in context: 
http://www.nabble.com/Changing-Header.vm-file-on-Locale-change-tf3589047.html#a10029907
Sent from the Velocity - Dev mailing list archive at Nabble.com.


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




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



[jira] Commented: (VELOCITY-223) VMs that use a large number of directives and macros use excessive amounts of memory - over 4-6MB RAM per form

2007-04-17 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489434
 ] 

Nathan Bubna commented on VELOCITY-223:
---

Lei has tested and confirmed memory savings, and i see no reason to doubt that 
unless someone gets other results.  His explanation of why it saved memory also 
makes sense.  He sent it to the mailing list in response to my comments above, 
so i'll repost here:

On April 2, Lei Gu said:

Hi Nathan,
a) In the original code, a new copy of string image is constructed and
returned as part of the token, which is part of a node. When we cache
templates, these nodes stay in memory forever or until the template itself
is booted from the cache. We improved this by checking against the string
image pool. If the image already exists in the pool, the reference for the
image is used instead of the newly created string. The newly created string
will be garbage collected.

b) This image pool is being called constantly and that's why we don't want
to synchronized on the get call. It is okay to have one thread overwrites
the other's string image and the overwritten images won't be lost if there
could be existing references to them.
Thanks.
-- Lei

 VMs that use a large number of directives and macros use excessive amounts of 
 memory - over 4-6MB RAM per form
 --

 Key: VELOCITY-223
 URL: https://issues.apache.org/jira/browse/VELOCITY-223
 Project: Velocity
  Issue Type: Bug
  Components: Engine
Affects Versions: 1.3.1
 Environment: Operating System: All
 Platform: All
Reporter: Christian Nichols
 Fix For: 1.6

 Attachments: 223-patch.txt, AllVelocityMemoryByClass.html, 
 StringImagePool.java, VelocityCharStream.java, VelocityMemory.JPG


 Our application FinanceCenter is based on Velocity as the template engine.  
 We 
 have a library of about 200 macros and about 400 VM files.  Because the 
 velocity parser copies the macro body into the VM during parsing, macros that 
 are frequently used (even though identical and using local contexts) use up 
 large amounts of memory.  On our Linux server (running Redhat 7.2 with Sun 
 JDK 
 1.4.1_04) we can easily use up over 1GB of RAM simply by opening up many 
 forms 
 (about 150) - the server starts out using 60MB after startup.  This memory 
 times out after 5 minutes and is returned which tells me that it is screen 
 memory.  Our problem is that the NT JVM and Linux JVM (32 bit) are currently 
 limited to about 1.6 - 2.0 GB of ram for heap space.  Thus, using a fair 
 number 
 of forms in the application leaves little space for user session data.
 We have implemented a caching mechanism for compiled templates and integrated 
 it into Velocity so that cached objects are timed out of the cache but the 
 server is still using large amounts of memory.  We finally had to rewrite 
 many 
 of our macros into Java so that memory usage would be reduced (note that 
 these 
 macros were doing complex screen formatting not business logic).  Doing this 
 has reduced our memory by about 30%.  This is currently our biggest issue 
 with 
 Velocity and is causing us to review our decision to stay with Velocity going 
 forward.  This is because we will likely end up with close to 1,000 forms by 
 the end of next year and need to know that Velocity can deal with this.  Is 
 there any work underway to share compiled macro AST's?  This would greatly 
 reduce the amount of memory used.  I have reviewed the parser code that is 
 doing this but it seems that this is an embedded part of the design and not 
 easily changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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



[jira] Commented: (VELOCITY-223) VMs that use a large number of directives and macros use excessive amounts of memory - over 4-6MB RAM per form

2007-04-17 Thread Nathan Bubna (JIRA)

[ 
https://issues.apache.org/jira/browse/VELOCITY-223?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489437
 ] 

Nathan Bubna commented on VELOCITY-223:
---

So, all told.  I think if we drop the static Map for a ReferenceMap (as 
Christopher suggested), drop the synchronization (as per the discussion between 
Lei and me), and retest to confirm the memory savings then this is ready to go 
into the codebase.

 VMs that use a large number of directives and macros use excessive amounts of 
 memory - over 4-6MB RAM per form
 --

 Key: VELOCITY-223
 URL: https://issues.apache.org/jira/browse/VELOCITY-223
 Project: Velocity
  Issue Type: Bug
  Components: Engine
Affects Versions: 1.3.1
 Environment: Operating System: All
 Platform: All
Reporter: Christian Nichols
 Fix For: 1.6

 Attachments: 223-patch.txt, AllVelocityMemoryByClass.html, 
 StringImagePool.java, VelocityCharStream.java, VelocityMemory.JPG


 Our application FinanceCenter is based on Velocity as the template engine.  
 We 
 have a library of about 200 macros and about 400 VM files.  Because the 
 velocity parser copies the macro body into the VM during parsing, macros that 
 are frequently used (even though identical and using local contexts) use up 
 large amounts of memory.  On our Linux server (running Redhat 7.2 with Sun 
 JDK 
 1.4.1_04) we can easily use up over 1GB of RAM simply by opening up many 
 forms 
 (about 150) - the server starts out using 60MB after startup.  This memory 
 times out after 5 minutes and is returned which tells me that it is screen 
 memory.  Our problem is that the NT JVM and Linux JVM (32 bit) are currently 
 limited to about 1.6 - 2.0 GB of ram for heap space.  Thus, using a fair 
 number 
 of forms in the application leaves little space for user session data.
 We have implemented a caching mechanism for compiled templates and integrated 
 it into Velocity so that cached objects are timed out of the cache but the 
 server is still using large amounts of memory.  We finally had to rewrite 
 many 
 of our macros into Java so that memory usage would be reduced (note that 
 these 
 macros were doing complex screen formatting not business logic).  Doing this 
 has reduced our memory by about 30%.  This is currently our biggest issue 
 with 
 Velocity and is causing us to review our decision to stay with Velocity going 
 forward.  This is because we will likely end up with close to 1,000 forms by 
 the end of next year and need to know that Velocity can deal with this.  Is 
 there any work underway to share compiled macro AST's?  This would greatly 
 reduce the amount of memory used.  I have reviewed the parser code that is 
 doing this but it seems that this is an embedded part of the design and not 
 easily changed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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



Re: Need some help with running tests

2007-04-17 Thread Will Glass-Husain

Hi Supun,

There's a couple of quirks here.  Here's what I think the issue sare:

(1) Ant can't find the junit jar for the junit task.  That's because it
doesn't look in the build classpath.  Solutions (a) Use ant 1.7 which solves
this problem or (b) copy junit.jar into the ant\lib library.

Let us know if this helps.  If this solves the problem I'll add a note to
the documentation about this.

(2) The test velocity files cannot be found.  The junit tests will not run
in an IDE without slight modifications.  The path to the test files is added
by an ant task.  Specifically, TemplateTestBase has constant fields which
define the path to the test files.  These have dummy values by default.
When you run ant compile the entire source tree is copied to a temporary
location and these values are filled in with the current path.  (note to
self: we really need to remove this annoying feature if possible).

Again, two possible solutions.
* Manually edit this class to include the path to your Velocity source
tree.  Probably . will work, though you might need an absolute path.  This
is the easiest approach, though we'll have to be careful not to commit this.

OR (this is what I do).

* Run ant compile which will create the alternate source tree.  Then
configure your IDE to use as the source tree (1) the standard java files (2)
the standard directory of java test files and (3) TemplateTestBase from
bin/test-src  (which has the filled in paths).  Credit to Henning for this
workaround.

WILL


On 4/17/07, Supun Kamburugamuva [EMAIL PROTECTED] wrote:


Hi,

I got some problems while trying to run test cases.

1. When I try to run the tests using Ant build(ant test) I got the
following error.

Could not create task or type of type:  junit.  Ant could not find
the task or a class this task relies upon.

I'm using ant-1.6.5.

2.  I have built an IntelliJ Idea project from the current SVN
checkout of the Velocity Engine. When I try to run some test cases I
got the following exception.

org.apache.velocity.exception.ResourceNotFoundException: Unable to
find resource 'context_safety.vm' 

Same exception occurs for other test cases where external files are
required. Some test cases that don't use external files run correctly.

Cheers,
Supun.

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





--
Forio Business Simulations

Will Glass-Husain
[EMAIL PROTECTED]
www.forio.com


Re: Changing Header.vm file on Locale change

2007-04-17 Thread santas

Thanks for your reply 
but i think i missed one point here that i am not using
velocity for my front end. I am using jsp with the portlets. And i think i
cant use this #parse( )  here in jsp.
I tryid solution but i don't know whether it is standard
or not.
What i tried to do is whenever i change Locale of my application it calls
on class,ok
 now int hat class i added following code


VelocityEngine Velocity = new VelocityEngine();
Properties p = new Properties();
p.setProperty(file.resource.loader.path,
C:\\Jetspeed-2.0\\webapps\\jetspeed\\decorations\\layout);
VelocityContext context= new VelocityContext();
context.put(langname,strLanguage);
Velocity.init(p);
Template temp = Velocity.getTemplate(tempheader.vm);
StringWriter writer = new StringWriter();
temp.merge(context,writer);
byte[] test= writer.toString().getBytes();
FileOutputStream out = new   
FileOutputStream(C:\\Jetspeed-2.0\\webapps\\jetspeed\\decorations\\layout\\header.vm);
out.write(test);
out.close();


now  i had written on file called tempheader.vm 
  #set ($MESSAGES =
$portletConfig.getResourceBundle($renderRequest.Locale))
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  html
head
   base href=#BaseHref()
   meta http-equiv=Content-type content=#ContentType() /
  meta http-equiv=Content-style-type content=text/css /
   #includeJavaScriptForHead()
  #IncludeStylesheets()
 #if($langname== it)

metaitalian meta
data here/meta
 #else
 metaenglish meta
data here/meta
 #end
 head


now whatever output i get by using this tempheader.vm template i write it to
another template that is header.vm

now it is working fine now but i dont know wether it is standard approch or
not.
i trying to seach about how this jetspeed container manages file writing for
large no of request.(how it synchronizes all request that write single file
)
   
Please can you put some light on this


Thanks



Nathan Bubna wrote:
 
 This looks like it might be a good situation to use the
 MultiViewsTool to find the appropriate header.vm file:
 
 http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/view/i18n/MultiViewsTool.html
 
 I haven't used it myself, but my understanding is that you use it to
 find the appropriate template name for a specified locale (or the
 default locale if there is none for the specified locale).  And then
 you use the #parse() or #include() directives to load that
 template/file.
 
 So, assuming that you are using VelocityTools and the MultiViewsTool
 is in the context as $i18n, you would probably do something like:
 
 #parse( $i18n.findLocalizedResource(header.vm, $request.locale) )
 
 
 of course, i don't know if you are using VelocityTools or the
 VelocityViewServlet.  You mentioned portlets.  Are you using a
 specific portlet framework?  You might consider asking them for advice
 on this too.  It could be challenging to set up VelocityTools with
 that framework; i'm not really sure how that would work...
 
 On 4/16/07, santas [EMAIL PROTECTED] wrote:

 Hi
 What i want to do is that whenever i change Locale  of my
 application
 depending on that locale i want to change my
 header.vm files contetnt for Meta tag.

 On my first page i am having one link that will chage my Locale  of
 application now suppose i click on link and now new Locale is en  then
 i
 want meta  tag for en to be used by browser.

   Whenever i change my Locale one portlet is called and that calls
 another
 class to set this locale in session for that user. I tryid to put that in
 Velocity context but

 Now i am very much new to this velocity and trying lot many things but
 getting nothing.
 And my big confusion is that is this header.vm is called before that
 portlet is called.
 Can anybody give me proper direction please.


 Thanks


 --
 View this message in context:
 http://www.nabble.com/Changing-Header.vm-file-on-Locale-change-tf3589047.html#a10029907
 Sent from the Velocity - Dev mailing list archive at Nabble.com.


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


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

-- 
View this message in context: