luni, 20 aprilie 2015

[OmniFaces utilities (2.0)] Check if RichFaces 4.0-4.3 is installed


[OmniFaces utilities] The isRichFacesInstalled() method returns true if RichFaces 4.0-4.3 is installed. That is, when the RichFaces 4.0-4.3 specific ExtendedPartialViewContextImpl is present in the runtime classpath. As this is usually auto-registered, we may safely assume that RichFaces 4.0-4.3 is installed.

Note In RichFaces 4.5, this class has changed to ExtendedPartialViewContext which finally properly extends PartialViewContextWrapper with among others the correct implementation for getRenderIds(), so the #getRichFacesPartialViewContext() hack isn't anymore necessary for the purpose. Also note that RichFaces 4.4 doesn't exist.

Method:
Usage:

So, in order to find out if RichFaces 4.0-4.3 is installed or not, just invoke Hacks#isRichFacesInstalled() method:

import org.omnifaces.util.Hacks;
...
// e.g. false, if RichFaces 4.0-4.3 is not installed
boolean isRichFacesAvailable = Hacks.isRichFacesInstalled();
      if(isRichFacesAvailable){
          // looks like RichFaces 4.0-4.3 is installed
      } else {
          // looks like RichFaces 4.0-4.3 is not installed
      }

Niciun comentariu:

Trimiteți un comentariu