UIData extends UIComponentBase implements NamingContainer, UniqueIdVendor { @Override public Object saveState(FacesContext context) { resetClientIds(this); if (initialStateMarked()) { Object superState = super.saveState(context); if (superState == null && _rowDeltaStates.isEmpty()) { return null; } else { Object values[] = null; Object attachedState = UIComponentBase.saveAttachedState(context, _rowDeltaStates); if (superState != null || attachedState != null) { values = new Object[] { superState, attachedState }; } return values; } } else { Object values[] = new Object[2]; values[0] = super.saveState(context); values[1] = UIComponentBase.saveAttachedState(context, _rowDeltaStates); return values; } } UIData(); @Override String getFamily(); int getFirst(); void setFirst(int first); UIComponent getFooter(); void setFooter(UIComponent footer); UIComponent getHeader(); void setHeader(UIComponent header); boolean isRowAvailable(); int getRowCount(); Object getRowData(); int getRowIndex(); void setRowIndex(int rowIndex); int getRows(); void setRows(int rows); String getVar(); void setVar(String var); boolean isRowStatePreserved(); void setRowStatePreserved(boolean preserveComponentState); Object getValue(); void setValue(Object value); @Override void setValueBinding(String name, ValueBinding binding); @Override void setValueExpression(String name, ValueExpression binding); @Override String getClientId(FacesContext context); @Override boolean invokeOnComponent(FacesContext context, String clientId,
                                     ContextCallback callback); @Override void queueEvent(FacesEvent event); @Override void broadcast(FacesEvent event); @Override void encodeBegin(FacesContext context); @Override void processDecodes(FacesContext context); @Override void processValidators(FacesContext context); @Override void processUpdates(FacesContext context); @Override String createUniqueId(FacesContext context, String seed); @Override boolean visitTree(VisitContext context, 
                             VisitCallback callback); @Override void markInitialState(); @Override void restoreState(FacesContext context, Object state); @Override Object saveState(FacesContext context); static final String COMPONENT_TYPE; static final String COMPONENT_FAMILY; }
@Test public void testSaveState() { FacesContext context = EasyMock.createMock(FacesContext.class); UIData data = new UIData(); data.markInitialState(); replay(context); assertNull(data.saveState(context)); verify(context); }
@Test public void testSaveState2() { FacesContext context = EasyMock.createMock(FacesContext.class); UIData data = new UIData(); replay(context); assertNotNull(data.saveState(context)); verify(context); }