Class NoAutoGeneratedIdViewHandler

  • All Implemented Interfaces:

    public class NoAutoGeneratedIdViewHandler
    extends ViewHandlerWrapper

    This ViewHandler once installed will during development stage throw an IllegalStateException whenever an automatically generated Faces component ID (j_id...) is encountered in the rendered output. This has various advantages:

    • Keep the HTML output free of autogenerated Faces component IDs.
    • No need to fix the IDs again and again when the client side unit tester encounters an unusable autogenerated ID.
    • Make the developer aware which components are naming containers and/or implicitly require outputting its ID.

    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.

    Additionally, since version 3.0 it will also log a warning line when prependId="false" is encountered. This is considered bad practice. See also UIForm with prependId=“false” breaks <f:ajax render>.


    Register it as <view-handler> in faces-config.xml.


    Note that this only runs if Application.getProjectStage() equals to ProjectStage.Development.

    Arjan Tijms
    • Constructor Detail

      • NoAutoGeneratedIdViewHandler

        public NoAutoGeneratedIdViewHandler​(ViewHandler wrapped)
        Construct a new No Auto Generated Id view handler around the given wrapped view handler.
        wrapped - The wrapped view handler.