XHTML Transitional rel attribute alternative - validation

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.

Related

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.

Freemarker Variable replacement behavior modification

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?

how to valid there is no attribute "checked" in xhtml 1.0 validation

i have use
Default style
for style sheet switch but this code is not valid and i have error in http://validator.w3.org
how i can fix this error?
simple, take out the checked='checked' out of your a tag. It's not a valid attribute for an 'a' tag in either xhtml strict or transitional
you'll have to come up with another way to store the style sheetswitch. possibly storing your checked option in the class instead, and checking that the class contains 'checked'.

Struts 2 - Conditionallly display elements on page based on validation errors

I'm looking into the fielderror tag for struts and was wondering if it was possible to conditionally show certain elements on the page based on whether or not there are any validation errors. I want to do something like this (which currently does not do what i want it to):
<s:fielderror>
This is a test link
<s:param>field1</s:param>
<s:param>field2</s:param>
<s:param>field2</s:param>
</s:fielderror>
I would like the anchor tag to show up ONLY if one of the fields referenced by the param tags is invalid. In other words, if something is invalid in this fielderror block, I would like to display some HTML. The way it is coded above, the anchor tag is always displayed.
I think I can certainly do this with jQuery, but i was wondering if there was a way to do this natively in Struts that perhaps I'm overlooking. I've tried looking at things like the label and title attribute, but nothing seems to be working.
thanks in advance!
~j
There's nothing out-of-the-box, at least not like the way you want it.
Personally, I find your construct quite counter-intuitive: it doesn't execute/render like it reads.
A few options: do it "manually", create a tag to do it, or do it outside of the view. All rely on using ValidationAware.getFieldErrors() to grab the map and do some minimal logic.
The manual approach would use <s:if> to check for the presence of fieldErrors['fieldName'] for each field. Wrapped up in a simplistic JSP-based custom tag would produce something like:
<if:fieldErrors for='field1, field2, field3'>
<a ...>
</if:fieldErrors>
IMO doing most of the work in Java is cleaner, and easier to test. This could mean doing all the work in the action (or utility) and exposing only a single flag to the view, or using a thin JSP-based tag to call the utility. Either way, it's easier to test outside of a container, and removes inappropriate view logic.

xHTML 1.0 strict - Validate iFrames

Is it possible to validate iFrames in xhtml 1.0 strict? Preferably without any use of javascript to inject the iframe into the page.
I know there is no point in validating just for the sake of validation, but lets just say that I like the green validation message on w3c ;) (I am forced by factors beyond my control to use iframes)
Or maybe there is something very similar I can use in xHTML to get iframe-like behavior without losing compatibility across different browsers? (object?)
Perhaps there is a way to add a second doctype containing iframe rules?
i'm not sure but I think you can include another page with object as you suggest.
<object data="/another.html" type="text/html"></object>
If you need iframes, use Transitional instead of Strict. The point of it is for when you need to use legacy features like iframes.

Resources