首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

重写FacesStateManager,为解决验证显示有关问题

2013-06-26 
重写FacesStateManager,为解决验证显示问题package org.iata.isss.web.common.jsf.factoryimport java.io

重写FacesStateManager,为解决验证显示问题
package org.iata.isss.web.common.jsf.factory;import java.io.IOException;import java.util.Iterator;import javax.faces.application.StateManager;import javax.faces.component.EditableValueHolder;import javax.faces.component.UIComponent;import javax.faces.component.UIViewRoot;import javax.faces.context.FacesContext;/** * * @author Xiao Jianbo * */public class FacesStateManager extends StateManager {private final StateManager stateManager;public FacesStateManager(StateManager sm) {this.stateManager = sm;}@Overrideprotected Object getComponentStateToSave(FacesContext ctx) {throw new UnsupportedOperationException();}@Overrideprotected Object getTreeStructureToSave(FacesContext ctx) {throw new UnsupportedOperationException();}@Overrideprotected void restoreComponentState(FacesContext ctx, UIViewRoot viewRoot,String str) {throw new UnsupportedOperationException();}@Overrideprotected UIViewRoot restoreTreeStructure(FacesContext ctx, String str1,String str2) {throw new UnsupportedOperationException();}@Overridepublic SerializedView saveSerializedView(FacesContext facesContext) {processEditableValueHolder(facesContext.getViewRoot());return stateManager.saveSerializedView(facesContext);}private void processEditableValueHolder(UIComponent component) {if (component instanceof EditableValueHolder) {EditableValueHolder editableValueHolder = (EditableValueHolder) component;editableValueHolder.setValid(true);boolean localset = editableValueHolder.isLocalValueSet();editableValueHolder.setValue(null);// super.setValue(value);setLocalValueSet(true);editableValueHolder.setLocalValueSet(localset);} else {Iterator<UIComponent> kids = component.getFacetsAndChildren();while (kids.hasNext()) {UIComponent kid = kids.next();processEditableValueHolder(kid);}}}@Overridepublic void writeState(FacesContext ctx, SerializedView sv)throws IOException {stateManager.writeState(ctx, sv);}@Overridepublic UIViewRoot restoreView(FacesContext ctx, String str1, String str2) {return stateManager.restoreView(ctx, str1, str2);}@Overridepublic Object saveView(FacesContext facesContext) {return stateManager.saveView(facesContext);}@Overridepublic void writeState(FacesContext ctx, Object sv) throws IOException {stateManager.writeState(ctx, sv);}@Overridepublic boolean isSavingStateInClient(FacesContext ctx) {return stateManager.isSavingStateInClient(ctx);}}

?

热点排行