I am upgrading my app to JSF 2 from JSF 1.2.
I have ran into the following issue. I had locale handler which handled the locale used by examing the URL of the request.
@Configurable
public class MutationViewHandler extends FaceletViewHandler {
@Autowired
private LanguageMutationServiceIface mutationService;
public MutationViewHandler(ViewHandler parent) {
super(parent);
}
@Override
public Locale calculateLocale(FacesContext context) {
String mutation = FacesUtil.getRequestParameter("mutation");
if (mutation == null) {
return new Locale(mutationService.getDefaultLanguageMutation().getName());
} else {
return new Locale(mutation);
}
}
}
But in JSF 2 is this class deprecated and causes error (NPE) when used in MyFaces. I have tried to implement it using simple ViewHandler, but it forces me to implement many methods where I wish to use the default behaviour.
Thanks for help in advance.
You need to extend
ViewHandlerWrapperinstead.So, you can just do