Possible to have an ApplicationScoped bean that skins a JSF 2 application with a richfaces skin?

风格不统一 提交于 2019-12-04 19:51:33

To implement something like this RichFaces source code is your best friend.

Here is what I have found how you can do what you want:

Add a file to a jar (or anywhere so it will appear in classpath) META-INF/services/org.richfaces.application.Module Content of the file should be com.example.CustomModule

Implementation of the custom module can be like this:

public class CustomModule implements Module {
    public void configure(ServicesFactory factory) {
        factory.setInstance(SkinFactory.class, new CustomSkinFactoryImpl());
    }
}

And then implement SkinFactory according to your needs, for example (if you want to extend default behavior with your CustomSkin):

public class CustomSkinFactoryImpl extends SkinFactoryImpl {
    public Skin getSkin(FacesContext context) {
        return new CompositeSkinImpl(new CustomSkin(), super.getSkin(context));
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!