org.omnifaces.component.output
Class ConditionalComment

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by org.omnifaces.component.output.OutputFamily
              extended by org.omnifaces.component.output.ConditionalComment
All Implemented Interfaces:
java.util.EventListener, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder

public class ConditionalComment
extends OutputFamily

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="&lt;!--[if lte IE 7]&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;ie6-ie7.css&quot; /&gt;&lt;![endif]--&gt;" 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

Field Summary
static java.lang.String COMPONENT_TYPE
          The component type.
 
Fields inherited from class org.omnifaces.component.output.OutputFamily
COMPONENT_FAMILY
 
Fields inherited from class javax.faces.component.UIComponent
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
 
Constructor Summary
ConditionalComment()
           
 
Method Summary
 void encodeChildren(javax.faces.context.FacesContext context)
          Encode the conditional comment.
 java.lang.String getIf()
          Returns the if condition.
 void setIf(java.lang.String _if)
          Sets the if condition.
 
Methods inherited from class org.omnifaces.component.output.OutputFamily
getFamily, getRendersChildren
 
Methods inherited from class javax.faces.component.UIComponentBase
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, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getListenersForEventClass, getNamingContainer, getResourceBundleMap, getStateHelper, getStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, setInView, setValueExpression, subscribeToEvent, unsubscribeFromEvent, visitTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_TYPE

public static final java.lang.String COMPONENT_TYPE
The component type.

See Also:
Constant Field Values
Constructor Detail

ConditionalComment

public ConditionalComment()
Method Detail

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context)
                    throws java.io.IOException
Encode the conditional comment.

Overrides:
encodeChildren in class javax.faces.component.UIComponentBase
Throws:
java.lang.IllegalArgumentException - When if attribute is not specified.
java.io.IOException

getIf

public java.lang.String getIf()
Returns the if condition.

Returns:
The if condition.

setIf

public void setIf(java.lang.String _if)
Sets the if condition.

Parameters:
_if - The if condition.