public class ConditionalComment extends OutputFamily
The <o:conditionalComment>
component 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 the comment's contents HTML-escaped which makes it unusable.
<!--[if lte IE 7]> <link rel="stylesheet" href="ie6-ie7.css" /> <![endif]-->
Also, 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>
.
OutputFamily
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_TYPE
The component type.
|
COMPONENT_FAMILY
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
Constructor and Description |
---|
ConditionalComment() |
Modifier and Type | Method and Description |
---|---|
void |
encodeBegin(FacesContext context) |
void |
encodeEnd(FacesContext context) |
String |
getIf()
Returns the if condition.
|
void |
setIf(String condition)
Sets the if condition.
|
getFamily, getRendersChildren
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeChildren, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
public static final String COMPONENT_TYPE
public void encodeBegin(FacesContext context) throws IOException
encodeBegin
in class UIComponentBase
IllegalArgumentException
- When if
attribute is not specified.IOException
public void encodeEnd(FacesContext context) throws IOException
encodeEnd
in class UIComponentBase
IOException
public String getIf()
public void setIf(String condition)
condition
- The if condition.Copyright © 2012–2018 OmniFaces. All rights reserved.