jsf - commandLink inside datatable redirect to servlet only work for first time click -
i'm using primeface 4.0. there datatable list documents of login user. when user click on 1 row of datatable, open new page , display pdf content of document. works 1st click, after 1st click on same original page (which list documents) clicking on element open new window navigate home page. datatable looks this:
<p:datatable id="tablelicenseedocuments" value="#{pc_licenseedocumentsbean.documentlist}" var="document"> <p:column sortby="documentname" headertext="#{bundle['header.name']}" > <h:commandlink value="#{document.documentname}" action="#{documentsbean.viewfile(document)}" ajax="false" target="_blank"/> </p:column> </p:datatable>
the documentbean in session scope, action viewfile looks this:
public void viewfile(documentdto document) { facescontext facecontext = facescontext.getcurrentinstance(); externalcontext extcontext = facecontext.getexternalcontext(); portletrequest portletrequest = (portletrequest) extcontext.getrequest(); portletsession psession = portletrequest.getportletsession(true); psession.setattribute("document", document , portletsession.application_scope); string baseurl = extcontext.getrequestcontextpath(); string url = baseurl + "/displaypdfservlet"; seek { string encodeurl = extcontext.encoderedirecturl(url, null); extcontext.redirect(encodeurl); } grab (exception e) { // handle exception here ... } { facecontext.responsecomplete(); }
the page includes datatable loaded user click on side menu, commandlink, going bean load data, display, lifecycle of displaying page is: (please note after phase 5, there phase 1 resotre_view, why there resotre_view phase here, view restored?)
1.start phase restore_view(1)
2.end phase restore_view(1)
3.start phase apply_request_values(2)
4.end phase apply_request_values(2)
5.start phase process_validations(3)
6.end phase process_validations(3)
7.start phase update_model_values(4)
8.end phase update_model_values(4)
9.start phase invoke_application(5)
10.end phase invoke_application(5)
11.start phase restore_view(1)
12.end phase restore_view(1)
13.start phase render_response(6)
14.end phase render_response(6)
when user 1st time click on row of datatable, open new window , display content, life cycle following:
1.start phase restore_view(1)
2.end phase restore_view(1)
3.start phase apply_request_values(2)
4.end phase apply_request_values(2)
5.start phase process_validations(3)
6.end phase process_validations(3)
7.start phase update_model_values(4)
8.end phase update_model_values(4)
9.start phase invoke_application(5)
10.end phase invoke_application(5)
on same page has datatable, when user 2nd click on row, goes home page:
1.start phase restore_view(1)
2.end phase restore_view(1)
3.start phase render_response(6)
4.end phase render_response(6)
it's portlet, think problem jsf-related. i've been struggle on couple days, advice much appreciated!
jsf primefaces
No comments:
Post a Comment