I have a problem with Struts2, the problem is, the client want the styling of the web apps is dynamic, for example is, i can put the template (.html / .ftl) on /apps/template/path where all the logic on war, can i do that?
i've been searching all over google and that style of code is belong to freemarker. but if using freemarker, i have to code using servlet (i dont wanna do that).
Can you give me the hint/solution, or it really cant be in Struts2?
if using freemarker, i have to code using servlet
No, FreeMarker doesn't need Servlets instead of Actions.
FreeMarker is fully integrated in Struts2, it just needs the library in your libs directory and some little configuration in struts.xml and web.xml.
According to Struts2 documentation,
Template Loading
The framework looks for FreeMarker templates in two locations (in this
order):
Web application
Class path
This ordering makes it ideal for providing templates inside a
fully-built jar, but allowing for overrides of those templates to be
defined in your web application. In fact, this is how you can override
the default UI tags and Form Tags included with the framework.
In addition, you can specify a location (directory on your file
system) through the templatePath or TemplatePath context variable (in
the {{web.xml)}. If a variable is specified, the content of the
directory it points to will be searched first. This variable is
currently NOT relative to the root of your application.
So, if you want to use .FTL files (FreeMarker Templates) INSTEAD of JSP files, you can put them outside the ear, in the file system.
Like this (web.xml):
<!-- FreemarkerServlet settings: -->
<init-param>
<param-name>TemplatePath</param-name>
<param-value>/apps/template/path</param-value>
</init-param>
Related
I have installed typo3 extension "cookieman". The documentation says it comes with 2 static templates. Include the static TypoScript “Cookieman” in your root template or reference the necessary files in your site package. what is the location of a root template? and what is the syntax to include something?
first: be clear what Template means in this context.
there are multiple kinds of template in TYPO3.
There are HTML-templates which define the structure of parts of the output. That could be Fluid-templates or the older marker-based templates.
Then there are records which contain the typoscript configuration which also are called templates.
This typoscript-templates are meant. As the typoscript templates can be stored in each page of your page tree, which are concatenated, you have a root-template propably in the root-page of your website. (the added ts-template are called extension-templatesas they extend the basic configuration).
These records have a field for additional templates from TYPO3 extensions which are called static templates as they come from an extension and are never changed (never change any file from an extension inside the extension folders!!! you always can override the values).
Otherwise you can use explicit include statements in a typoscript configuration. The include statement was invented in TYPO3 4.6 and has changed it's syntax slightly until now. In the online-manual you can select your version to see syntax of your TYPO3 version.
I am using SpringBoot for my Web application and I was wondering why I have to have two folders, one for the templates and another one for "static"(css,js,etc..).
Can't I configure it for having just one folder, placing the "static" content inside my templates folder?
Thanks.
Usually the folder templates contains files that are transformed server-side with a library like freemarker etc. to add dynamic content before being sent to the client, while static contains files that are sent directly as is.
I am a newbie to meteor. I wonder how meteor works without directory structure. Usually web server runs index file in default, and MVC frameworks have route, controllers, model and view in a specific directory structure with file naming. I understand somehow meteor identifies Client code by Meteor.isClient and Server code by Meteor.isServer. I want to know how it identifies default index file? And explain me how the structure works?
There is no index. From the docs:
When your app is loaded, it automatically renders the special template
called <body>, which is written using the element instead of a
. You insert a template inside another template by using the
{{> inclusion}} operator.
<!-- in myapp.html -->
<body>
<h1>Today's weather!</h1>
{{> forecast}}
</body>
So put your tags in any html file and it will find them. I usually put them in a file called body.html so I know where they are.
As far as structuring your app, again from the docs
You don't always have to use Meteor.isClient. There are some special folders in Meteor. Two of them are client and server. Putting code in these folders will load that code only in the client or only in the server. There are more special names explained in the documentation.
We have legacy code to maintain and, to solve a specific customer customization problem, we want to route calls to some files to other files. That is, when the app calls a particular ASPX, it will end up hitting another ASPX.
If you call:
www.foo.com/admin/admin.aspx
It will actually hit:
www.foo.com/customizations/customer1/admin/admin.aspx
This is not a good design but this is legacy code. We just want to solve this.
We are using the System.Web.Routing framework to solve it. This works fine when you set RouteExistingFiles to true, except for static files (CSS, JavaScript and Images).
When I first tried it, it retrieved this error:
There is no build provider register for the extension '.css'.
So I did register a build provider in the web.config file for the .css extension. I used this build provider: PageBuilderProvider because someone recommended it in the internet.
It works! But the CSS is being served with text\html content type.
How do I achieve this?
TL;DR: I want to use routes in ASP.NET Web Forms to make a call for a specific CSS file to actually retrieve another one. A customer needs this for customization.
Try coding a HttpHandler. I had to do something similar but for PDF files, I coded a custom HttpHandler in the end - works very well. You can even set the content type in the HttpHandler code and have a pattern matched path the handler will be used for in the web.config. You can also configure it in web.config not to execute if the path does not point to an existing file e.g. so a 404 is returned without having to code that in the handler itself. I can't post my code (VB.NET) ATM because I'm using a tablet but google search for tutorials. You will also probably need to use the TransmitFile function to actually write out the css file. Is it a web forms project or web site? If its a web site there is a special way of registering the HttpHandler in the web.config.
I am building an application with Spring MVC and jquery for UI. The UI developer is designing the pages using jQuery without using any server (as it is not required). The pages are integrated by developers in the application.
The issue here is that the UI designer is using relative directory path and to integrate these pages, paths need to be prefixed with spring resource path. Even the JS and CSS files are referring to images with relative directory path. Every time the UI is update same process is repeated for integration.
What I want to know is there any better approach in this case so that
the relative path used by ui developer doesn't needs to be changed every time for integration.
The spring static resource loading can still be used. <mvc:resources mapping="/res/**" location="/resources/" />
The path reference in any js or css file can also work without any changes in it.
I do not want to do anything which tightly couple it with a server. Please help.
lookup util:constant in the spring documentation and see if that is helpful.