大家好。我在使用netbeans 6.8,想实现动态更改用户的locale。写了个CustomViewHandler,也配置在了faces-comfig.xml中。结果,能更改locale,但每次点h:commandLink都报404错,如果直接地址栏输入URL能正常访问相应的文件。如果不使用CustomViewHandler,没有这个问题。
谁知道原因吗,谢谢啦。The error:---------------
HTTP Status 404 - null not found
type Status report
message null not found
description The requested resource (null not found) is not available.The config--------------
<application>
<resource-bundle>
<base-name>/Bundle</base-name>
<var>bundle</var>
</resource-bundle>
<locale-config>
<default-locale>zh</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>ko</supported-locale>
<supported-locale>ja</supported-locale>
</locale-config>
<view-handler>myui.CustomLocaleViewHandler</view-handler>
</application>The code----------------
public class CustomLocaleViewHandler extends ViewHandler {
protected ViewHandler baseViewHandler;public CustomLocaleViewHandler(ViewHandler baseViewHandler) {
super();
this.baseViewHandler = baseViewHandler;
}@Override
public Locale calculateLocale(FacesContext context) {
Locale userLocal = Locale.JAPAN;
if(userLocal != null){
return userLocal;
}else{
return baseViewHandler.calculateLocale(context);
}
}@Override
public String calculateRenderKitId(FacesContext context) {
return baseViewHandler.calculateRenderKitId(context);
}@Override
public UIViewRoot createView(FacesContext context, String viewId) {
return baseViewHandler.createView(context, viewId);
}@Override
public String getActionURL(FacesContext context, String viewId) {
return baseViewHandler.getActionURL(context, viewId);
}@Override
public String getResourceURL(FacesContext context, String path) {
return baseViewHandler.getResourceURL(context, path);
}@Override
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
baseViewHandler.renderView(context, viewToRender);
}@Override
public UIViewRoot restoreView(FacesContext context, String viewId) {
return baseViewHandler.restoreView(context, viewId);
}@Override
public void writeState(FacesContext context) throws IOException {
baseViewHandler.writeState(context);
}