|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.faces.render Class ResponseStateManager
java.lang.Object javax.faces.render.ResponseStateManager
public abstract class ResponseStateManager
- extends Object
ResponseStateManager 是 javax.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 |
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. |
static 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. |
Constructor Summary | |
---|---|
ResponseStateManager()
|
Method Summary | |
---|---|
Object |
getComponentStateToRestore(FacesContext context)
Deprecated. This method has been replaced by getState(javax.faces.context.FacesContext, java.lang.String) .
The default implementation returns null . |
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) . |
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 . |
boolean |
isPostback(FacesContext context)
Return true if the current request is a postback. |
void |
writeState(FacesContext context,
Object state)
|
void |
writeState(FacesContext context,
StateManager.SerializedView state)
Deprecated. This method has been replaced by writeState(javax.faces.context.FacesContext,java.lang.Object) .
The default implementation of this method does nothing. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 currentResponseWriter
, 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
- TheFacesContext
instance for the current requeststate
- 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 包含 SerializedView
的 state
属性。
since | 1.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 callsgetTreeStructureToRestore(javax.faces.context.FacesContext, java.lang.String)
andgetComponentStateToRestore(javax.faces.context.FacesContext)
and creates and returns a two elementObject
array with element zero containing thestructure
property and element one containing thestate
property of theSerializedView
.- Parameters:
context
- TheFacesContext
instance for the current requestviewId
- 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 returnsnull
. - 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 returnsnull
. The implementation must inspect the current request and return the tree structure Object passed to it on a previous invocation of
writeState()
.- Parameters:
context
- TheFacesContext
instance for the current requestviewId
- 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 returnsnull
. The implementation must inspect the current request and return the component state Object passed to it on a previous invocation of
writeState()
.- Parameters:
context
- TheFacesContext
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.ExternalContext
的 requestParameterMap
,当且仅当有一个键等于符号常量 #VIEW_STATE_PARAM
的值时返回 true
。
为了向后兼容 JSF 1.2 以前的 ResponseStateManager
实现,提供了一个默认实现,该实现参考 javax.faces.context.ExternalContext
的 requestParameterMap
,并且当其大小大于 0 时返回 true
。
since | 1.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)
orViewHandler.createView(javax.faces.context.FacesContext, java.lang.String)
should be called. The default implementation must returntrue
if thisResponseStateManager
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
'srequestParameterMap
and returntrue
if and only if there is a key equal to the value of the symbolic constantVIEW_STATE_PARAM
.For backwards compatability with implementations of
ResponseStateManager
prior to JSF 1.2, a default implementation is provided that consults theExternalContext
'srequestParameterMap
and returntrue
if its size is greater than 0.- Since:
- 1.2
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!