- java.lang.Object
-
- jakarta.faces.component.UIComponent
-
- jakarta.faces.component.UIComponentBase
-
- org.omnifaces.component.output.OutputFamily
-
- org.omnifaces.component.output.ConditionalComment
-
- All Implemented Interfaces:
PartialStateHolder,StateHolder,TransientStateHolder,ComponentSystemEventListener,FacesListener,SystemEventListenerHolder,EventListener
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
jakarta.faces.FACELETS_SKIP_COMMENTScontext param is set totruethen 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>.- Author:
- Bauke Scholtz
- See Also:
OutputFamily
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOMPONENT_TYPEThe component type, which is "org.omnifaces.component.output.ConditionalComment".-
Fields inherited from class org.omnifaces.component.output.OutputFamily
COMPONENT_FAMILY
-
Fields inherited from class jakarta.faces.component.UIComponent
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 Summary
Constructors Constructor Description ConditionalComment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencodeBegin(FacesContext context)voidencodeEnd(FacesContext context)StringgetIf()Returns the if condition.voidsetIf(String condition)Sets the if condition.-
Methods inherited from class org.omnifaces.component.output.OutputFamily
getFamily, getRendersChildren
-
Methods inherited from class jakarta.faces.component.UIComponentBase
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
-
Methods inherited from class jakarta.faces.component.UIComponent
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
-
-
-
-
Field Detail
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The component type, which is "org.omnifaces.component.output.ConditionalComment".- See Also:
- Constant Field Values
-
-
Method Detail
-
encodeBegin
public void encodeBegin(FacesContext context) throws IOException
- Overrides:
encodeBeginin classUIComponentBase- Throws:
IllegalArgumentException- Whenifattribute is not specified.IOException
-
encodeEnd
public void encodeEnd(FacesContext context) throws IOException
- Overrides:
encodeEndin classUIComponentBase- Throws:
IOException
-
getIf
public String getIf()
Returns the if condition.- Returns:
- The if condition.
-
setIf
public void setIf(String condition)
Sets the if condition.- Parameters:
condition- The if condition.
-
-