Java Code Examples for javax.faces.component.UIComponent.markInitialState()

The following are Jave code examples for showing how to use markInitialState() of the javax.faces.component.UIComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: myfaces-trinidad   File: TrinidadComponentHandler.java   Source Code and License Vote up 5 votes
@Override
public void onComponentPopulated(FaceletContext context,
                                   UIComponent component,
                                   UIComponent parent)
{
  assert (_markInitialState != null);

  if ((component instanceof UIXComponent) &&
      (_markInitialState == Boolean.TRUE))
  {
    if (component.getId() == null)
      component.setId(context.generateUniqueId(UIViewRoot.UNIQUE_ID_PREFIX));
    
    PhaseId phase = context.getFacesContext().getCurrentPhaseId();
    
    // In jsf2 markInitialState will be called by the framework during restore view, 
    // and in fact the framework should always be the one
    // calling markInitialState, but it doesn't always do that in render response, see
    // http://java.net/jira/browse/JAVASERVERFACES-2285
    // Also don't call markInitialState unless initialStateMarked returns false, otherwise
    // any deltas previously saved may get blown away.
    if (PhaseId.RENDER_RESPONSE.equals(phase) && !component.initialStateMarked())
    {
      component.markInitialState();
    }
  }
}