Freemarker Variable replacement behavior modification - freemarker

I am working on JSF based application which has to generate different views (1. PDF, 2. Readonly XHTML, 3. XHTML with FORM backed by a JSF backing bean) from a single docx template. This docx template is based on Freemarker variables. The data model for the Freemarker template engine is DynamicEntity see http://www.eclipse.org/eclipselink/api/2.0/org/eclipse/persistence/dynamic/DynamicEntity.html
For generation of XHTML with FORM backed by a JSF backing bean, I want to mark certain variables in the docx template as Editable e.g. ${edit_customer.name} and during the template engine replacement process instead of trying to replace them with a value from data model, I want to replace them with JSF EL expressions e.g < h:inputtext value="#{customer.name}" />. So at the end I would have one docx. template with special markers which would have special meaning for Editable XHTML and have to ignore them for PDF/Readonly-XHTML.
I looked at Freemarker source code to find the hooking point where I can change the variable deplacement behavior but could not find any clue. The things there are declared final and not extensible :(
Does anyone has idea how can achieve the above requirement?

Related

How to perform an XI:INCLUDE in Orbeon 4.10 form builder

Trying to include a set of common sections and fields in all my forms. Forms were built using the form builder so I tried using the xi:include tag but the page stops working when I put the tag in. It does not matter what href parameter I provide. The form stops working.
You cannot just include a form into another one: the structure of the resulting document will not be compatible with what Form Runner expects. And that's because a form, or a section thereof, includes parts which belong to the model, and parts which belong to the view.
The main way to reuse parts of a form is to use section templates.
You can also write custom model logic.

Using a custom html tag in CKEditor

I am trying to integrate CKEditor into an internal PHP application, where in the past I was just pasting my HTML into a textarea field in a form.
This HTML that I am submitting in the form is for a custom template system that uses custom tags. These custom tags would then be replaced with real data by my backend. For example, an invoice would have the custom tag <%INVOICE#%>, which my backend would replace with the correct invoice number.
When using CKEditor, these types of tags are being converted into htmlentities such as <%INVOICE#>, which breaks my string replacement on the backend.
Is there a way to make CKEditor recognize tags that are in the format <%*%> and not convert them in any way?
The simplest way to protect those tags against modifications would be to use config.protectedSource. With Show Protected plugin (3rd party addon), you could even see the protected code in wysiwyg area.
A more user friendly solution would be to adopt the widget-based Placeholder plugin to recognize the syntax you use for custom tags. This plugin is just a proof of concept solution, so you can improve it in any way you like. E.g. by offering a select element to the end user with the list of valid placeholders instead of asking to type them manually.
Widgets are powerful, which means that it is technically possible to write even a plugin that returns <%INVOICE#%> in source code, but shows the real invoice number in wysiwyg area.

Block asp.net mvc Html creation in using scope

I use an HTML helper that returns an IDisposable to create a specific DIV structure that I need very often in my application. The constructor of this class creates the open divs while the Dispose method created to closing Divs. Now I need to secure my application and I would like this structure not to be created in some condition but I also need that every kind of HTML that this produced between using and the end if its scope is also not rendered.
First thing I did was to replace the TextWriter found int he ViewContext with dummy :
_helper.ViewContext.Writer = new StringWriter(new StringBuilder());
Its working for each piece of code that directly uses the ViewContext Writer to render HTML but not for the others (raw HTML and other helper)
So the question is : How can we prevent a Asp.net view to render HTML within the scope of a using block ?
I am afraid that currently there's no way of preventing the contents of a using block to be rendered. That was not the original intent of this block anyway. If you want to prevent something from being rendered you might consider using an if statement instead.
I have no example code for you, and this idea is pretty hackish but may work if you have a zillion of these things you need to secure and don't have time to add condition logic.
What if you used the app's Response.Filter to strip out html? Then in your constructor and dispose methods, if the user isn't authorized to see the content, output some easy to find elements that you could either regex replace or use Html Agility Pack to parse/modify the DOM before the stream is sent to the browser.

Spring 3.0 (form:select, form:option(s) ) tag library supports HTML 5 data-* attributes

Spring 3.0 (form:select, form:option(s) ) tag library supports rendering HTML 5 data-* attributes using a bean's property? If yes , an example would help.
Background : I am developing a Spring MVC app and using Bootstarp css and JS and spring provided tags. Need to use HTML 5 data-* attributes to keep additional data with dropdowns options. Based upon the user selection in one of the dropdown , I want update further dropdowns and I want to avoid AJAX calls to fetch options for next dropdown since I have the data during page load.
I understand JQuery has attribute support but that would require javascript code execution on page load, so looking for HTML 5 support. Any other suggestions to handle this are welcome.
Data-* attributes are supported on Spring 3.0 form tags (along with any validly-named custom attribute you specify, I believe). You can also use the value of a bean's property as the attribute value, e.g.
<form:input data-test="${myBean.propertyName}" path="propertyName" />
To answer the second part of your question, where you ask if there's a way to get the Spring form tag library to populate the data-* attributes with the contents of the bean's property that you specify, this does not happen automatically: you would need to write a custom tag that does this.

XHTML Transitional rel attribute alternative

I'm trying to add some custom data within a tag to reference later in a jQuery call, and I usually use "rel=" for something like this. However, I'm working in an XHTML Transitional document, and it gives me a "there is no rel attribute".
Are there any alternate attributes I can use to attach custom data to an HTML tag while still keeping the document valid?
If you care much about XHTML validity in the case you mentioned, a common practice is to use the class attribute and space different things there.
HTML5 allows this via the data attribute or rather prefixing your own custom attributes with data-, e.g. data-my-var="hello". But this is invalid in XHTML.

Resources