You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Mike Kienenberger <mk...@gmail.com> on 2006/09/19 17:14:44 UTC

Don't commit massive format changes with other changes [was Re: svn commit: r447870 - in /myfaces: core/trunk/impl/src/main/java/org/apache/myfaces/application/jsp/ ...]

Thomas,

I've said this before to you, and I don't know how I can make this any clearer.

PLEASE do not make your formatting changes at the same time as you
make your logic changes.  PLEASE commit your formatting changes
separately from your logic patches.

It's impossible to tell what what you've done when every line of the
file ends up in the commit message.

I'm going to start vetoing and reverting your changes if you keep doing this.

On 9/19/06, tomsp@apache.org <to...@apache.org> wrote:
> Author: tomsp
> Date: Tue Sep 19 08:06:22 2006
> New Revision: 447870
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=447870
> Log:
> MYFACES-1405 reopened and fixed
>
> Added:
>     myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ViewSequenceUtils.java
> Modified:
>     myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java
>     myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
>     myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
>     myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
>     myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DummyFormUtils.java
>
> Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java
> URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java?view=diff&rev=447870&r1=447869&r2=447870
> ==============================================================================
> --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java (original)
> +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/application/jsp/JspStateManagerImpl.java Tue Sep 19 08:06:22 2006
> @@ -15,23 +15,16 @@
>   */
>  package org.apache.myfaces.application.jsp;
>
> -import java.io.ByteArrayInputStream;
> -import java.io.ByteArrayOutputStream;
> -import java.io.IOException;
> -import java.io.InputStream;
> -import java.io.ObjectInputStream;
> -import java.io.ObjectOutputStream;
> -import java.io.OutputStream;
> -import java.io.Serializable;
> -import java.util.ArrayList;
> -import java.util.HashMap;
> -import java.util.HashSet;
> -import java.util.Iterator;
> -import java.util.List;
> -import java.util.Map;
> -import java.util.Set;
> -import java.util.zip.GZIPInputStream;
> -import java.util.zip.GZIPOutputStream;
> +import org.apache.commons.collections.map.ReferenceMap;
> +import org.apache.commons.lang.builder.EqualsBuilder;
> +import org.apache.commons.lang.builder.HashCodeBuilder;
> +import org.apache.commons.logging.Log;
> +import org.apache.commons.logging.LogFactory;
> +import org.apache.myfaces.application.MyfacesStateManager;
> +import org.apache.myfaces.application.TreeStructureManager;
> +import org.apache.myfaces.renderkit.MyfacesResponseStateManager;
> +import org.apache.myfaces.shared_impl.renderkit.ViewSequenceUtils;
> +import org.apache.myfaces.shared_impl.util.MyFacesObjectInputStream;
>
>  import javax.faces.FactoryFinder;
>  import javax.faces.application.StateManager;
> @@ -43,36 +36,28 @@
>  import javax.faces.render.RenderKit;
>  import javax.faces.render.RenderKitFactory;
>  import javax.faces.render.ResponseStateManager;
> -
> -import org.apache.commons.collections.map.ReferenceMap;
> -import org.apache.commons.lang.builder.EqualsBuilder;
> -import org.apache.commons.lang.builder.HashCodeBuilder;
> -import org.apache.commons.logging.Log;
> -import org.apache.commons.logging.LogFactory;
> -import org.apache.myfaces.application.MyfacesStateManager;
> -import org.apache.myfaces.application.TreeStructureManager;
> -import org.apache.myfaces.renderkit.MyfacesResponseStateManager;
> -import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
> -import org.apache.myfaces.shared_impl.util.MyFacesObjectInputStream;
> +import java.io.*;
> +import java.util.*;
> +import java.util.zip.GZIPInputStream;
> +import java.util.zip.GZIPOutputStream;
>
>  /**
>   * Default StateManager implementation for use when views are defined
>   * via tags in JSP pages.
> - *
> + *
>   * @author Thomas Spiegl (latest modification by $Author$)
>   * @author Manfred Geiler
>   * @version $Revision$ $Date$
>   */
>  public class JspStateManagerImpl
> -    extends MyfacesStateManager
> -{
> +    extends MyfacesStateManager {
>      private static final Log log = LogFactory.getLog(JspStateManagerImpl.class);
>      private static final String SERIALIZED_VIEW_SESSION_ATTR
> -            = JspStateManagerImpl.class.getName() + ".SERIALIZED_VIEW";
> +        = JspStateManagerImpl.class.getName() + ".SERIALIZED_VIEW";
>      private static final String SERIALIZED_VIEW_REQUEST_ATTR
> -            = JspStateManagerImpl.class.getName() + ".SERIALIZED_VIEW";
> +        = JspStateManagerImpl.class.getName() + ".SERIALIZED_VIEW";
>      private static final String RESTORED_SERIALIZED_VIEW_REQUEST_ATTR
> -    = JspStateManagerImpl.class.getName() + ".RESTORED_SERIALIZED_VIEW";
> +        = JspStateManagerImpl.class.getName() + ".RESTORED_SERIALIZED_VIEW";
>
>      /**
>       * Only applicable if state saving method is "server" (= default).
> @@ -121,18 +106,15 @@
>
>      private RenderKitFactory _renderKitFactory = null;
>
> -    public JspStateManagerImpl()
> -    {
> +    public JspStateManagerImpl() {
>          if (log.isTraceEnabled()) log.trace("New JspStateManagerImpl instance created");
>      }
>
> -    protected Object getComponentStateToSave(FacesContext facesContext)
> -    {
> +    protected Object getComponentStateToSave(FacesContext facesContext) {
>          if (log.isTraceEnabled()) log.trace("Entering getComponentStateToSave");
>
>          UIViewRoot viewRoot = facesContext.getViewRoot();
> -        if (viewRoot.isTransient())
> -        {
> +        if (viewRoot.isTransient()) {
>              return null;
>          }
>
> @@ -148,12 +130,10 @@
>       * tree to be recreated later, though all the components will have
>       * just default values for their members.
>       */
> -    protected Object getTreeStructureToSave(FacesContext facesContext)
> -    {
> +    protected Object getTreeStructureToSave(FacesContext facesContext) {
>          if (log.isTraceEnabled()) log.trace("Entering getTreeStructureToSave");
>          UIViewRoot viewRoot = facesContext.getViewRoot();
> -        if (viewRoot.isTransient())
> -        {
> +        if (viewRoot.isTransient()) {
>              return null;
>          }
>          TreeStructureManager tsm = new TreeStructureManager();
> @@ -170,8 +150,7 @@
>       */
>      protected void restoreComponentState(FacesContext facesContext,
>                                           UIViewRoot uiViewRoot,
> -                                         String renderKitId)
> -    {
> +                                         String renderKitId) {
>          if (log.isTraceEnabled()) log.trace("Entering restoreComponentState");
>
>          //===========================================
> @@ -179,40 +158,37 @@
>          //===========================================
>
>          Object serializedComponentStates;
> -        if (isSavingStateInClient(facesContext))
> -        {
> +        if (isSavingStateInClient(facesContext)) {
>              RenderKit renderKit = getRenderKitFactory().getRenderKit(facesContext, renderKitId);
>              ResponseStateManager responseStateManager = renderKit.getResponseStateManager();
>              serializedComponentStates = responseStateManager.getComponentStateToRestore(facesContext);
> -            if (serializedComponentStates == null)
> -            {
> +            if (serializedComponentStates == null) {
>                  log.error("No serialized component state found in client request!");
>                  // mark UIViewRoot invalid by resetting view id
>                  uiViewRoot.setViewId(null);
>                  return;
>              }
>          }
> -        else
> -        {
> +        else {
> +            String viewId = uiViewRoot.getViewId();
> +            String sequenceStr = getSequenceString(facesContext, renderKitId, viewId);
>              SerializedView serializedView = getSerializedViewFromServletSession(facesContext,
> -                                                                                uiViewRoot.getViewId());
> -            if (serializedView == null)
> -            {
> +                                                                                viewId,
> +                                                                                sequenceStr);
> +            if (serializedView == null) {
>                  log.error("No serialized view found in server session!");
>                  // mark UIViewRoot invalid by resetting view id
>                  uiViewRoot.setViewId(null);
>                  return;
>              }
>              serializedComponentStates = serializedView.getState();
> -            if (serializedComponentStates == null)
> -            {
> +            if (serializedComponentStates == null) {
>                  log.error("No serialized component state found in server session!");
>                  return;
>              }
>          }
>
> -        if (uiViewRoot.getRenderKitId() == null)
> -        {
> +        if (uiViewRoot.getRenderKitId() == null) {
>              //Just to be sure...
>              uiViewRoot.setRenderKitId(renderKitId);
>          }
> @@ -228,47 +204,46 @@
>       */
>      protected UIViewRoot restoreTreeStructure(FacesContext facesContext,
>                                                String viewId,
> -                                              String renderKitId)
> -    {
> +                                              String renderKitId) {
>          if (log.isTraceEnabled()) log.trace("Entering restoreTreeStructure");
>
>          UIViewRoot uiViewRoot;
> -        if (isSavingStateInClient(facesContext))
> -        {
> +        if (isSavingStateInClient(facesContext)) {
>              //reconstruct tree structure from request
>              RenderKit rk = getRenderKitFactory().getRenderKit(facesContext, renderKitId);
>              ResponseStateManager responseStateManager = rk.getResponseStateManager();
>              Object treeStructure = responseStateManager.getTreeStructureToRestore(facesContext, viewId);
> -            if (treeStructure == null)
> -            {
> -                if (log.isDebugEnabled()) log.debug("Exiting restoreTreeStructure - No tree structure state found in client request");
> +            if (treeStructure == null) {
> +                if (log.isDebugEnabled())
> +                    log.debug("Exiting restoreTreeStructure - No tree structure state found in client request");
>                  return null;
>              }
>
>              TreeStructureManager tsm = new TreeStructureManager();
> -            uiViewRoot = tsm.restoreTreeStructure((TreeStructureManager.TreeStructComponent)treeStructure);
> +            uiViewRoot = tsm.restoreTreeStructure((TreeStructureManager.TreeStructComponent) treeStructure);
>              if (log.isTraceEnabled()) log.trace("Tree structure restored from client request");
>          }
> -        else
> -        {
> +        else {
> +            String sequenceStr = getSequenceString(facesContext, renderKitId, viewId);
>              //reconstruct tree structure from ServletSession
>              SerializedView serializedView = getSerializedViewFromServletSession(facesContext,
> -                                                                                viewId);
> -            if (serializedView == null)
> -            {
> -                if (log.isDebugEnabled()) log.debug("Exiting restoreTreeStructure - No serialized view found in server session!");
> +                                                                                viewId,
> +                                                                                sequenceStr);
> +            if (serializedView == null) {
> +                if (log.isDebugEnabled())
> +                    log.debug("Exiting restoreTreeStructure - No serialized view found in server session!");
>                  return null;
>              }
>
>              Object treeStructure = serializedView.getStructure();
> -            if (treeStructure == null)
> -            {
> -                if (log.isDebugEnabled()) log.debug("Exiting restoreTreeStructure - No tree structure state found in server session, former UIViewRoot must have been transient");
> +            if (treeStructure == null) {
> +                if (log.isDebugEnabled())
> +                    log.debug("Exiting restoreTreeStructure - No tree structure state found in server session, former UIViewRoot must have been transient");
>                  return null;
>              }
>
>              TreeStructureManager tsm = new TreeStructureManager();
> -            uiViewRoot = tsm.restoreTreeStructure((TreeStructureManager.TreeStructComponent)serializedView.getStructure());
> +            uiViewRoot = tsm.restoreTreeStructure((TreeStructureManager.TreeStructComponent) serializedView.getStructure());
>              if (log.isTraceEnabled()) log.trace("Tree structure restored from server session");
>          }
>
> @@ -276,18 +251,22 @@
>          return uiViewRoot;
>      }
>
> -    public UIViewRoot restoreView(FacesContext facescontext, String viewId, String renderKitId)
> -    {
> +    private String getSequenceString(FacesContext facesContext, String renderKitId, String viewId) {
> +        RenderKit rk = getRenderKitFactory().getRenderKit(facesContext, renderKitId);
> +        ResponseStateManager responseStateManager = rk.getResponseStateManager();
> +        String sequenceStr = (String) responseStateManager.getTreeStructureToRestore(facesContext, viewId);
> +        return sequenceStr;
> +    }
> +
> +    public UIViewRoot restoreView(FacesContext facescontext, String viewId, String renderKitId) {
>          if (log.isTraceEnabled()) log.trace("Entering restoreView");
>
>          UIViewRoot uiViewRoot = restoreTreeStructure(facescontext, viewId, renderKitId);
> -        if (uiViewRoot != null)
> -        {
> +        if (uiViewRoot != null) {
>              uiViewRoot.setViewId(viewId);
>              restoreComponentState(facescontext, uiViewRoot, renderKitId);
>              String restoredViewId = uiViewRoot.getViewId();
> -            if (restoredViewId == null || !(restoredViewId.equals(viewId)))
> -            {
> +            if (restoredViewId == null || !(restoredViewId.equals(viewId))) {
>                  if (log.isTraceEnabled()) log.trace("Exiting restoreView - restored view is null.");
>                  return null;
>              }
> @@ -298,8 +277,7 @@
>          return uiViewRoot;
>      }
>
> -    public SerializedView saveSerializedView(FacesContext facesContext) throws IllegalStateException
> -    {
> +    public SerializedView saveSerializedView(FacesContext facesContext) throws IllegalStateException {
>          if (log.isTraceEnabled()) log.trace("Entering saveSerializedView");
>
>          checkForDuplicateIds(facesContext, facesContext.getViewRoot(), new HashSet());
> @@ -309,10 +287,9 @@
>          ExternalContext externalContext = facesContext.getExternalContext();
>
>          // SerializedView already created before within this request?
> -        SerializedView serializedView = (SerializedView)externalContext.getRequestMap()
> -                                                            .get(SERIALIZED_VIEW_REQUEST_ATTR);
> -        if (serializedView == null)
> -        {
> +        SerializedView serializedView = (SerializedView) externalContext.getRequestMap()
> +            .get(SERIALIZED_VIEW_REQUEST_ATTR);
> +        if (serializedView == null) {
>              if (log.isTraceEnabled()) log.trace("Processing saveSerializedView - create new serialized view");
>
>              // first call to saveSerializedView --> create SerializedView
> @@ -325,14 +302,15 @@
>              if (log.isTraceEnabled()) log.trace("Processing saveSerializedView - new serialized view created");
>          }
>
> -        if (!isSavingStateInClient(facesContext))
> -        {
> -            if (log.isTraceEnabled()) log.trace("Processing saveSerializedView - server-side state saving - save state");
> +        if (!isSavingStateInClient(facesContext)) {
> +            if (log.isTraceEnabled())
> +                log.trace("Processing saveSerializedView - server-side state saving - save state");
>              //save state in server session
>              saveSerializedViewInServletSession(facesContext, serializedView);
>
>              if (log.isTraceEnabled()) log.trace("Exiting saveSerializedView - server-side state saving - saved state");
> -            return null;
> +            Integer sequence = ViewSequenceUtils.getViewSequence(facesContext);
> +            return new SerializedView(sequence.toString(), null);
>          }
>
>          if (log.isTraceEnabled()) log.trace("Exiting saveSerializedView - client-side state saving");
> @@ -342,122 +320,108 @@
>
>      private static void checkForDuplicateIds(FacesContext context,
>                                               UIComponent component,
> -                                             Set ids)
> -    {
> +                                             Set ids) {
>          String id = component.getId();
> -        if (id != null && !ids.add(id))
> -        {
> -            throw new IllegalStateException("Client-id : "+id +
> -                                            " is duplicated in the faces tree. Component : "+component.getClientId(context)+", path: "+
> -                                            getPathToComponent(component));
> +        if (id != null && !ids.add(id)) {
> +            throw new IllegalStateException("Client-id : " + id +
> +                " is duplicated in the faces tree. Component : " + component.getClientId(context) + ", path: " +
> +                getPathToComponent(component));
>          }
>          Iterator it = component.getFacetsAndChildren();
>          boolean namingContainer = component instanceof NamingContainer;
> -        while (it.hasNext())
> -        {
> +        while (it.hasNext()) {
>              UIComponent kid = (UIComponent) it.next();
> -            if (namingContainer)
> -            {
> +            if (namingContainer) {
>                  checkForDuplicateIds(context, kid, new HashSet());
>              }
> -            else
> -            {
> +            else {
>                  checkForDuplicateIds(context, kid, ids);
>              }
>          }
>      }
>
> -    private static String getPathToComponent(UIComponent component)
> -    {
> +    private static String getPathToComponent(UIComponent component) {
>          StringBuffer buf = new StringBuffer();
>
> -        if(component == null)
> -        {
> +        if (component == null) {
>              buf.append("{Component-Path : ");
>              buf.append("[null]}");
>              return buf.toString();
>          }
>
> -        getPathToComponent(component,buf);
> +        getPathToComponent(component, buf);
>
> -        buf.insert(0,"{Component-Path : ");
> +        buf.insert(0, "{Component-Path : ");
>          buf.append("}");
>
>          return buf.toString();
>      }
>
> -    private static void getPathToComponent(UIComponent component, StringBuffer buf)
> -    {
> -        if(component == null)
> +    private static void getPathToComponent(UIComponent component, StringBuffer buf) {
> +        if (component == null)
>              return;
>
>          StringBuffer intBuf = new StringBuffer();
>
>          intBuf.append("[Class: ");
>          intBuf.append(component.getClass().getName());
> -        if(component instanceof UIViewRoot)
> -        {
> +        if (component instanceof UIViewRoot) {
>              intBuf.append(",ViewId: ");
>              intBuf.append(((UIViewRoot) component).getViewId());
>          }
> -        else
> -        {
> +        else {
>              intBuf.append(",Id: ");
>              intBuf.append(component.getId());
>          }
>          intBuf.append("]");
>
> -        buf.insert(0,intBuf.toString());
> +        buf.insert(0, intBuf.toString());
>
> -        if(component!=null)
> -        {
> -            getPathToComponent(component.getParent(),buf);
> +        if (component != null) {
> +            getPathToComponent(component.getParent(), buf);
>          }
>      }
>
>      public void writeState(FacesContext facesContext,
> -                           SerializedView serializedView) throws IOException
> -    {
> +                           SerializedView serializedView) throws IOException {
>          if (log.isTraceEnabled()) log.trace("Entering writeState");
>
> -        if (log.isTraceEnabled()) log.trace("Processing writeState - either client-side (full state) or server-side (partial information; e.g. sequence)");
> -
> -        UIViewRoot uiViewRoot = facesContext.getViewRoot();
> -        //save state in response (client-side: full state; server-side: sequence)
> -        RenderKit renderKit = getRenderKitFactory().getRenderKit(facesContext, uiViewRoot.getRenderKitId());
> -        renderKit.getResponseStateManager().writeState(facesContext, serializedView);
> -
> -        if (log.isTraceEnabled()) log.trace("Exiting writeState");
> -
> +        if (log.isTraceEnabled())
> +            log.trace("Processing writeState - either client-side (full state) or server-side (partial information; e.g. sequence)");
> +        if (serializedView != null) {
> +            UIViewRoot uiViewRoot = facesContext.getViewRoot();
> +            //save state in response (client-side: full state; server-side: sequence)
> +            RenderKit renderKit = getRenderKitFactory().getRenderKit(facesContext, uiViewRoot.getRenderKitId());
> +            renderKit.getResponseStateManager().writeState(facesContext, serializedView);
>
> +            if (log.isTraceEnabled()) log.trace("Exiting writeState");
> +        }
>      }
>
>      /**
>       * MyFaces extension
> +     *
>       * @param facesContext
>       * @param serializedView
>       * @throws IOException
>       */
>      public void writeStateAsUrlParams(FacesContext facesContext,
> -                                      SerializedView serializedView) throws IOException
> -    {
> +                                      SerializedView serializedView) throws IOException {
>          if (log.isTraceEnabled()) log.trace("Entering writeStateAsUrlParams");
>
> -        if (isSavingStateInClient(facesContext))
> -        {
> -            if (log.isTraceEnabled()) log.trace("Processing writeStateAsUrlParams - client-side state saving writing state");
> +        if (isSavingStateInClient(facesContext)) {
> +            if (log.isTraceEnabled())
> +                log.trace("Processing writeStateAsUrlParams - client-side state saving writing state");
>
>              UIViewRoot uiViewRoot = facesContext.getViewRoot();
>              //save state in response (client)
>              RenderKit renderKit = getRenderKitFactory().getRenderKit(facesContext, uiViewRoot.getRenderKitId());
>              ResponseStateManager responseStateManager = renderKit.getResponseStateManager();
> -            if (responseStateManager instanceof MyfacesResponseStateManager)
> -            {
> -                ((MyfacesResponseStateManager)responseStateManager).writeStateAsUrlParams(facesContext,
> -                                                                                          serializedView);
> +            if (responseStateManager instanceof MyfacesResponseStateManager) {
> +                ((MyfacesResponseStateManager) responseStateManager).writeStateAsUrlParams(facesContext,
> +                                                                                           serializedView);
>              }
> -            else
> -            {
> +            else {
>                  log.error("ResponseStateManager of render kit " + uiViewRoot.getRenderKitId() + " is no MyfacesResponseStateManager and does not support saving state in url parameters.");
>              }
>          }
> @@ -467,23 +431,19 @@
>
>      //helpers
>
> -    protected RenderKitFactory getRenderKitFactory()
> -    {
> -        if (_renderKitFactory == null)
> -        {
> -            _renderKitFactory = (RenderKitFactory)FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
> +    protected RenderKitFactory getRenderKitFactory() {
> +        if (_renderKitFactory == null) {
> +            _renderKitFactory = (RenderKitFactory) FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
>          }
>          return _renderKitFactory;
>      }
>
>      protected void saveSerializedViewInServletSession(FacesContext context,
> -                                                      SerializedView serializedView)
> -    {
> +                                                      SerializedView serializedView) {
>          Map sessionMap = context.getExternalContext().getSessionMap();
>          SerializedViewCollection viewCollection = (SerializedViewCollection) sessionMap
> -                .get(SERIALIZED_VIEW_SESSION_ATTR);
> -        if (viewCollection == null)
> -        {
> +            .get(SERIALIZED_VIEW_SESSION_ATTR);
> +        if (viewCollection == null) {
>              viewCollection = new SerializedViewCollection();
>              sessionMap.put(SERIALIZED_VIEW_SESSION_ATTR, viewCollection);
>          }
> @@ -492,92 +452,54 @@
>          sessionMap.put(SERIALIZED_VIEW_SESSION_ATTR, viewCollection);
>      }
>
> -    protected SerializedView getSerializedViewFromServletSession(FacesContext context, String viewId)
> -    {
> +    protected SerializedView getSerializedViewFromServletSession(FacesContext context, String viewId, String sequenceStr) {
>          ExternalContext externalContext = context.getExternalContext();
>          Map requestMap = externalContext.getRequestMap();
>          SerializedView serializedView = null;
> -        if (requestMap.containsKey(RESTORED_SERIALIZED_VIEW_REQUEST_ATTR))
> -        {
> +        if (requestMap.containsKey(RESTORED_SERIALIZED_VIEW_REQUEST_ATTR)) {
>              serializedView = (SerializedView) requestMap.get(RESTORED_SERIALIZED_VIEW_REQUEST_ATTR);
>          }
> -        else
> -        {
> +        else {
>              SerializedViewCollection viewCollection = (SerializedViewCollection) externalContext
> -                    .getSessionMap().get(SERIALIZED_VIEW_SESSION_ATTR);
> -            if (viewCollection != null)
> -            {
> -                String sequenceStr = (String) externalContext.getRequestParameterMap().get(
> -                        RendererUtils.SEQUENCE_PARAM);
> +                .getSessionMap().get(SERIALIZED_VIEW_SESSION_ATTR);
> +            if (viewCollection != null) {
>                  Integer sequence = null;
> -                if (sequenceStr == null)
> -                {
> +                if (sequenceStr == null) {
>                      // use latest sequence
> -                    Map map = externalContext.getSessionMap();
> -                    sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
> +                    sequence = ViewSequenceUtils.getCurrentSequence(context);
>                  }
> -                else
> -                {
> +                else {
>                      sequence = new Integer(sequenceStr);
>                  }
> -                if (sequence != null)
> -                {
> +                if (sequence != null) {
>                      Object state = viewCollection.get(sequence, viewId);
> -                    if (state != null)
> -                    {
> +                    if (state != null) {
>                          serializedView = deserializeView(state);
>                      }
>                  }
>              }
>              requestMap.put(RESTORED_SERIALIZED_VIEW_REQUEST_ATTR, serializedView);
> -            nextViewSequence(context);
> +            ViewSequenceUtils.nextViewSequence(context);
>          }
>          return serializedView;
>      }
>
> -    protected void nextViewSequence(FacesContext facescontext)
> -    {
> -        ExternalContext externalContext = facescontext.getExternalContext();
> -        Object sessionObj = externalContext.getSession(true);
> -        synchronized(sessionObj) // synchronized to increase sequence if multiple requests
> -                                 // are handled at the same time for the session
> -        {
> -            Map map = externalContext.getSessionMap();
> -            Integer sequence = (Integer) map.get(RendererUtils.SEQUENCE_PARAM);
> -            if(sequence == null || sequence.intValue() == Integer.MAX_VALUE)
> -            {
> -                sequence = new Integer(1);
> -            }
> -            else
> -            {
> -                sequence = new Integer(sequence.intValue() + 1);
> -            }
> -            map.put(RendererUtils.SEQUENCE_PARAM, sequence);
> -            externalContext.getRequestMap().put(RendererUtils.SEQUENCE_PARAM, sequence);
> -        }
> -    }
> -
> -    protected Object serializeView(FacesContext context, SerializedView serializedView)
> -    {
> +    protected Object serializeView(FacesContext context, SerializedView serializedView) {
>          if (log.isTraceEnabled()) log.trace("Entering serializeView");
>
> -        if(isSerializeStateInSession(context))
> -        {
> +        if (isSerializeStateInSession(context)) {
>              if (log.isTraceEnabled()) log.trace("Processing serializeView - serialize state in session");
>
>              ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
> -            try
> -            {
> +            try {
>                  OutputStream os = baos;
> -                if(isCompressStateInSession(context))
> -                {
> +                if (isCompressStateInSession(context)) {
>                      if (log.isTraceEnabled()) log.trace("Processing serializeView - serialize compressed");
>
>                      os.write(COMPRESSED_FLAG);
>                      os = new GZIPOutputStream(os, 1024);
>                  }
> -                else
> -                {
> +                else {
>                      if (log.isTraceEnabled()) log.trace("Processing serializeView - serialize uncompressed");
>
>                      os.write(UNCOMPRESSED_FLAG);
> @@ -588,110 +510,97 @@
>                  out.close();
>                  baos.close();
>
> -                if (log.isTraceEnabled()) log.trace("Exiting serializeView - serialized. Bytes : "+baos.size());
> +                if (log.isTraceEnabled()) log.trace("Exiting serializeView - serialized. Bytes : " + baos.size());
>                  return baos.toByteArray();
>              }
> -            catch (IOException e)
> -            {
> +            catch (IOException e) {
>                  log.error("Exiting serializeView - Could not serialize state: " + e.getMessage(), e);
>                  return null;
>              }
>          }
> -        else
> -        {
> +        else {
>              if (log.isTraceEnabled()) log.trace("Exiting serializeView - do not serialize state in session.");
> -            return new Object[] {serializedView.getStructure(), serializedView.getState()};
> +            return new Object[]{serializedView.getStructure(), serializedView.getState()};
>          }
>      }
>
>      /**
>       * Reads the value of the <code>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</code> context parameter.
> -     * @see SERIALIZE_STATE_IN_SESSION_PARAM
> +     *
>       * @param context <code>FacesContext</code> for the request we are processing.
>       * @return boolean true, if the server state should be serialized in the session
> +     * @see SERIALIZE_STATE_IN_SESSION_PARAM
>       */
> -    protected boolean isSerializeStateInSession(FacesContext context)
> -    {
> +    protected boolean isSerializeStateInSession(FacesContext context) {
>          String value = context.getExternalContext().getInitParameter(
> -                SERIALIZE_STATE_IN_SESSION_PARAM);
> +            SERIALIZE_STATE_IN_SESSION_PARAM);
>          boolean serialize = DEFAULT_SERIALIZE_STATE_IN_SESSION;
> -        if (value != null)
> -        {
> -           serialize = new Boolean(value).booleanValue();
> +        if (value != null) {
> +            serialize = new Boolean(value).booleanValue();
>          }
>          return serialize;
>      }
>
>      /**
>       * Reads the value of the <code>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</code> context parameter.
> -     * @see COMPRESS_SERVER_STATE_PARAM
> +     *
>       * @param context <code>FacesContext</code> for the request we are processing.
>       * @return boolean true, if the server state steam should be compressed
> +     * @see COMPRESS_SERVER_STATE_PARAM
>       */
> -    protected boolean isCompressStateInSession(FacesContext context)
> -    {
> +    protected boolean isCompressStateInSession(FacesContext context) {
>          String value = context.getExternalContext().getInitParameter(
> -                COMPRESS_SERVER_STATE_PARAM);
> +            COMPRESS_SERVER_STATE_PARAM);
>          boolean compress = DEFAULT_COMPRESS_SERVER_STATE_PARAM;
> -        if (value != null)
> -        {
> -           compress = new Boolean(value).booleanValue();
> +        if (value != null) {
> +            compress = new Boolean(value).booleanValue();
>          }
>          return compress;
>      }
>
> -    protected SerializedView deserializeView(Object state)
> -    {
> +    protected SerializedView deserializeView(Object state) {
>          if (log.isTraceEnabled()) log.trace("Entering deserializeView");
>
> -        if(state instanceof byte[])
> -        {
> -            if (log.isTraceEnabled()) log.trace("Processing deserializeView - deserializing serialized state. Bytes : "+((byte[]) state).length);
> +        if (state instanceof byte[]) {
> +            if (log.isTraceEnabled())
> +                log.trace("Processing deserializeView - deserializing serialized state. Bytes : " + ((byte[]) state).length);
>
> -            try
> -            {
> +            try {
>                  ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) state);
>                  InputStream is = bais;
> -                if(is.read() == COMPRESSED_FLAG)
> -                {
> +                if (is.read() == COMPRESSED_FLAG) {
>                      is = new GZIPInputStream(is);
>                  }
>                  ObjectInputStream in = new MyFacesObjectInputStream(
> -                        is);
> +                    is);
>                  return new SerializedView(in.readObject(), in.readObject());
>              }
> -            catch (IOException e)
> -            {
> +            catch (IOException e) {
>                  log.error("Exiting deserializeView - Could not deserialize state: " + e.getMessage(), e);
>                  return null;
>              }
> -            catch (ClassNotFoundException e)
> -            {
> +            catch (ClassNotFoundException e) {
>                  log.error("Exiting deserializeView - Could not deserialize state: " + e.getMessage(), e);
>                  return null;
>              }
>          }
> -        else if (state instanceof Object[])
> -        {
> +        else if (state instanceof Object[]) {
>              if (log.isTraceEnabled()) log.trace("Exiting deserializeView - state not serialized.");
>
>              Object[] value = (Object[]) state;
>              return new SerializedView(value[0], value[1]);
>          }
> -        else if(state == null)
> -        {
> +        else if (state == null) {
>              log.error("Exiting deserializeView - this method should not be called with a null-state.");
>              return null;
>          }
> -        else
> -        {
> -            log.error("Exiting deserializeView - this method should not be called with a state of type : "+state.getClass());
> +        else {
> +            log.error("Exiting deserializeView - this method should not be called with a state of type : " + state.getClass());
>              return null;
>          }
>      }
>
> -    protected static class SerializedViewCollection implements Serializable
> -    {
> +    protected static class SerializedViewCollection implements Serializable {
>          private static final long serialVersionUID = -3734849062185115847L;
>
>          private final List _keys = new ArrayList(DEFAULT_NUMBER_OF_VIEWS_IN_SESSION);
> @@ -701,21 +610,18 @@
>          // the garbage collector if free memory is low
>          private transient Map _oldSerializedViews = null;
>
> -        public synchronized void add(FacesContext context, Object state)
> -        {
> +        public synchronized void add(FacesContext context, Object state) {
>              Object key = new SerializedViewKey(context);
>              _serializedViews.put(key, state);
> -
> -            while (_keys.remove(key));
> +
> +            while (_keys.remove(key)) ;
>              _keys.add(key);
>
>              int views = getNumberOfViewsInSession(context);
> -            while (_keys.size() > views)
> -            {
> +            while (_keys.size() > views) {
>                  key = _keys.remove(0);
>                  Object oldView = _serializedViews.remove(key);
> -                if (oldView != null)
> -                {
> +                if (oldView != null) {
>                      getOldSerializedViewsMap().put(key, oldView);
>                  }
>              }
> @@ -723,33 +629,29 @@
>
>          /**
>           * Reads the amount (default = 20) of views to be stored in session.
> -         * @see NUMBER_OF_VIEWS_IN_SESSION_PARAM
> +         *
>           * @param context FacesContext for the current request, we are processing
>           * @return Number vf views stored in the session
> +         * @see NUMBER_OF_VIEWS_IN_SESSION_PARAM
>           */
> -        protected int getNumberOfViewsInSession(FacesContext context)
> -        {
> +        protected int getNumberOfViewsInSession(FacesContext context) {
>              String value = context.getExternalContext().getInitParameter(
> -                    NUMBER_OF_VIEWS_IN_SESSION_PARAM);
> +                NUMBER_OF_VIEWS_IN_SESSION_PARAM);
>              int views = DEFAULT_NUMBER_OF_VIEWS_IN_SESSION;
> -            if (value != null)
> -            {
> -                try
> -                {
> +            if (value != null) {
> +                try {
>                      views = Integer.parseInt(value);
> -                    if (views <= 0)
> -                    {
> +                    if (views <= 0) {
>                          log.error("Configured value for " + NUMBER_OF_VIEWS_IN_SESSION_PARAM
> -                                  + " is not valid, must be an value > 0, using default value ("
> -                                  + DEFAULT_NUMBER_OF_VIEWS_IN_SESSION);
> +                            + " is not valid, must be an value > 0, using default value ("
> +                            + DEFAULT_NUMBER_OF_VIEWS_IN_SESSION);
>                          views = DEFAULT_NUMBER_OF_VIEWS_IN_SESSION;
>                      }
>                  }
> -                catch (Throwable e)
> -                {
> +                catch (Throwable e) {
>                      log.error("Error determining the value for " + NUMBER_OF_VIEWS_IN_SESSION_PARAM
> -                              + ", expected an integer value > 0, using default value ("
> -                              + DEFAULT_NUMBER_OF_VIEWS_IN_SESSION + "): " + e.getMessage(), e);
> +                        + ", expected an integer value > 0, using default value ("
> +                        + DEFAULT_NUMBER_OF_VIEWS_IN_SESSION + "): " + e.getMessage(), e);
>                  }
>              }
>              return views;
> @@ -758,58 +660,47 @@
>          /**
>           * @return old serialized views map
>           */
> -        protected Map getOldSerializedViewsMap()
> -        {
> -            if (_oldSerializedViews == null)
> -            {
> +        protected Map getOldSerializedViewsMap() {
> +            if (_oldSerializedViews == null) {
>                  _oldSerializedViews = new ReferenceMap();
>              }
>              return _oldSerializedViews;
>          }
>
> -        public Object get(Integer sequence, String viewId)
> -        {
> +        public Object get(Integer sequence, String viewId) {
>              Object key = new SerializedViewKey(viewId, sequence);
>              Object value = _serializedViews.get(key);
> -            if (value == null)
> -            {
> +            if (value == null) {
>                  value = getOldSerializedViewsMap().get(key);
>              }
>              return value;
>          }
>      }
>
> -    protected static class SerializedViewKey implements Serializable
> -    {
> +    protected static class SerializedViewKey implements Serializable {
>          private static final long serialVersionUID = -1170697124386063642L;
>
>          private final String _viewId;
>          private final Integer _sequenceId;
>
> -        public SerializedViewKey(String viewId, Integer sequence)
> -        {
> +        public SerializedViewKey(String viewId, Integer sequence) {
>              _sequenceId = sequence;
>              _viewId = viewId;
>          }
>
> -        public SerializedViewKey(FacesContext context)
> -        {
> -            _sequenceId = RendererUtils.getViewSequence(context);
> +        public SerializedViewKey(FacesContext context) {
> +            _sequenceId = ViewSequenceUtils.getViewSequence(context);
>              _viewId = context.getViewRoot().getViewId();
>          }
>
> -        public boolean equals(Object obj)
> -        {
> -            if (obj == null)
> -            {
> +        public boolean equals(Object obj) {
> +            if (obj == null) {
>                  return false;
>              }
> -            if (obj == this)
> -            {
> +            if (obj == this) {
>                  return true;
>              }
> -            if (obj instanceof SerializedViewKey)
> -            {
> +            if (obj instanceof SerializedViewKey) {
>                  SerializedViewKey other = (SerializedViewKey) obj;
>                  return new EqualsBuilder().append(other._viewId, _viewId).append(other._sequenceId,
>                                                                                   _sequenceId).isEquals();
> @@ -817,8 +708,7 @@
>              return false;
>          }
>
> -        public int hashCode()
> -        {
> +        public int hashCode() {
>              return new HashCodeBuilder().append(_viewId).append(_sequenceId).toHashCode();
>          }
>      }
>
> Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java
> URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java?view=diff&rev=447870&r1=447869&r2=447870
> ==============================================================================
> --- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java (original)
> +++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlResponseStateManager.java Tue Sep 19 08:06:22 2006
> @@ -34,8 +34,7 @@
>   * @version $Revision$ $Date$
>   */
>  public class HtmlResponseStateManager
> -        extends MyfacesResponseStateManager
> -{
> +    extends MyfacesResponseStateManager {
>      private static final Log log = LogFactory.getLog(HtmlResponseStateManager.class);
>
>      private static final String TREE_PARAM = "jsf_tree";
> @@ -45,80 +44,78 @@
>      private static final String BASE64_STATE_PARAM = "jsf_state_64";
>
>      public void writeState(FacesContext facescontext,
> -                           StateManager.SerializedView serializedview) throws IOException
> -    {
> +                           StateManager.SerializedView serializedview) throws IOException {
>          ResponseWriter responseWriter = facescontext.getResponseWriter();
>
> -        if(facescontext.getApplication().getStateManager().isSavingStateInClient(facescontext))
> -        {
> +        if (facescontext.getApplication().getStateManager().isSavingStateInClient(facescontext)) {
>              Object treeStruct = serializedview.getStructure();
>              Object compStates = serializedview.getState();
>
> -            if (treeStruct != null)
> -            {
> -                if (treeStruct instanceof String)
> -                {
> +            if (treeStruct != null) {
> +                if (treeStruct instanceof String) {
>                      responseWriter.startElement(HTML.INPUT_ELEM, null);
>                      responseWriter.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
>                      responseWriter.writeAttribute(HTML.NAME_ATTR, TREE_PARAM, null);
>                      responseWriter.writeAttribute(HTML.ID_ATTR, TREE_PARAM, null);
> -                    if(StateUtils.isSecure(facescontext.getExternalContext()))
> +                    if (StateUtils.isSecure(facescontext.getExternalContext()))
>                          treeStruct = StateUtils.construct(treeStruct, facescontext.getExternalContext());
>                      responseWriter.writeAttribute(HTML.VALUE_ATTR, treeStruct, null);
>                      responseWriter.endElement(HTML.INPUT_ELEM);
>                  }
> -                else
> -                {
> +                else {
>                      responseWriter.startElement(HTML.INPUT_ELEM, null);
>                      responseWriter.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
>                      responseWriter.writeAttribute(HTML.NAME_ATTR, BASE64_TREE_PARAM, null);
>                      responseWriter.writeAttribute(HTML.ID_ATTR, BASE64_TREE_PARAM, null);
>                      responseWriter.writeAttribute(HTML.VALUE_ATTR,
> -                            StateUtils.construct(treeStruct, facescontext.getExternalContext()), null);
> +                                                  StateUtils.construct(treeStruct, facescontext.getExternalContext()), null);
>                      responseWriter.endElement(HTML.INPUT_ELEM);
>                  }
>              }
> -            else
> -            {
> +            else {
>                  log.error("No tree structure to be saved in client response!");
>              }
>
> -            if (compStates != null)
> -            {
> -                if (compStates instanceof String)
> -                {
> +            if (compStates != null) {
> +                if (compStates instanceof String) {
>                      responseWriter.startElement(HTML.INPUT_ELEM, null);
>                      responseWriter.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
>                      responseWriter.writeAttribute(HTML.NAME_ATTR, STATE_PARAM, null);
>                      responseWriter.writeAttribute(HTML.ID_ATTR, STATE_PARAM, null);
> -                    if(StateUtils.isSecure(facescontext.getExternalContext()))
> +                    if (StateUtils.isSecure(facescontext.getExternalContext()))
>                          compStates = StateUtils.construct(compStates, facescontext.getExternalContext());
>                      responseWriter.writeAttribute(HTML.VALUE_ATTR, compStates, null);
>                      responseWriter.endElement(HTML.INPUT_ELEM);
>                  }
> -                else
> -                {
> +                else {
>                      responseWriter.startElement(HTML.INPUT_ELEM, null);
>                      responseWriter.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
>                      responseWriter.writeAttribute(HTML.NAME_ATTR, BASE64_STATE_PARAM, null);
>                      responseWriter.writeAttribute(HTML.ID_ATTR, BASE64_STATE_PARAM, null);
>                      responseWriter.writeAttribute(HTML.VALUE_ATTR,
> -                            StateUtils.construct(compStates, facescontext.getExternalContext()), null);
> +                                                  StateUtils.construct(compStates, facescontext.getExternalContext()), null);
>                      responseWriter.endElement(HTML.INPUT_ELEM);
>                  }
>              }
> -            else
> -            {
> +            else {
>                  log.error("No component states to be saved in client response!");
>              }
>          }
> -        else
> -        {
> -            responseWriter.startElement(HTML.INPUT_ELEM, null);
> -            responseWriter.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
> -            responseWriter.writeAttribute(HTML.NAME_ATTR, RendererUtils.SEQUENCE_PARAM, null);
> -            responseWriter.writeAttribute(HTML.VALUE_ATTR, RendererUtils.getViewSequence(facescontext), null);
> -            responseWriter.endElement(HTML.INPUT_ELEM);
> +        else {
> +            // write viewSequence
> +            Object treeStruct = serializedview.getStructure();
> +            if (treeStruct != null) {
> +                if (treeStruct instanceof String) {
> +                    responseWriter.startElement(HTML.INPUT_ELEM, null);
> +                    responseWriter.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
> +                    responseWriter.writeAttribute(HTML.NAME_ATTR, TREE_PARAM, null);
> +                    responseWriter.writeAttribute(HTML.ID_ATTR, TREE_PARAM, null);
> +                    if (StateUtils.isSecure(facescontext.getExternalContext()))
> +                        treeStruct = StateUtils.construct(treeStruct, facescontext.getExternalContext());
> +                    responseWriter.writeAttribute(HTML.VALUE_ATTR, treeStruct, null);
> +                    responseWriter.endElement(HTML.INPUT_ELEM);
> +                }
> +            }
>          }
>
>          responseWriter.startElement(HTML.INPUT_ELEM, null);
> @@ -131,55 +128,46 @@
>
>      /**
>       * MyFaces extension
> +     *
>       * @param facescontext
>       * @param serializedview
>       * @throws IOException
>       */
>      public void writeStateAsUrlParams(FacesContext facescontext,
> -                                      StateManager.SerializedView serializedview) throws IOException
> -    {
> +                                      StateManager.SerializedView serializedview) throws IOException {
>          ResponseWriter responseWriter = facescontext.getResponseWriter();
>          Object treeStruct = serializedview.getStructure();
>          Object compStates = serializedview.getState();
>
> -        if (treeStruct != null)
> -        {
> -            if (treeStruct instanceof String)
> -            {
> -               if(StateUtils.isSecure(facescontext.getExternalContext()))
> -                       treeStruct = StateUtils.construct(treeStruct,facescontext.getExternalContext());
> -                writeStateParam(responseWriter, TREE_PARAM, (String)treeStruct);
> +        if (treeStruct != null) {
> +            if (treeStruct instanceof String) {
> +                if (StateUtils.isSecure(facescontext.getExternalContext()))
> +                    treeStruct = StateUtils.construct(treeStruct, facescontext.getExternalContext());
> +                writeStateParam(responseWriter, TREE_PARAM, (String) treeStruct);
>              }
> -            else
> -            {
> +            else {
>                  writeStateParam(responseWriter, BASE64_TREE_PARAM,
> -                        StateUtils.construct(treeStruct, facescontext.getExternalContext()));
> +                                StateUtils.construct(treeStruct, facescontext.getExternalContext()));
>              }
>          }
> -        else
> -        {
> +        else {
>              log.error("No tree structure to be saved in client response!");
>          }
>
> -        if (compStates != null)
> -        {
> -            if (treeStruct != null)
> -            {
> +        if (compStates != null) {
> +            if (treeStruct != null) {
>                  responseWriter.write('&');
>              }
> -            if (compStates instanceof String)
> -            {
> -               if(StateUtils.isSecure(facescontext.getExternalContext()))
> -                       compStates = StateUtils.construct(compStates, facescontext.getExternalContext());
> -                writeStateParam(responseWriter, STATE_PARAM, (String)compStates);
> +            if (compStates instanceof String) {
> +                if (StateUtils.isSecure(facescontext.getExternalContext()))
> +                    compStates = StateUtils.construct(compStates, facescontext.getExternalContext());
> +                writeStateParam(responseWriter, STATE_PARAM, (String) compStates);
>              }
> -            else
> -            {
> +            else {
>                  writeStateParam(responseWriter, BASE64_STATE_PARAM, StateUtils.construct(compStates, facescontext.getExternalContext()));
>              }
>          }
> -        else
> -        {
> +        else {
>              log.error("No component states to be saved in client response!");
>          }
>
> @@ -189,56 +177,48 @@
>          writeStateParam(responseWriter, VIEWID_PARAM, facescontext.getViewRoot().getViewId());
>      }
>
> -    public Object getTreeStructureToRestore(FacesContext facescontext, String viewId)
> -    {
> +    public Object getTreeStructureToRestore(FacesContext facescontext, String viewId) {
>          Map reqParamMap = facescontext.getExternalContext().getRequestParameterMap();
>          Object param = reqParamMap.get(VIEWID_PARAM);
> -        if (param == null || !param.equals(viewId))
> -        {
> +        if (param == null || !param.equals(viewId)) {
>              //no saved state or state of different viewId
>              return null;
>          }
>
>          param = reqParamMap.get(TREE_PARAM);
> -        if (param != null)
> -        {
> -               if(StateUtils.isSecure(facescontext.getExternalContext()))
> -                       param = StateUtils.construct(param, facescontext.getExternalContext());
> +        if (param != null) {
> +            if (StateUtils.isSecure(facescontext.getExternalContext()))
> +                param = StateUtils.construct(param, facescontext.getExternalContext());
>              return param;
>          }
>
>          param = reqParamMap.get(BASE64_TREE_PARAM);
> -        if (param != null)
> -        {
> -            return StateUtils.reconstruct((String)param, facescontext.getExternalContext());
> +        if (param != null) {
> +            return StateUtils.reconstruct((String) param, facescontext.getExternalContext());
>          }
>
>          return null;
>      }
>
> -    public Object getComponentStateToRestore(FacesContext facescontext)
> -    {
> +    public Object getComponentStateToRestore(FacesContext facescontext) {
>          Map reqParamMap = facescontext.getExternalContext().getRequestParameterMap();
>          Object param = reqParamMap.get(STATE_PARAM);
> -        if (param != null)
> -        {
> -               if(StateUtils.isSecure(facescontext.getExternalContext()))
> -                       param = StateUtils.construct(param, facescontext.getExternalContext());
> +        if (param != null) {
> +            if (StateUtils.isSecure(facescontext.getExternalContext()))
> +                param = StateUtils.construct(param, facescontext.getExternalContext());
>              return param;
>          }
>
>          param = reqParamMap.get(BASE64_STATE_PARAM);
> -        if (param != null)
> -        {
> -            return StateUtils.reconstruct((String)param, facescontext.getExternalContext());
> +        if (param != null) {
> +            return StateUtils.reconstruct((String) param, facescontext.getExternalContext());
>          }
>
>          return null;
>      }
>
>      private void writeStateParam(ResponseWriter writer, String name, String value)
> -        throws IOException
> -    {
> +        throws IOException {
>          writer.write(name);
>          writer.write('=');
>          writer.write(URLEncoder.encode(value, writer.getCharacterEncoding()));
>
> Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
> URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java?view=diff&rev=447870&r1=447869&r2=447870
> ==============================================================================
> --- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java (original)
> +++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java Tue Sep 19 08:06:22 2006
> @@ -60,8 +60,6 @@
>      public static final String ACTION_FOR_LIST = "org.apache.myfaces.ActionForList";
>      public static final String ACTION_FOR_PHASE_LIST = "org.apache.myfaces.ActionForPhaseList";
>
> -    public static final String SEQUENCE_PARAM = "jsf_sequence";
> -
>      public static String getPathToComponent(UIComponent component) {
>          StringBuffer buf = new StringBuffer();
>
> @@ -699,20 +697,6 @@
>          dest.setTabindex(src.getTabindex());
>          dest.setTitle(src.getTitle());
>          dest.setValidator(src.getValidator());
> -    }
> -
> -    public static Integer getViewSequence(FacesContext facescontext) {
> -        Map map = facescontext.getExternalContext().getRequestMap();
> -        Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
> -        if (sequence == null) {
> -            sequence = new Integer(1);
> -            map.put(SEQUENCE_PARAM, sequence);
> -
> -            synchronized (facescontext.getExternalContext().getSession(true)) {
> -                facescontext.getExternalContext().getSessionMap().put(RendererUtils.SEQUENCE_PARAM, sequence);
> -            }
> -        }
> -        return sequence;
>      }
>
>      public static UIComponent findComponent(UIComponent headerComp, Class clazz) {
>
> Added: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ViewSequenceUtils.java
> URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ViewSequenceUtils.java?view=auto&rev=447870
> ==============================================================================
> --- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ViewSequenceUtils.java (added)
> +++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ViewSequenceUtils.java Tue Sep 19 08:06:22 2006
> @@ -0,0 +1,85 @@
> +/*
>
> + * Copyright 2004 The Apache Software Foundation.
>
> + *
>
> + * Licensed under the Apache License, Version 2.0 (the "License");
>
> + * you may not use this file except in compliance with the License.
>
> + * You may obtain a copy of the License at
>
> + *
>
> + *      http://www.apache.org/licenses/LICENSE-2.0
>
> + *
>
> + * Unless required by applicable law or agreed to in writing, software
>
> + * distributed under the License is distributed on an "AS IS" BASIS,
>
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>
> + * See the License for the specific language governing permissions and
>
> + * limitations under the License.
>
> + */
>
> +package org.apache.myfaces.shared.renderkit;
>
> +
>
> +import javax.faces.context.ExternalContext;
>
> +import javax.faces.context.FacesContext;
>
> +import java.util.Map;
>
> +
>
> +/**
>
> + * @author Thomas Spiegl
>
> + */
>
> +public class ViewSequenceUtils {
>
> +    private static final String SEQUENCE_PARAM = "jsf_sequence";
>
> +
>
> +    /**
>
> +     * Increments view sequence by 1.
>
> +     *
>
> +     * @param facescontext
>
> +     */
>
> +    public static void nextViewSequence(FacesContext facescontext) {
>
> +        ExternalContext externalContext = facescontext.getExternalContext();
>
> +        Object sessionObj = externalContext.getSession(true);
>
> +        synchronized (sessionObj) // synchronized to increase sequence if multiple requests
>
> +        // are handled at the same time for the session
>
> +        {
>
> +            Map map = externalContext.getSessionMap();
>
> +            Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
>
> +            if (sequence == null || sequence.intValue() == Integer.MAX_VALUE) {
>
> +                sequence = new Integer(1);
>
> +            }
>
> +            else {
>
> +                sequence = new Integer(sequence.intValue() + 1);
>
> +            }
>
> +            map.put(SEQUENCE_PARAM, sequence);
>
> +            externalContext.getRequestMap().put(SEQUENCE_PARAM, sequence);
>
> +        }
>
> +    }
>
> +
>
> +    /**
>
> +     * Returns current view sequence and sets current view sequence to Integer(1) if
>
> +     * current sequence value is NULL.
>
> +     *
>
> +     * @param facescontext
>
> +     * @return
>
> +     */
>
> +    public static Integer getViewSequence(FacesContext facescontext) {
>
> +        Map map = facescontext.getExternalContext().getRequestMap();
>
> +        Integer sequence = (Integer) map.get(SEQUENCE_PARAM);
>
> +        if (sequence == null) {
>
> +            sequence = new Integer(1);
>
> +            map.put(SEQUENCE_PARAM, sequence);
>
> +
>
> +            synchronized (facescontext.getExternalContext().getSession(true)) {
>
> +                facescontext.getExternalContext().getSessionMap().put(SEQUENCE_PARAM, sequence);
>
> +            }
>
> +        }
>
> +        return sequence;
>
> +    }
>
> +
>
> +
>
> +    /**
>
> +     * Current view sequence, may be NULL!
>
> +     *
>
> +     * @param context
>
> +     * @return
>
> +     */
>
> +    public static Integer getCurrentSequence(FacesContext context) {
>
> +        Map map = context.getExternalContext().getSessionMap();
>
> +        return (Integer) map.get(SEQUENCE_PARAM);
>
> +    }
>
> +
>
> +}
>
>
> Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
> URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java?view=diff&rev=447870&r1=447869&r2=447870
> ==============================================================================
> --- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java (original)
> +++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java Tue Sep 19 08:06:22 2006
> @@ -214,8 +214,7 @@
>              onClick.append(component.getClientId(facesContext));
>              onClick.append("'});return false;");
>          }
> -        else
> -        {
> +        else {
>              renderFormSubmitScriptIfNecessary(facesContext);
>
>              StringBuffer params = addChildParameters(component, nestingForm);
> @@ -223,12 +222,11 @@
>              String target = getTarget(component);
>
>              onClick.append("return ").
> -                    append(HtmlRendererUtils.SUBMIT_FORM_FN_NAME).append("('").
> -                    append(formName).append("','").
> -                    append(clientId).append("'");
> +                append(HtmlRendererUtils.SUBMIT_FORM_FN_NAME).append("('").
> +                append(formName).append("','").
> +                append(clientId).append("'");
>
> -            if(params.length()>2 || target != null)
> -            {
> +            if (params.length() > 2 || target != null) {
>                  onClick.append(",").
>                      append(params).append(",").
>                      append(target == null ? "null" : ("'" + target + "'"));
> @@ -251,16 +249,14 @@
>          Map map = facesContext.getExternalContext().getRequestMap();
>          Boolean firstLink = (Boolean) map.get(FIRST_LINK_ON_PAGE);
>
> -        if(firstLink == null || firstLink.equals(Boolean.TRUE))
> -        {
> -            map.put(FIRST_LINK_ON_PAGE,Boolean.FALSE);
> +        if (firstLink == null || firstLink.equals(Boolean.TRUE)) {
> +            map.put(FIRST_LINK_ON_PAGE, Boolean.FALSE);
>              HtmlRendererUtils.renderFormSubmitScript(facesContext);
>
>          }
>      }
>
> -    private String getTarget(UIComponent component)
> -    {
> +    private String getTarget(UIComponent component) {
>          // for performance reason: double check for the target attribute
>          String target;
>          if (component instanceof HtmlCommandLink) {
> @@ -272,8 +268,7 @@
>          return target;
>      }
>
> -    private StringBuffer addChildParameters(UIComponent component, UIComponent nestingForm)
> -    {
> +    private StringBuffer addChildParameters(UIComponent component, UIComponent nestingForm) {
>          //add child parameters
>          StringBuffer params = new StringBuffer();
>          params.append("[");
> @@ -295,8 +290,7 @@
>                  String strParamValue = value != null ? org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder.encode(value.toString(), false, false) : "";
>
>
> -                if(params.length()>1)
> -                {
> +                if (params.length() > 1) {
>                      params.append(",");
>                  }
>
> @@ -360,11 +354,6 @@
>          hrefBuf.append("&");
>          if (stateManager.isSavingStateInClient(facesContext)) {
>              hrefBuf.append(URL_STATE_MARKER);
> -        }
> -        else {
> -            hrefBuf.append(RendererUtils.SEQUENCE_PARAM);
> -            hrefBuf.append('=');
> -            hrefBuf.append(org.apache.myfaces.shared.renderkit.RendererUtils.getViewSequence(facesContext));
>          }
>          String href = facesContext.getExternalContext().encodeActionURL(hrefBuf.toString());
>          writer.startElement(HTML.ANCHOR_ELEM, component);
>
> Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DummyFormUtils.java
> URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DummyFormUtils.java?view=diff&rev=447870&r1=447869&r2=447870
> ==============================================================================
> --- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DummyFormUtils.java (original)
> +++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/util/DummyFormUtils.java Tue Sep 19 08:06:22 2006
> @@ -38,15 +38,14 @@
>   * communication with the server is necessary. These components can use
>   * methods on the <code>DummyFormRequestInfo</code> object accessable via this
>   * class to register parameters and get the name of a form to submit.
> - * <p>
> + * <p/>
>   * Only one dummy form will be rendered into the response.
> - *
> + *
>   * @author Manfred Geiler (latest modification by $Author$)
>   * @author Bruno Aranda
>   * @version $Revision$ $Date$
>   */
> -public class DummyFormUtils
> -{
> +public class DummyFormUtils {
>      private static final Log log = LogFactory.getLog(DummyFormUtils.class);
>
>      public static final String DUMMY_FORM_NAME = "linkDummyForm";
> @@ -55,7 +54,7 @@
>      /**
>       * Used to store the instance of <code>DummyFormRequestInfo</code> in the request map
>       */
> -    public static final String DUMMY_FORM_INFO = DummyFormUtils.class.getName()+".DUMMY_FORM_INFO";
> +    public static final String DUMMY_FORM_INFO = DummyFormUtils.class.getName() + ".DUMMY_FORM_INFO";
>
>
>      public static String getDummyFormName() {
> @@ -70,55 +69,47 @@
>       * @param facesContext
>       * @param writeDummyForm
>       */
> -    public static void setWriteDummyForm(FacesContext facesContext, boolean writeDummyForm)
> -    {
> -        if (!writeDummyForm)
> -        {
> +    public static void setWriteDummyForm(FacesContext facesContext, boolean writeDummyForm) {
> +        if (!writeDummyForm) {
>              return;
>          }
>
> -         if (!isWriteDummyForm(facesContext))
> -         {
> -             DummyFormRequestInfo dummyFormInfo = new DummyFormRequestInfo();
> -             facesContext.getExternalContext().getRequestMap().put(DUMMY_FORM_INFO, dummyFormInfo);
> -         }
> +        if (!isWriteDummyForm(facesContext)) {
> +            DummyFormRequestInfo dummyFormInfo = new DummyFormRequestInfo();
> +            facesContext.getExternalContext().getRequestMap().put(DUMMY_FORM_INFO, dummyFormInfo);
> +        }
>      }
>
>      /**
>       * Checks if the DummyFormRequestInfo is already in the request map.
> +     *
>       * @param facesContext
>       * @return boolean true, if dummy form is to be written
>       */
> -    public static boolean isWriteDummyForm(FacesContext facesContext)
> -    {
> +    public static boolean isWriteDummyForm(FacesContext facesContext) {
>          return facesContext.getExternalContext().getRequestMap().containsKey(DUMMY_FORM_INFO);
>      }
>
>      /**
>       * Delegator method to add a parameter to the DummyFormRequestInfo object in the request
> -     *
> +     *
>       * @param facesContext
>       * @param paramName
>       */
> -    public static void addDummyFormParameter(FacesContext facesContext, String paramName)
> -    {
> -        if (isWriteDummyForm(facesContext))
> -        {
> +    public static void addDummyFormParameter(FacesContext facesContext, String paramName) {
> +        if (isWriteDummyForm(facesContext)) {
>              DummyFormRequestInfo dummyFormInfo = (DummyFormRequestInfo) facesContext.getExternalContext().getRequestMap().get(DUMMY_FORM_INFO);
>              dummyFormInfo.addDummyFormParameter(paramName);
>          }
> -        else
> -        {
> -            if (log.isWarnEnabled())
> -            {
> +        else {
> +            if (log.isWarnEnabled()) {
>                  log.warn("Dummy Form parameter was not added because dummy form is not written");
>              }
>          }
>      }
>
>      public static Set getDummyFormParameters(FacesContext facesContext) {
> -        if (isWriteDummyForm(facesContext))
> -        {
> +        if (isWriteDummyForm(facesContext)) {
>              DummyFormRequestInfo dummyFormInfo = (DummyFormRequestInfo) facesContext.getExternalContext().getRequestMap().get(DUMMY_FORM_INFO);
>              return dummyFormInfo.getDummyFormParams();
>          }
> @@ -128,8 +119,7 @@
>
>
>      public static void writeDummyForm(ResponseWriter writer,
> -                                      Set dummyFormParams) throws IOException
> -    {
> +                                      Set dummyFormParams) throws IOException {
>          FacesContext facesContext = FacesContext.getCurrentInstance();
>          ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
>          String viewId = facesContext.getViewRoot().getViewId();
> @@ -153,47 +143,35 @@
>          StateManager.SerializedView serializedView = stateManager.saveSerializedView(facesContext);
>          // Adam Winer - TOMAHAWK-253: Ideally, this code should be refactored so that the server-side code is also calling StateManager.writeState() too
>          //    it's a significant problem that DummyFormUtils has hardcoded knowledge of how the StateManager works.
> -        if (stateManager.isSavingStateInClient(facesContext))
> -        {
> +        if (stateManager.isSavingStateInClient(facesContext)) {
>              //render state parameters
>              stateManager.writeState(facesContext, serializedView);
>          }
> -        else
> -        {
> -            writer.startElement(HTML.INPUT_ELEM, null);
> -            writer.writeAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.TYPE_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.INPUT_TYPE_HIDDEN, null);
> -            writer.writeAttribute(HTML.NAME_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.SEQUENCE_PARAM, null);
> -            writer.writeAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.VALUE_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.getViewSequence(facesContext), null);
> -            writer.endElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.INPUT_ELEM);
> -        }
>
>          if (org.apache.myfaces.shared_tomahawk.config.MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll())
>          {
> -            JavascriptUtils.renderAutoScrollHiddenInput(facesContext,writer);
> +            JavascriptUtils.renderAutoScrollHiddenInput(facesContext, writer);
>          }
>
>          org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.writePrettyLineSeparator(facesContext);
> -        if (dummyFormParams != null)
> -        {
> +        if (dummyFormParams != null) {
>              org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.renderHiddenCommandFormParams(writer, dummyFormParams);
>              org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.renderClearHiddenCommandFormParamsFunction(writer,
> -                                                                         DUMMY_FORM_NAME,
> -                                                                         dummyFormParams, null);
> +                                                                                                                           DUMMY_FORM_NAME,
> +                                                                                                                           dummyFormParams, null);
>          }
>          org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils.writePrettyLineSeparator(facesContext);
>
>          writer.endElement(HTML.FORM_ELEM);
>      }
> -
> -    public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
> -    {
> -       FormInfo formInfo = _ComponentUtils.findNestingForm(uiComponent, facesContext);
> -       if (formInfo != null)
> -       {
> -               return formInfo;
> -       }
> -
> +
> +    public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext) {
> +        FormInfo formInfo = _ComponentUtils.findNestingForm(uiComponent, facesContext);
> +        if (formInfo != null) {
> +            return formInfo;
> +        }
> +
>          DummyFormUtils.setWriteDummyForm(facesContext, true);
> -       return new FormInfo(null, DUMMY_FORM_NAME);
> +        return new FormInfo(null, DUMMY_FORM_NAME);
>      }
>  }
>
>
>

Re: Don't commit massive format changes with other changes

Posted by Jurgen Lust <Ju...@gmail.com>.
We could put Jalopy in the Maven build process, I just finished writing
a very simple plugin for it, for the internal framework I'm setting up
at work... We've been using Jalopy for over a year now and we're very
happy about it.

Jurgen

Op di, 19-09-2006 te 18:56 +0200, schreef Mario Ivankovits:
> Hi Martin!
> > Oh my, I'm going under cover!
> >
> > This has started the single longest discussion on the mailing-list the
> > last time ;)
> I hoped you already discussed it :-), and regarding to
> http://wiki.apache.org/myfaces/MyFaces_Developer_Notes this is the case.
> 
> The decision was to use "Suns Java Code Conventions" (ok, I dont like it
> that much ;-) ), however, lets do it that way.
> 
> Ciao,
> Mario
> 


Re: Don't commit massive format changes with other changes

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Martin!
> Oh my, I'm going under cover!
>
> This has started the single longest discussion on the mailing-list the
> last time ;)
I hoped you already discussed it :-), and regarding to
http://wiki.apache.org/myfaces/MyFaces_Developer_Notes this is the case.

The decision was to use "Suns Java Code Conventions" (ok, I dont like it
that much ;-) ), however, lets do it that way.

Ciao,
Mario


Re: Don't commit massive format changes with other changes

Posted by Martin Marinschek <ma...@gmail.com>.
Oh my, I'm going under cover!

This has started the single longest discussion on the mailing-list the
last time ;)

regards,

Martin

On 9/19/06, Cagatay Civici <ca...@gmail.com> wrote:
> Since eclipse has a similiar feature too, I'll do the one for eclipse once
> Mario is done with the IDEA one.
>
> Cagatay
>
>
> On 9/19/06, Mario Ivankovits < imario@apache.org> wrote:
> > Hi!
> >
> > Mike, I am with you, though, (another question about this topic) do you
> > know, do we have a wiki page which defines which codestyle we have to use?
> >
> > Currently, we really have a mixture, which isnt good too.
> > Also I propose to create a codestyle file for at least IDEA and Eclipse
> > - as far as I know, in IDEA you can export the codestyle preferences.
> > I can do the IDEA one once we defined our codestyle to use.
> > I'll commit it to our svn then so everyone can import and use it then.
> >
> > Ciao,
> > Mario
> >
> >
>
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Don't commit massive format changes with other changes

Posted by Cagatay Civici <ca...@gmail.com>.
Since eclipse has a similiar feature too, I'll do the one for eclipse once
Mario is done with the IDEA one.

Cagatay

On 9/19/06, Mario Ivankovits <im...@apache.org> wrote:
>
> Hi!
>
> Mike, I am with you, though, (another question about this topic) do you
> know, do we have a wiki page which defines which codestyle we have to use?
>
> Currently, we really have a mixture, which isnt good too.
> Also I propose to create a codestyle file for at least IDEA and Eclipse
> - as far as I know, in IDEA you can export the codestyle preferences.
> I can do the IDEA one once we defined our codestyle to use.
> I'll commit it to our svn then so everyone can import and use it then.
>
> Ciao,
> Mario
>
>

Re: Don't commit massive format changes with other changes

Posted by Mario Ivankovits <im...@apache.org>.
Hi!

Mike, I am with you, though, (another question about this topic) do you
know, do we have a wiki page which defines which codestyle we have to use?

Currently, we really have a mixture, which isnt good too.
Also I propose to create a codestyle file for at least IDEA and Eclipse
- as far as I know, in IDEA you can export the codestyle preferences.
I can do the IDEA one once we defined our codestyle to use.
I'll commit it to our svn then so everyone can import and use it then.

Ciao,
Mario