This utility method exist in OmniFaces 2.0, but it was slightly improved in OmniFaces 2.1.
[OmniFaces utilities] The
toClass()
returns the Class
instance associated with the class of the given string, using the context class loader and if that fails the defining class loader of the current class. Just pass in the fully qualified class name of the class for which a Class
instance needs to be created.Method:
import
org.omnifaces.util.Reflection;
...
// example
1, fully qualified class name: book.beans.BookBean
Class<BookBean> bookBean =
(Class<BookBean>) Reflection.toClass("book.beans.BookBean");
// example
2, fully qualified class name: javax.faces.component.UIInput
Class<UIInput> uiInput =
(Class<UIInput>) Reflection.toClass("javax.faces.component.UIInput");
Niciun comentariu :
Trimiteți un comentariu