从facelets 1.1迁移到faclets 2.0 - FaceletViewHandler

发布于 2024-11-25 18:50:38 字数 372 浏览 1 评论 0原文

我读过以下帖子,非常有帮助 从 JSF 1.2 迁移到 JSF 2.0

但我迁移时遇到问题,因为我有一个从 FaceletViewHandler 扩展的自定义视图处理程序 - 这不是 faclets 2 的一部分。

我正在 JBoss 4.2.2 上迁移以下内容: - JSF 1.2 到 JSF 2.0

我还想迁移 faclets - 我遇到了上述问题。

在我的应用程序中,我也使用 Tomahawk - 此迁移有任何问题吗?

提前致谢。

埃利科.

I have read the following post which was very helpful
Migrating from JSF 1.2 to JSF 2.0

but I am having a problem with the migration as I have a custom view handler which extends from FaceletViewHandler - this is not part of faclets 2.

I am migrating on JBoss 4.2.2 the following:
- JSF 1.2 to JSF 2.0

I also want to migrate the faclets - which i have a problem described above.

In my application, I am also using Tomahawk - is there any problem with this migration?

Thanks in advance.

Elico.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤凫 2024-12-02 18:50:38

是的,您需要将 FaceletViewHandler 替换为 ViewHandlerWrapper

因此,以下基本 FaceletViewHandler 实现:

import javax.faces.application.ViewHandler;
import com.sun.facelets.FaceletViewHandler;

public class MyViewHandler extends FaceletViewHandler {

    public MyViewHandler(ViewHandler parent) {
        super(parent);
    }

    // ...
}

需要更新如下:

import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;

public class MyViewHandler extends ViewHandlerWrapper {

    private ViewHandler wrapped;

    public MyViewHandler(ViewHandler wrapped) {
        this.wrapped = wrapped;
    }

    @Override
    public ViewHandler getWrapped() {
        return wrapped;
    }

    // ...
}

我已相应地更新了有关迁移问题的答案。

Right, you need to replace FaceletViewHandler by ViewHandlerWrapper.

So the following basic FaceletViewHandler implementation:

import javax.faces.application.ViewHandler;
import com.sun.facelets.FaceletViewHandler;

public class MyViewHandler extends FaceletViewHandler {

    public MyViewHandler(ViewHandler parent) {
        super(parent);
    }

    // ...
}

needs to be updated as follows:

import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;

public class MyViewHandler extends ViewHandlerWrapper {

    private ViewHandler wrapped;

    public MyViewHandler(ViewHandler wrapped) {
        this.wrapped = wrapped;
    }

    @Override
    public ViewHandler getWrapped() {
        return wrapped;
    }

    // ...
}

I've updated my answer on the migration question accordingly.

梦在深巷 2024-12-02 18:50:38

要激活 MyViewHandler 例如对于 JEE7,WEB-INF/faces-config.xml 应定义如下:

<?xml version="1.0"?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
          http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <application>
        <view-handler>pkg.MyViewHandler</view-handler>
    </application>
</faces-config>

To activate MyViewHandler e.g. for JEE7, WEB-INF/faces-config.xml should be defined like:

<?xml version="1.0"?>
<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
          http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">
    <application>
        <view-handler>pkg.MyViewHandler</view-handler>
    </application>
</faces-config>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文