public class NoAutoGeneratedIdViewHandler extends ViewHandlerWrapper
This ViewHandler
once installed will during development stage throw an IllegalStateException
whenever
an automatically generated JSF component ID (j_id...
) is encountered in the rendered output.
This has various advantages:
Note that this does not check every component for its ID directly, but instead checks the ResponseWriter
for
writes to the "id" attribute. Components that write their markup in any other way won't be checked and will thus
slip through.
Register it as <view-handler>
in faces-config.xml
.
<application> <view-handler>org.omnifaces.viewhandler.NoAutoGeneratedIdViewHandler</view-handler> </application>
Note that this only runs if Application.getProjectStage()
equals to ProjectStage.Development
.
Modifier and Type | Class and Description |
---|---|
static class |
NoAutoGeneratedIdViewHandler.NoAutoGeneratedIdResponseWriter
This response writer throws an
IllegalStateException when an attribute with name "id" is written with
a non-null value which starts with UIViewRoot.UNIQUE_ID_PREFIX or contains an intermediate. |
CHARACTER_ENCODING_KEY, DEFAULT_FACELETS_SUFFIX, DEFAULT_SUFFIX, DEFAULT_SUFFIX_PARAM_NAME, DISABLE_FACELET_JSF_VIEWHANDLER_PARAM_NAME, FACELETS_BUFFER_SIZE_PARAM_NAME, FACELETS_DECORATORS_PARAM_NAME, FACELETS_LIBRARIES_PARAM_NAME, FACELETS_REFRESH_PERIOD_PARAM_NAME, FACELETS_SKIP_COMMENTS_PARAM_NAME, FACELETS_SUFFIX_PARAM_NAME, FACELETS_VIEW_MAPPINGS_PARAM_NAME
Constructor and Description |
---|
NoAutoGeneratedIdViewHandler(ViewHandler wrapped)
Construct a new No Auto Generated Id view handler around the given wrapped view handler.
|
Modifier and Type | Method and Description |
---|---|
ViewHandler |
getWrapped() |
void |
renderView(FacesContext context,
UIViewRoot viewToRender) |
addProtectedView, calculateCharacterEncoding, calculateLocale, calculateRenderKitId, createView, deriveLogicalViewId, deriveViewId, getActionURL, getBookmarkableURL, getProtectedViewsUnmodifiable, getRedirectURL, getResourceURL, getViewDeclarationLanguage, initView, removeProtectedView, restoreView, writeState
public NoAutoGeneratedIdViewHandler(ViewHandler wrapped)
wrapped
- The wrapped view handler.public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException
renderView
in class ViewHandlerWrapper
IOException
public ViewHandler getWrapped()
getWrapped
in interface FacesWrapper<ViewHandler>
getWrapped
in class ViewHandlerWrapper
Copyright © 2012–2017 OmniFaces. All rights reserved.