Re: Overriding Templates

2010-10-21 Thread Li Ying
I have reported it to JIRA as a BUG.
https://issues.apache.org/jira/browse/WW-3522

If the develop team confirm that it really is a bug,
then I will add information to the docs.

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Dave Newton
All help is greatly appreciated :)

Thanks!

Dave

On Wed, Oct 20, 2010 at 10:26 AM, Li Ying  wrote:
> OK, I will do it,
> But maybe tomorrow, because the local time is over 11PM now.
>
>
>
> 2010/10/20 Dave Newton :
>>> (A)I am just a new guy of Struts2 community, if I put some message
>>> into the Struts2 docs and it is not right, I will mislead so many
>>> users, I will feel so~~~ sorry.
>>
>> Honestly, I'd rather see the documentation reflect current behavior,
>> whether or not the behavior itself is correct. And if the
>> documentation is *already* wrong... Plus if something gets in there
>> that isn't well-written, it'll be corrected at some point.
>>
>>> (B)As you can see, my English is not good.
>>
>> Better than my Mandarin and Cantonese ;)
>>
>> Dave
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Li Ying
OK, I will do it,
But maybe tomorrow, because the local time is over 11PM now.



2010/10/20 Dave Newton :
>> (A)I am just a new guy of Struts2 community, if I put some message
>> into the Struts2 docs and it is not right, I will mislead so many
>> users, I will feel so~~~ sorry.
>
> Honestly, I'd rather see the documentation reflect current behavior,
> whether or not the behavior itself is correct. And if the
> documentation is *already* wrong... Plus if something gets in there
> that isn't well-written, it'll be corrected at some point.
>
>> (B)As you can see, my English is not good.
>
> Better than my Mandarin and Cantonese ;)
>
> Dave
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Dave Newton
> (A)I am just a new guy of Struts2 community, if I put some message
> into the Struts2 docs and it is not right, I will mislead so many
> users, I will feel so~~~ sorry.

Honestly, I'd rather see the documentation reflect current behavior,
whether or not the behavior itself is correct. And if the
documentation is *already* wrong... Plus if something gets in there
that isn't well-written, it'll be corrected at some point.

> (B)As you can see, my English is not good.

Better than my Mandarin and Cantonese ;)

Dave

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Li Ying
Actually I did not know about these, Sorry.

And
(A)I am just a new guy of Struts2 community, if I put some message
into the Struts2 docs and it is not right, I will mislead so many
users, I will feel so~~~ sorry.

(B)As you can see, my English is not good.


2010/10/20 Dave Newton :
> You know that (a) the dev team reads this list, and (b) I'm on the dev
> team, right?

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Dave Newton
You know that (a) the dev team reads this list, and (b) I'm on the dev
team, right?

On Wed, Oct 20, 2010 at 9:19 AM, Li Ying  wrote:
> If I am the author of this code, i think the priority order
> of these 3 TemplateLoaders should be:
> 1, WebappTemplateLoader
> 2,ClassTemplateLoader (when value of param [templatePath] is string
> starts with "class://") or FileTemplateLoader(when value of param
> [templatePath] is string starts with "file://")
> 3, StrutsClassTemplateLoader
>
> But I don't know what the intention of the author is.
> Is it a BUG or lack of updating document?
> I am not sure.
>
> So maybe we should send our investigation result to the develop team,
> see what they say.
>
>
>
> 2010/10/20 Dave Newton :
>> It's actually more likely the documentation needs to be updated.
>>
>> Perhaps you could get edit access to the wiki and update them?
>>
>> Dave
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Li Ying
If I am the author of this code, i think the priority order
of these 3 TemplateLoaders should be:
1, WebappTemplateLoader
2,ClassTemplateLoader (when value of param [templatePath] is string
starts with "class://") or FileTemplateLoader(when value of param
[templatePath] is string starts with "file://")
3, StrutsClassTemplateLoader

But I don't know what the intention of the author is.
Is it a BUG or lack of updating document?
I am not sure.

So maybe we should send our investigation result to the develop team,
see what they say.



2010/10/20 Dave Newton :
> It's actually more likely the documentation needs to be updated.
>
> Perhaps you could get edit access to the wiki and update them?
>
> Dave

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Dave Newton
It's actually more likely the documentation needs to be updated.

Perhaps you could get edit access to the wiki and update them?

Dave

On Wed, Oct 20, 2010 at 8:47 AM, Li Ying  wrote:
> No, I mean it works, but the value "template" has no meaning.
>
> Actually, if you set param [templatePath] (or [TemplatePath]) to any
> string which not start with "class://" or "file://", you will get the
> same result: templates under web root folder will be loaded.
>
> If you delete this param from web.xml, Struts2.2.1 will use the
> default setting (which is "class://") to create a ClassTemplateLoader.
> And this ClassTemplateLoader will get a higher priority than
> WebappTemplateLoader, that make templates under web root folder not
> loaded.
>
> I think this may be a BUG of Struts2, because this behavior is
> different from the Struts2 document.
> And, as adam said, it also different from the old version of Struts2.
>
>
> 2010/10/20 Dave Newton :
>> So you're saying it doesn't work for him?
>>
>> Dave
>>
>> On Wed, Oct 20, 2010 at 5:26 AM, Li Ying  wrote:
 Just add this to your web.xml:

    
        templatePath
        template
    
>>>
>>> The param [templatePath] can start with only "class://" or "file://".
>>> Otherwise, struts will ignore it and do not create a
>>> TemplateLoader for it.
>>>
>>> (See method [init] and [createTemplateLoader] of class
>>> [org.apache.struts2.views.freemarker.FreemarkerManager])
>>>
>>> So, the value "template" means noting, it will get the same result as
>>> setting it to a empty string or anything else.
>>>
>>> -
>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>>> For additional commands, e-mail: user-h...@struts.apache.org
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Li Ying
No, I mean it works, but the value "template" has no meaning.

Actually, if you set param [templatePath] (or [TemplatePath]) to any
string which not start with "class://" or "file://", you will get the
same result: templates under web root folder will be loaded.

If you delete this param from web.xml, Struts2.2.1 will use the
default setting (which is "class://") to create a ClassTemplateLoader.
And this ClassTemplateLoader will get a higher priority than
WebappTemplateLoader, that make templates under web root folder not
loaded.

I think this may be a BUG of Struts2, because this behavior is
different from the Struts2 document.
And, as adam said, it also different from the old version of Struts2.


2010/10/20 Dave Newton :
> So you're saying it doesn't work for him?
>
> Dave
>
> On Wed, Oct 20, 2010 at 5:26 AM, Li Ying  wrote:
>>> Just add this to your web.xml:
>>>
>>>    
>>>        templatePath
>>>        template
>>>    
>>
>> The param [templatePath] can start with only "class://" or "file://".
>> Otherwise, struts will ignore it and do not create a
>> TemplateLoader for it.
>>
>> (See method [init] and [createTemplateLoader] of class
>> [org.apache.struts2.views.freemarker.FreemarkerManager])
>>
>> So, the value "template" means noting, it will get the same result as
>> setting it to a empty string or anything else.
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Dave Newton
So you're saying it doesn't work for him?

Dave

On Wed, Oct 20, 2010 at 5:26 AM, Li Ying  wrote:
>> Just add this to your web.xml:
>>
>>    
>>        templatePath
>>        template
>>    
>
> The param [templatePath] can start with only "class://" or "file://".
> Otherwise, struts will ignore it and do not create a
> TemplateLoader for it.
>
> (See method [init] and [createTemplateLoader] of class
> [org.apache.struts2.views.freemarker.FreemarkerManager])
>
> So, the value "template" means noting, it will get the same result as
> setting it to a empty string or anything else.
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-20 Thread Li Ying
> Just add this to your web.xml:
>
>    
>        templatePath
>        template
>    

The param [templatePath] can start with only "class://" or "file://".
Otherwise, struts will ignore it and do not create a
TemplateLoader for it.

(See method [init] and [createTemplateLoader] of class
[org.apache.struts2.views.freemarker.FreemarkerManager])

So, the value "template" means noting, it will get the same result as
setting it to a empty string or anything else.

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: Overriding Templates

2010-10-20 Thread adam pinder

 
Hi Li / Maurizio,
 
thanks for your replies - i did receive the answer from another user yesterday 
too, he sent the following
 
Actually, I found the solution, and it works for me:
 
http://old.nabble.com/-S2--2.2.1-possible-freemarker-template-bug-td29462347.html
 
Just add this to your web.xml:
 
 
templatePath 
template 

 
it seems it has been noted by others (see link) and is a bug of sorts - could 
be it was supposed to be this way and struts2.0.11 didn't enforce it or it was 
just changed in later version and developer didn't realise full implications.
 
anyway, the addition of the context-param sorted out my problem.
 
thanks for your responses
 
adam

 
> Date: Wed, 20 Oct 2010 12:01:34 +0900
> Subject: Re: Overriding Templates
> From: liying.cn.2...@gmail.com
> To: user@struts.apache.org
> 
> Hi Maurizio:
> 
> In this document:
> http://struts.apache.org/2.2.1/docs/template-loading.html
> 
> It says the template should be searched in (in this order):
> 1, web app folder
> 2, class path
> 
> But i have read the Struts2.2.1 source code, it creates TemplateLoader
> in a different order, as i described in my earlier mail.
> 
> And, as adam said, the template under web app folder worked correctly
> in elder version of Struts2.
> 
> So i think, this is maybe a BUG of Struts2,
> or lack of updating document.
> Maybe we should send this issue to the development team of Struts2.
> 
> 
> 
> 2010/10/20 Maurizio Cucchiara :
> > @Adam
> >
> >> and they were placed into WebContent\template\simple folder
> >
> > you should start to investigate about your path correctness IMHO .
> > Struts usually finds freemarker template inside your classpath. In
> > order to enable struts to find your custom template file, you should
> > ensure that template files reside inside the
> > WEB-INF/classes/template/simple folder
> >
> > Hope this help
> >
> > --
> > Maurizio Cucchiara
> >
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
  

Re: Overriding Templates

2010-10-19 Thread Li Ying
Hi Maurizio:

In this document:
http://struts.apache.org/2.2.1/docs/template-loading.html

It says the template should be searched in (in this order):
1, web app folder
2, class path

But i have read the Struts2.2.1 source code, it creates TemplateLoader
in a different order, as i described in my earlier mail.

And, as adam said, the template under web app folder worked correctly
in elder version of Struts2.

So i think, this is maybe a BUG of Struts2,
or lack of updating document.
Maybe we should send this issue to the development team of Struts2.



2010/10/20 Maurizio Cucchiara :
> @Adam
>
>> and they were placed into WebContent\template\simple folder
>
> you should start to investigate about your path correctness IMHO .
> Struts usually finds freemarker template inside your classpath. In
> order to enable struts to find your custom template file, you should
> ensure that template files reside inside the
> WEB-INF/classes/template/simple folder
>
> Hope this help
>
> --
> Maurizio Cucchiara
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-19 Thread Maurizio Cucchiara
@Adam

> and they were placed into WebContent\template\simple folder

you should start to investigate about your path correctness IMHO .
Struts usually finds freemarker template inside your classpath. In
order to enable struts to find your custom template file, you should
ensure that template files reside inside the
WEB-INF/classes/template/simple folder

Hope this help

--
Maurizio Cucchiara

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Overriding Templates

2010-10-19 Thread Li Ying
With a lot of debugging, I think i have found what's wrong.

If you use the default setting,

In method [createTemplateLoader] of class
[org.apache.struts2.views.freemarker.FreemarkerManager],
Struts will create 3 TemplateLoader which is:
1,ClassTemplateLoader, which will load Template from class url
2,WebappTemplateLoader, which will load Template from WebApp folder
3,StrutsClassTemplateLoader, I don't known what different with
ClassTemplateLoader

The 3 TemplateLoader will be executed in this order,
which means, the ClassTemplateLoader get higher priority than
WebappTemplateLoader.
(See method [findTemplateSource] of class
[freemarker.cache.MultiTemplateLoader])

So, if you simply put your template under the WebApp folder,
it will not be used, because the ClassTemplateLoader will load the old
template from struts2-core-2.2.1.jar.

I think it may be a Struts2 bug, because this result is obviously
different from the Struts2 document, but i am not very sure about it.


Before they fix this bug, i suggest you add this setting in your web.xml:


TemplatePath



It will make FreemarkerManager not to create ClassTemplateLoader, so
the WebappTemplateLoader will get highest priority.
I tested it, and it works in my environment.

Or you can set this parameter to:

TemplatePath
class://package

and put your template under the [package].
But i did not test this solution.

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: Overriding Templates

2010-10-19 Thread adam pinder

 
The theme is set to simple as was for struts 2.0.11
My struts.xml is very plain and i don't see it would help with this particular 
issue.
 
My jsp contains the following 
 



 
 
The revised templates were overriding the jar templates in 2.0.11 just not in 
2.2.1 - no code changes have been made so it must be something in how latest 
struts2 is working.
 
Looking at the templates for action message/errors in latest jar - they have 
additonal text regarding parameters etc.. i wondered if maybe the amended 
templates are now invalid in some 
way and so it reverts back to templates in jar file - no errors are logged 
though.
 
My action error template contains the following 
 
<#if (actionErrors?exists && actionErrors?size > 0)>

<#list actionErrors as error>
${error}



 
Adam

 
> Date: Tue, 19 Oct 2010 11:39:13 +0900
> Subject: Re: Overriding Templates
> From: liying.cn.2...@gmail.com
> To: user@struts.apache.org
> 
> Hi adam:
> 
> what theme are you using?
> 
> The default theme in Struts2.2.1 is [xhtml].
> 
> Maybe you need change the default theme or the theme of your tag to [simple].
> 
> Can you show us your setting file(struts.xml and so on) and your jsp code?
> 
> 
> 2010/10/19 adam pinder :
> >
> >
> >
> > I have just upgraded struts2 version from 2.0.11 to 2.2.1 and one issue 
> > seems to be that i have amended templates
> >
> > actionerror.ftl
> > actionmessage.ftl
> >
> > and they were placed into WebContent\template\simple folder in the web app 
> > and with 2.0.11 they overrided the templates in the struts2 core jar file 
> > correctly...
> >
> > with 2.2.1 it's now always using the templates in the struts2 core jar even 
> > though i can see inside this jar the folder structure and filenames have 
> > not changed..
> >
> > with 2.2.1 do you need to place the overriding templates in a different 
> > folder for it to work ?
> >
> > note. i have upgraded other jars as it seemed appropriate for this struts 
> > version.
> >
> > thanks
> > adam
> >
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
  

Re: Overriding Templates

2010-10-18 Thread Li Ying
Hi adam:

what theme are you using?

The default theme in Struts2.2.1 is [xhtml].

Maybe you need change the default theme or the theme of your tag to [simple].

Can you show us your setting file(struts.xml and so on) and your jsp code?


2010/10/19 adam pinder :
>
>
>
> I have just upgraded struts2 version from 2.0.11 to 2.2.1 and one issue seems 
> to be that i have amended templates
>
> actionerror.ftl
> actionmessage.ftl
>
> and they were placed into WebContent\template\simple folder in the web app 
> and with 2.0.11 they overrided the templates in the struts2 core jar file 
> correctly...
>
> with 2.2.1 it's now always using the templates in the struts2 core jar even 
> though i can see inside this jar the folder structure and filenames have not 
> changed..
>
> with 2.2.1 do you need to place the overriding templates in a different 
> folder for it to work ?
>
> note. i have upgraded other jars as it seemed appropriate for this struts 
> version.
>
> thanks
> adam
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org