本文介绍了重新排序自定义统一表达语言解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写自定义表达式语言(EL)解析器.此解析器的目的是拦截对某个Bean的方法调用以添加第二个参数.我已经编写了一个自定义的EL解析器,该解析器会覆盖invoke-方法来执行我想要的操作.我还根据需要将解析器放在faces-config.xml中.

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.

不幸的是,我的项目中有一个依赖项,该依赖项还声明了自定义的EL解析器,并且它们在解析器链中放置在我的EL解析器之前.由于其他解析器之一已经处理过invoke-方法,所以我的自定义invoke-方法永远不会被调用.

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.

有什么方法可以重新排序解析器,以便首先调用我的解析器?我知道Apache MyFaces提供了一种用于订购解析器的机制,但是很遗憾,我无法让MyFaces在我的项目中工作.

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.

推荐答案

将EL解析器放在单独的,该项目最终以web应用程序/WEB-INF/lib中的JAR结尾.在Web片段项目的faces-config.xml中,将顺序声明为先于其他",如下所示.

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>

或者,如果其他依赖项"也有一个声明了<name>faces-config.xml文件,则在顺序中显式声明该名称.如果其他依赖项"恰好也恰好具有上述顺序集,那么这将是唯一的方法.

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>

请注意,这会影响整个faces-config.xml.

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

这篇关于重新排序自定义统一表达语言解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:31