Simon,
Here's where the problem arises. This is an ajax request being handled in a
phase listener. I'm waiting till after the the restoreView phase, but with
client-side, the request is 1) missing the state and 2) missing the
viewRoot.
So I can add the state information manually into the request, but I'm still
not getting my state back, perhaps because of 2)?
Any suggestions?
Thanks.
Matt
Simon Kitching-3 wrote:
>
> Matt Tyson wrote:
>> Hello,
>>
>> This works using server-side state saving:
>>
>> UIViewRoot viewRoot =
>> context.getApplication().getViewHandler().restoreView(context, viewId);
>>
>> And then I can get the component I'm interested in. The viewRoot has no
>> children if its client-side state saving. Do I need to manually restore
>> the
>> state? If so, how do I do that - I've got the value from the
>> "jsf_tree_64"
>> field, but how do you convert it to a State object to give to the
>> viewRoot.restoreState() method?
>
> By coincidence, I've been going through the relevant MyFaces code today
> for an unrelated reason.
>
> I would have thought the above code would work fine.
>
> Application.getViewHandler should return an instance of
> JspViewHandlerImpl. This will then delegate to JspStateHandlerImpl which
> will check whether client or server state is used:
>
> protected UIViewRoot restoreTreeStructure(FacesContext facesContext,
> String viewId,
> String renderKitId)
> {
> UIViewRoot uiViewRoot;
> if (isSavingStateInClient(facesContext))
> {
> //reconstruct tree structure from request
> RenderKit rk = getRenderKitFactory().getRenderKit(
> facesContext, renderKitId);
> ResponseStateManager responseStateManager =
> rk.getResponseStateManager();
> Object treeStructure =
> responseStateManager.getTreeStructureToRestore(
> facesContext, viewId);
> ....
> }
>
> ResponseStateManager should be an instance of HtmlResponseStateManager:
>
> public Object getTreeStructureToRestore(
> FacesContext facescontext, String viewId)
> {
> Map reqParamMap =
> facescontext.getExternalContext().
> getRequestParameterMap();
> Object param = reqParamMap.get(VIEWID_PARAM);
> if (param == null || !param.equals(viewId))
> {
> //no saved state or state of different viewId
> return null;
> }
>
> param = reqParamMap.get(TREE_PARAM);
> .....
>
>
> So the tree structure required should be fetched from request property
> VIEWID_PARAM or TREE_PARAM automatically when restoreView is called on a
> JspStateHandlerImpl.
>
> Regards,
>
> Simon
>
>
--
View this message in context:
http://www.nabble.com/resotring-state-tf2816777.html#a7863028
Sent from the MyFaces - Users mailing list archive at Nabble.com.