Migrating from facelets 1.1 to faclets 2.0 - FaceletViewHandler
Asked Answered
B

2

7

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.

Bladdernut answered 25/7, 2011 at 12:41 Comment(0)
V
8

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.

Vocalise answered 25/7, 2011 at 13:0 Comment(0)
B
0

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>
Barrie answered 28/12, 2017 at 20:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.