Reorder custom Unified Expression Language Resolvers

二次信任 提交于 2019-12-11 11:58:36

问题


I am trying to write a custom Expression Language (EL) resolver. The purpose of this resolver is to intercept method calls to a certain Bean to add a second parameter. I have written a custom EL resolver that overwrites the invoke-method to do what I want. I also put the resolver in the faces-config.xml as required.

Unfortunately, I have a dependency in my project that also declares custom EL Resolvers and they are placed before my EL resolver in the resolver chain. Since one of the other resolvers already handles the invoke-method, my custom invoke-method never gets called.

Is there any way to reorder the resolvers so that my resolver gets called first? I am aware that Apache MyFaces offers a mechanism for ordering the resolvers, but unfortunately I can't get MyFaces to work in my project.


回答1:


Put the EL resolver in a separate web fragment project which ultimately ends up as JAR in webapp's /WEB-INF/lib. In the web fragment project's faces-config.xml, declare the ordering to be "before others" as below.

<ordering>
    <before>
        <others />
    </before>
</ordering>

Or if the "other dependency" has also a faces-config.xml file with a <name> declared, then explicitly declare that name in the ordering. This would be the only way if the "other dependency" happens to also have exactly the above ordering set.

<ordering>
    <before>
        <name>nameOfThatOtherDependency</name>
    </before>
</ordering>

Noted should be that this affects the entire faces-config.xml.



来源:https://stackoverflow.com/questions/36134617/reorder-custom-unified-expression-language-resolvers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!