Sunday, 15 January 2012

jsf - Restoring request parameters after session expires -



jsf - Restoring request parameters after session expires -

i have page has setup below url my.page.com/table.xhtml?id=123:

class="lang-none prettyprint-override">+----------------------------------------------+ |meta info | |----------------------------------------------| | search fields submit btn | |----------------------------------------------| | | | | | big p:datatable | | rowexpansion | | | |----------------------------------------------| | pager | +----------------------------------------------+

id=123 request parameter controls content on result table. actions reload info table using ajax.

id loaded throught :

class="lang-xml prettyprint-override"><f:metadata> <o:viewparam name="id" value="#{datatable.id}" /> <f:viewaction action="#{datatable.initialize}" /> </f:metadata>

this works fine, until session expires. @ point, nil works. cannot info since no longer have access id in question , phone call dao classes fetching info not have this.

by "no longer have access id" mean :

class="lang-java prettyprint-override">facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().get("id")

returns null. also, int id backing bean (which loaded through o:viewparam in f:metadata suffers same fate.

i know there methods grab viewexpiredexception, not want. need page reload values using request parameter (in case id) without user knowing.

i (think i) need @viewscoped manage bean command complex table , parameters, etc.

i @ lost regards this. have tried building own viewhandler seek rebuild (mimic refresh) of page, , tried utilize primefaces ajaxexceptionhandler among other solutions. these error , display it. want have access request parameter my.page.com/table.xhtml?id=123 backing bean.

any help appreciated.

i running on:

tomcat 7 mojarra 2.2.6 omnifaces 1.8.1 primefaces 5.0

as bypassing expired view recreating it, add together <o:enablerestorableview> metadata:

<f:metadata> ... <o:enablerestorableview /> </f:metadata>

as retaining request parameter, either add together plain html hidden input field form:

<h:form> ... <input type="hidden" name="id" value="#{datatable.id}" /> </h:form>

or utilize <o:form> includeviewparams="true",includerequestparams="true" or userequesturi="true", depending on whether you'd submit jsf view id view params, or jsf view id entire request query string, or entire request uri (including query string):

<o:form includeviewparams="true"> ... </o:form>

as reinitializing bean's state on postback before going through phases of jsf lifecycle, you'd need replace <o:viewparam> manually grabbing , <f:viewaction> @postconstruct:

@postconstruct public void initialize() { id = faces.getrequestparameter("id"); // ... }

jsf tomcat jsf-2 jsf-2.2

No comments:

Post a Comment