jsf 2 - JSF calling viewparams for every AJAX request -


i have jsf page accepts viewparam , sets variable looks respective entity database , load bean found details follows:

<f:metadata>     <f:viewparam name="attractionid" value="#{attractionsbean.attractionid}" /> </f:metadata> 

i have google map using primefaces api , when marker dragged, ajax call issued update marker location.

<h:outputtext value="location" /> <f:view contenttype="text/html">     <p:gmap id="gmap" center="41.381542, 2.122893" zoom="10" type="hybrid" style="width:380px;height:350px"                         model="#{attractionsbean.attractionmodel.mapmodel}"                         markerdraglistener="#{attractionsbean.onmarkerdrag}"                         onmarkerdragupdate="growl" />                 </f:view> 

the problem after every marker drag event , ajax call, method setattractionid metadata called every time.

what can solution problem prevent calling setattractionid method everytime?

the solution problem follows after lot of hours trying find workaround:

  1. make managedbean @viewscoped in order same bean while still on same page

  2. instead of retrieving entity database in setter of attractionid, introduced @postconstruct method in view scoped bean retrieve object view parameter using code follows:

    @postconstruct public void setupattractionmodel() {     this.attractionid = facescontext.getcurrentinstance().getexternalcontext().getrequestparametermap().get(attraction_id_view_param);     // lookup attractionid ... } 

    the postconstruct method called before every page requires bean.

  3. remove <f:metadata> tag causing trouble


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -