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.

Community
  • 1
  • 1
Elico
  • 71
  • 1
  • 2

2 Answers2

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.

BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
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>
Marc Dzaebel
  • 275
  • 1
  • 10