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:
make managedbean
@viewscoped
in order same bean while still on same pageinstead 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.
remove
<f:metadata>
tag causing trouble
Comments
Post a Comment