public class ConditionalComment
extends javax.faces.component.UIComponentBase
ConditionalComment is an UIComponent which renders a conditional comment. Conditional
comments are an IE specific feature which enables the developer to (out)comment blocks of HTML depending on whether
the client is using IE and if so even which version. They are often seen in combination with CSS stylesheets like so:
<!--[if lte IE 7]> <link rel="stylesheet" href="ie6-ie7.css" /> <![endif]-->
However, Facelets renders them HTML-escaped and if javax.faces.FACELETS_SKIP_COMMENTS context param is
set to true then it will even not be rendered at all. You would need to workaround this with an ugly
<h:outputText escape="false">.
<h:outputText value="<!--[if lte IE 7]><link rel="stylesheet" href="ie6-ie7.css" /><![endif]-->" escape="false" />
This component is designed to solve this problem.
<o:conditionalComment if="lte IE 7"> <link rel="stylesheet" href="ie6-ie7.css" /> </o:conditionalComment>
Note that you cannot use this with <h:outputStylesheet> as it would implicitly be relocated as
direct child of <h:head>.
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
COMPONENT_FAMILY
The standard component family.
|
static java.lang.String |
COMPONENT_TYPE
The component type.
|
| Constructor and Description |
|---|
ConditionalComment() |
| Modifier and Type | Method and Description |
|---|---|
void |
encodeChildren(javax.faces.context.FacesContext context)
Encode the conditional comment.
|
java.lang.String |
getFamily()
Returns
COMPONENT_FAMILY. |
java.lang.String |
getIf()
Returns the if condition.
|
boolean |
getRendersChildren()
Returns
true. |
void |
setIf(java.lang.String _if)
Sets the if condition.
|
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeBegin, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBindingencodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent, visitTreepublic static final java.lang.String COMPONENT_TYPE
public static final java.lang.String COMPONENT_FAMILY
public java.lang.String getFamily()
COMPONENT_FAMILY.getFamily in class javax.faces.component.UIComponentpublic boolean getRendersChildren()
true.getRendersChildren in class javax.faces.component.UIComponentBasepublic void encodeChildren(javax.faces.context.FacesContext context)
throws java.io.IOException
encodeChildren in class javax.faces.component.UIComponentBasejava.lang.IllegalArgumentException - When if attribute is not specified.java.io.IOExceptionpublic java.lang.String getIf()
public void setIf(java.lang.String _if)
_if - The if condition.