📄 uidata.java
字号:
} public UIComponent getFooter() { return getFacet("footer"); } public void setFooter(UIComponent footer) { getFacets().put("footer", footer); } // // overrides /** * Returns the client-specific id for the component. */ @Override public String getClientId(FacesContext context) { String clientId = super.getClientId(context); int rowIndex = getRowIndex(); if (rowIndex < 0) return clientId; else return clientId + SEPARATOR_CHAR + rowIndex; } /** * Queues the event, wrapping the rowIndex. */ @Override public void queueEvent(FacesEvent event) { int rowIndex = getRowIndex(); super.queueEvent(new UIDataEventWrapper(event, this, rowIndex)); } /** * Broadcasts the event, unwrapping the rowIndex. */ @Override public void broadcast(FacesEvent event) throws AbortProcessingException { if (event instanceof UIDataEventWrapper) { UIDataEventWrapper wrapper = (UIDataEventWrapper) event; event = wrapper.getEvent(); int oldIndex = getRowIndex(); setRowIndex(wrapper.getRowIndex()); event.getComponent().broadcast(event); setRowIndex(oldIndex); } else super.broadcast(event); } /** * Recursively calls the decodes for any children, then calls * decode(). */ @Override public void processDecodes(FacesContext context) { if (context == null) throw new NullPointerException(); if (! isRendered()) return; setRowIndex(-1); if (getFacetCount() > 0) { for (UIComponent facet : getFacets().values()) { facet.processDecodes(context); } } int childCount = getChildCount(); if (childCount > 0) { List<UIComponent> children = getChildren(); for (int i = 0; i < children.size(); i++) { UIComponent child = children.get(i); if (! child.isRendered() && child.getFacetCount() == 0) continue; for (UIComponent facet : child.getFacets().values()) { facet.processDecodes(context); } } int first = getFirst(); int rows = getRows(); if (rows <= 0) rows = Integer.MAX_VALUE; for (int i = 0; i < rows; i++) { setRowIndex(first + i); if (! isRowAvailable()) break; for (int j = 0; j < childCount; j++) { UIComponent child = children.get(j); if (! child.isRendered()) continue; int grandchildCount = child.getChildCount(); if (grandchildCount > 0) { List<UIComponent> grandchildren = child.getChildren(); for (int k = 0; k < grandchildCount; k++) { grandchildren.get(k).processDecodes(context); } } child.decode(context); } } } setRowIndex(-1); decode(context); } /** * Recursively calls the validators for any children, then calls * decode(). */ @Override public void processValidators(FacesContext context) { if (context == null) throw new NullPointerException(); if (! isRendered()) return; setRowIndex(-1); if (getFacetCount() > 0) { for (UIComponent facet : getFacets().values()) { facet.processValidators(context); } } int childCount = getChildCount(); if (childCount > 0) { List<UIComponent> children = getChildren(); for (int i = 0; i < children.size(); i++) { UIComponent child = children.get(i); if (! child.isRendered() && child.getFacetCount() == 0) continue; for (UIComponent facet : child.getFacets().values()) { facet.processValidators(context); } } int first = getFirst(); int rows = getRows(); if (rows <= 0) rows = Integer.MAX_VALUE; for (int i = 0; i < rows; i++) { setRowIndex(first + i); if (! isRowAvailable()) break; for (int j = 0; j < childCount; j++) { UIComponent child = children.get(j); if (! child.isRendered()) continue; int grandchildCount = child.getChildCount(); List<UIComponent> grandchildren = child.getChildren(); for (int k = 0; k < grandchildCount; k++) { grandchildren.get(k).processValidators(context); } } } } setRowIndex(-1); } /** * Recursively calls the updates for any children, then calls * decode(). */ @Override public void processUpdates(FacesContext context) { if (context == null) throw new NullPointerException(); if (! isRendered()) return; setRowIndex(-1); if (getFacetCount() > 0) { for (UIComponent facet : getFacets().values()) { facet.processUpdates(context); } } int childCount = getChildCount(); if (childCount > 0) { List<UIComponent> children = getChildren(); for (int i = 0; i < children.size(); i++) { UIComponent child = children.get(i); if (! child.isRendered() && child.getFacetCount() == 0) continue; for (UIComponent facet : child.getFacets().values()) { facet.processUpdates(context); } } int first = getFirst(); int rows = getRows(); if (rows <= 0) rows = Integer.MAX_VALUE; for (int i = 0; i < rows; i++) { setRowIndex(first + i); if (! isRowAvailable()) break; for (int j = 0; j < childCount; j++) { UIComponent child = children.get(j); if (! child.isRendered()) continue; int grandchildCount = child.getChildCount(); List<UIComponent> grandchildren = child.getChildren(); for (int k = 0; k < grandchildCount; k++) { grandchildren.get(k).processUpdates(context); } } } } setRowIndex(-1); } /** * Recursively calls the encodes for any children, then calls * decode(). */ @Override public void encodeBegin(FacesContext context) throws java.io.IOException { if (context == null) throw new NullPointerException(); if (! isRendered()) return; resetDataModel(); if (! context.getRenderResponse() || ! context.getResponseComplete()) _state = null; super.encodeBegin(context); } // // state // public Object saveState(FacesContext context) { return new Object[] { super.saveState(context), _value, _first, _rows, _var, }; } public void restoreState(FacesContext context, Object value) { Object []state = (Object []) value; super.restoreState(context, state[0]); _value = state[1]; _first = (Integer) state[2]; _rows = (Integer) state[3]; _var = (String) state[4]; } // // inner classes // static class UIDataEventWrapper extends FacesEvent { private FacesEvent _event; private int _rowIndex; UIDataEventWrapper(FacesEvent event, UIData component, int rowIndex) { super(component); _event = event; _rowIndex = rowIndex; } FacesEvent getEvent() { return _event; } int getRowIndex() { return _rowIndex; } public void setPhaseId(PhaseId phaseId) { _event.setPhaseId(phaseId); } public PhaseId getPhaseId() { return _event.getPhaseId(); } public boolean isAppropriateListener(FacesListener listener) { return _event.isAppropriateListener(listener); } public void processListener(FacesListener listener) throws AbortProcessingException { ((UIData) getComponent()).setRowIndex(_rowIndex); _event.processListener(listener); } } static class State implements java.io.Serializable { private final Object _submittedValue; private final Object _value; private final boolean _isLocal; private final boolean _isValid; State() { _submittedValue = null; _value = null; _isLocal = false; _isValid = false; } State(EditableValueHolder holder) { _submittedValue = holder.getSubmittedValue(); _value = holder.getValue(); _isLocal = holder.isLocalValueSet(); _isValid = holder.isValid(); } State update(EditableValueHolder holder) { if (_submittedValue == holder.getSubmittedValue() && _value == holder.getValue() && _isLocal == holder.isLocalValueSet() && _isValid == holder.isValid()) return this; else return new State(holder); } void restore(EditableValueHolder holder) { holder.setSubmittedValue(_submittedValue); holder.setValue(_value); holder.setLocalValueSet(_isLocal); holder.setValid(_isValid); } } // // private helpers // private static enum PropEnum { VALUE, FIRST, ROWS, } static { _propMap.put("value", PropEnum.VALUE); _propMap.put("first", PropEnum.FIRST); _propMap.put("rows", PropEnum.ROWS); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -