Re: Configuration capabilities
kukudas <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hello again,
thanks for your reply. I think you are right, it should work because the
"rest" works fine too.
i'm using struts 2 and using spring to create the action objects and inject
them with dependecys.
i will follow this and when i have comeup with a solution or solved it i
will let you know why it didnt worked.
thanks again for your support.
greets
kukudas
Daniel Dekany wrote:
>
> Monday, June 16, 2008, 4:25:39 PM, kukudas wrote:
>
>> Hi,
>>
>> thanks again for your reply.
>> The Error i get is this:
>>
>> Error reading imported file spring.ftl
>> The problematic instruction:
>> ----------
> ==>> import "/spring.ftl" as spring [on line 2, column 1 in index.ftl]
>>
>> Basicly he doesn't find the template. It's strange i have the jar file on
>> WEB-INF/lib/ so it normaly should work.
>
> I suppose the whole stuff runs under Spring, so the jar must be
> visible or the whole Web Application were fail to start. Unless, your
> Web server uses some tricky class loader that ban the FreeMarker
> classes to get the Spring classes. Also, you should look into the logs
> for details... maybe you didn't set up the Spring FreeMarker support
> properly, etc.
>
>> Daniel Dekany wrote:
>>>
>>> Friday, June 13, 2008, 11:02:12 AM, kukudas wrote:
>>>
>>>> Hello,
>>>>
>>>> thanks for your reply well the goal i want is somehow define a place
>>>> wher
>>>> ei
>>>> can store templates as moduls.
>>>> and let it wire up on the view by my framework struts 2 or alternatevly
>>>> spring.
>>>> i found something like this:
>>>>
>>>> <bean id="freemarkerConfig"
>>>> class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
>>>> <property name="templateLoaderPath" value="/WEB-INF/freemarker/"/>
>>>> </bean>
>>>>
>>>> but somehow i cant acces <#import "spring.ftl" as spring> like it is in
>>>> the
>>>> examples?
>>>
>>> It's a Spring question, as the templateLoaderPath is a Spring specific
>>> setting, it's not defined by FreeMarker. But, AFAIK Spring does this:
>>> When you request "/foo.ftl", then assuming we are using your
>>> configuation, it first tries to load the template from
>>> <ApplicationContextDir>/WEB-INF/freemarker/foo.ftl, and if the file is
>>> not there then it also tries to load it using the class loader from
>>> org/springframework/web/servlet/view/freemarker/foo.ftl. And since
>>> "spring.ftl" is in the org.springframework.web.servlet.view.freemarker
>>> package and the Spring jar(s) are in the class path, your import
>>> should work. Well, except that you should write "/spring.ftl" (note
>>> the slash), but that causes problem only if your template is in a
>>> subdirectory of WEB-INF/freemarker. What error message you get?
>>>
>>>> i'm not sure if i have to make the folder actualy and copy the
>>>> spring.ftl from the jar file
>>>
>>> Definitely not. Copying could cause maintenance problems when you or
>>> someone else updates the spring jars. Also of course it would be
>>> awkward.
>>>
>>>> into it but when i tried that it didnt work either.
>>>
>>>> for struts 2 i found this:
>>>> <init-param>
>>>> <param-name>TemplatePath</param-name>
>>>> <param-value>WEB-INF/freemarker/</param-value>
>>>> </init-param>
>>>> do i have to do this init params under the FilterDispatcher?
>>>
>>> I don't know this one... ask the Struts 2 guys.
>>>
>>>> i guess i have to read the programmers guide i mostly read only the
>>>> other part and just looked over the programmer part.
>>>
>>> It seems your questions are specific to Spring and/or Struts 2, so the
>>> FreeMarker programmers guide may will not help here. It's rather for
>>> those who add FreeMarker support to a Web Application Framework or use
>>> FreeMarker directly without a framework.
>>>
>>>> Anyway Thank you for you help.
>>>>
>>>>
>>>> Daniel Dekany wrote:
>>>>>
>>>>> Thursday, June 12, 2008, 3:03:27 PM, kukudas wrote:
>>>>>
>>>>>> Hello everybody,
>>>>>>
>>>>>> i did now successfully set up a little test project with struts 2
>>>>>> and
>>>>>> freemarker it's still "low" but it's working :). I have one question
>>>>>> i'm
>>>>>> using in my action something like this:
>>>>>>
>>>>>> Configuration c = new Configuration();
>>>>>> c.setDirectoryForTemplateLoading(new File("C:/MyModules/All/"));
>>>>>> c.getTemplate("module.ftl");
>>>>>>
>>>>>> which kinda works i don't get any exception or so. But i dont know
>>>>>> how
>>>>>> to
>>>>>> use this now
>>>>>> on my view. Like somehow a reference <#include c> or so i kinda don't
>>>>>> find
>>>>>> any examples just some
>>>>>> code snipplets which i put together and try out but well ...
>>>>>
>>>>> Huh?
>>>>>
>>>>>> Is there maybe any source for newbies i'm mean you guys had to learn
>>>>>> this
>>>>>> someway :).
>>>>>
>>>>> I think http://freemarker.org/docs/pgui_quickstart.html tells how to
>>>>> use FreeMarker on the programmer's side quite clearly. Also there are
>>>>> some examples packed with the "examples" directory of the FreeMarker
>>>>> distro, including a Struts 1.x example.
>>>>>
>>>>>> In the Documentation i've read so far it's kinda thin i gues sits
>>>>>> writting for users they have more expierince then me. What i'm
>>>>>> missing is like what i can do after i load a certain template.
>>>>>
>>>>> After you get a template, you have a Template object, that you can
>>>>> "process", i.e., merge with a data-model, for as many times as you
>>>>> want. But I guess that was clear. If not, then you missed the Getting
>>>>> Started stuff linked above.
>>>>>
>>>>> Well, something that the Getting Started doesn't mention that you can
>>>>> create the freemarker.core.Environment manually, as shown in
>>>>> http://freemarker.org/docs/app_faq.html#faq_question_19, which lets
>>>>> you adjust or read the runtime environment of the template both before
>>>>> and after the template is processed.
>>>>>
>>>>>> Like manipulate it
>>>>>
>>>>> No... Template objects are immutable. OK, not quite, but basically
>>>>> yes.
>>>>>
>>>>>> (which i proably don't want to do but still to know how would be
>>>>>> nice) or to set it up on diffrend views.
>>>>>
>>>>> I don't know what you mean by this.
>>>>>
>>>>>> maybe i'm just not searching hard enough for sources but i feel like
>>>>>> i
>>>>>> do. I
>>>>>> hope anyone could help me with examples/sources and i hope i don't
>>>>>> annoye
>>>>>> you guys with my newbie questions.
>>>>>
>>>>> But what *exactly* is your question?
>>>>>
>>>>>> greets kukudas
>>>>>
>>>>> --
>>>>> Best regards,
>>>>> Daniel Dekany
>>>
>>> --
>>> Best regards,
>>> Daniel Dekany
>>>
>>>
>>> -------------------------------------------------------------------------
>>> Check out the new SourceForge.net Marketplace.
>>> It's the best place to buy or sell services for
>>> just about anything Open Source.
>>> http://sourceforge.net/services/buy/index.php
>>> _______________________________________________
>>> FreeMarker-user mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>>
>>>
>>
>
> --
> Best regards,
> Daniel Dekany
>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
>
--
View this message in context: http://www.nabble.com/Configuration-capabilities-tp17799498p17882271.html
Sent from the freemarker-user mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php