ResponseStateManager (Java EE 5)

Java EE API


javax.faces.render Class ResponseStateManager

java.lang.Object
  extended by javax.faces.render.ResponseStateManager

public abstract class ResponseStateManager
extends Object


ResponseStateManagerjavax.faces.application.StateManager 的帮助类,它了解用来生成响应的特定呈现技术。它是单件抽象类,由 RenderKit 提供。此类了解保存状态的机制,不管它是隐藏字段、会话还是两者的组合。

英文文档:

ResponseStateManager is the helper class to StateManager that knows the specific rendering technology being used to generate the response. It is a singleton abstract class, vended by the RenderKit. This class knows the mechanics of saving state, whether it be in hidden fields, session, or some combination of the two.


Field Summary
static String
static String
 
Constructor Summary
 
Method Summary
 Object
 Object
 Object
 boolean
 void
 void
 
Methods inherited from class java.lang.Object
 

Field Detail

英文文档:

RENDER_KIT_ID_PARAM

public static final String RENDER_KIT_ID_PARAM

The name of the request parameter used by the default implementation of ViewHandler.calculateRenderKitId(javax.faces.context.FacesContext) to derive a RenderKit ID.

See Also:
Constant Field Values


英文文档:

VIEW_STATE_PARAM

public static final String VIEW_STATE_PARAM

Implementations must use this value as the name and id of the client parameter in which to save the state between requests.

Since:
1.2
See Also:
Constant Field Values

Constructor Detail

public ResponseStateManager()
英文文档:

ResponseStateManager

public ResponseStateManager()
Method Detail

public void writeState(FacesContext context, Object state) throws java.io.IOException
英文文档:

writeState

public void writeState(FacesContext context,
                       Object state)
                throws IOException
Throws:
IOException

public void writeState(FacesContext context, StateManager.SerializedView state) throws java.io.IOException

接受参数 state 并使用当前的 ResponseWriter 将其写入到输出,此 writer 必须已位于合适位置。

如果 javax.faces.application.StateManager.SerializedView 将被写出到隐藏字段,则实现必须谨慎地执行所有必要的字符替换,以便 String 适合用作 HTTP 请求参数。

如果此应用程序的状态保存方法为 javax.faces.application.StateManager#STATE_SAVING_METHOD_CLIENT,则实现可以对要保存到客户端的状态进行加密。建议状态对客户端不可读,并且易于发现是否被篡改。引用实现遵守这些建议。

deprecated 此方法由 #writeState(javax.faces.context.FacesContext,java.lang.Object) 取代。此方法的默认实现不执行任何操作。
context 当前请求的 FacesContext 实例
state 以前保存的序列化状态信息
英文文档:

writeState

public void writeState(FacesContext context,
                       StateManager.SerializedView state)
                throws IOException
Deprecated. This method has been replaced by writeState(javax.faces.context.FacesContext,java.lang.Object). The default implementation of this method does nothing.

Take the argument state and write it into the output using the current ResponseWriter, which must be correctly positioned already.

If the StateManager.SerializedView is to be written out to hidden fields, the implementation must take care to make all necessary character replacements to make the Strings suitable for inclusion as an HTTP request paramater.

If the state saving method for this application is StateManager.STATE_SAVING_METHOD_CLIENT, the implementation may encrypt the state to be saved to the client. We recommend that the state be unreadable by the client, and also be tamper evident. The reference implementation follows these recommendations.

Parameters:
context - The FacesContext instance for the current request
state - The serialized state information previously saved
Throws:
IOException

public Object getState(FacesContext context, String viewId)

实现必须检查当前的请求并返回一个 Object,用来表示传入以前调用的 #writeState(javax.faces.context.FacesContext,java.lang.Object) 的树结构和组件状态。

为了向后兼容现有的 ResponseStateManager 实现,此方法的默认实现调用 #getTreeStructureToRestore#getComponentStateToRestore,并创建和返回包含两个元素的 Object 数组,其中元素 0 包含 structure 属性,元素 1 包含 SerializedViewstate 属性。

since1.2
context 当前请求的 FacesContext 实例
viewId 要恢复的视图的视图标识符
return 传入 writeState 的树结构和组件状态 Object。如果为初始请求,则此方法返回 null
英文文档:

getState

public Object getState(FacesContext context,
                       String viewId)

The implementation must inspect the current request and return an Object representing the tree structure and component state passed in to a previous invocation of writeState(javax.faces.context.FacesContext,java.lang.Object).

For backwards compatability with existing ResponseStateManager implementations, the default implementation of this method calls getTreeStructureToRestore(javax.faces.context.FacesContext, java.lang.String) and getComponentStateToRestore(javax.faces.context.FacesContext) and creates and returns a two element Object array with element zero containing the structure property and element one containing the state property of the SerializedView.

Parameters:
context - The FacesContext instance for the current request
viewId - View identifier of the view to be restored
Returns:
the tree structure and component state Object passed in to writeState. If this is an initial request, this method returns null.
Since:
1.2

public Object getTreeStructureToRestore(FacesContext context, String viewId)

实现必须检查当前的请求并返回以前调用 writeState() 时传入的树结构 Object。

deprecated 此方法由 #getState 取代。默认实现返回 null
context 当前请求的 FacesContext 实例
viewId 要恢复的视图的视图标识符
英文文档:

getTreeStructureToRestore

public Object getTreeStructureToRestore(FacesContext context,
                                        String viewId)
Deprecated. This method has been replaced by getState(javax.faces.context.FacesContext, java.lang.String). The default implementation returns null.

The implementation must inspect the current request and return the tree structure Object passed to it on a previous invocation of writeState().

Parameters:
context - The FacesContext instance for the current request
viewId - View identifier of the view to be restored

public Object getComponentStateToRestore(FacesContext context)

实现必须检查当前的请求并返回以前调用 writeState() 时传入的组件状态 Object。

deprecated 此方法由 #getState 取代。默认实现返回 null
context 当前请求的 FacesContext 实例
英文文档:

getComponentStateToRestore

public Object getComponentStateToRestore(FacesContext context)
Deprecated. This method has been replaced by getState(javax.faces.context.FacesContext, java.lang.String). The default implementation returns null.

The implementation must inspect the current request and return the component state Object passed to it on a previous invocation of writeState().

Parameters:
context - The FacesContext instance for the current request

public boolean isPostback(FacesContext context)

如果当前请求为 postback,则返回 true。在还原视图 阶段利用此方法确定应该调用 javax.faces.application.ViewHandler#restoreView 还是 javax.faces.application.ViewHandler#createView。如果此 ResponseStateManager 实例写出以前此请求为 postback 时的请求的状态,则默认实现必须返回 true;否则返回 false

在标准 HTML RenderKit 中,此方法的实现必须参考 javax.faces.context.ExternalContextrequestParameterMap,当且仅当有一个键等于符号常量 #VIEW_STATE_PARAM 的值时返回 true

为了向后兼容 JSF 1.2 以前的 ResponseStateManager 实现,提供了一个默认实现,该实现参考 javax.faces.context.ExternalContextrequestParameterMap,并且当其大小大于 0 时返回 true

since1.2
英文文档:

isPostback

public boolean isPostback(FacesContext context)

Return true if the current request is a postback. This method is leveraged from the Restore View Phase to determine if ViewHandler.restoreView(javax.faces.context.FacesContext, java.lang.String) or ViewHandler.createView(javax.faces.context.FacesContext, java.lang.String) should be called. The default implementation must return true if this ResponseStateManager instance wrote out state on a previous request to which this request is a postback, false otherwise.

The implementation if this method for the Standard HTML RenderKit must consult the ExternalContext's requestParameterMap and return true if and only if there is a key equal to the value of the symbolic constant VIEW_STATE_PARAM.

For backwards compatability with implementations of ResponseStateManager prior to JSF 1.2, a default implementation is provided that consults the ExternalContext's requestParameterMap and return true if its size is greater than 0.

Since:
1.2


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!