My situation is as following:
        STATE_SAVING_METHOD is server.
        The jsp uses x:panelTabbedPane and contains three x:panelTab, one of 
three panelTabs contains a x:dataTable with a x:commandSortHeader and an 
attached x:dataScroller , we have used x:saveState to achieve state saving of 
this view.
        The problem is there is a "Export XML" button here to  export data in 
dataTable to user, When user click this button, data will be transferred to 
client and user will be asked to provide a path to store the data as a file, 
And after that, user will still be at this page. To achieve that, we get 
HttpServletResponse instance and write stream to it and set 
"Content-disposition" header ,call responseComplete, then return null in 
"Export XML" action.And I found I must add following code to save 
SerializedView to stateManager myself.If not, The next request will be 
recognized as a "not postback" request which is incorrect.

        StateManager stateManager = 
FacesContext.getCurrentInstance().getApplication().getStateManager();
        //save state in server
        stateManager.saveSerializedView(FacesContext.getCurrentInstance());

        The point is state of SerializedView will be removed if myfaces found 
the request is a postback request at Restore View phase, And the action of 
saveSerializedView is called when myfaces renders jsp file at Render Response 
phase which is skipped by responseComplete at our situation.

        My question is Am I doing the thing right? Is my solution the guys who 
designs JSF expected? Or any other solution more clean and comfortable?

        By the way, we are not allowed to use AJAX or any other javascript to 
achieve this.

 **********************************************
 Zhu Da Zhi
 Japan DDC Section
 Global Delivery China Center (GDCC)
 Hewlett-Packard co, Ltd.
 Tel: +86-411-8880-5034
 **********************************************

Reply via email to