Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620558
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:34:36+00:00 2026-05-22T02:34:36+00:00

I have a JSF page that accepts a viewparam and sets a variable which

  • 0

I have a JSF page that accepts a viewparam and sets a variable which looks up the respective entity from the database and load the bean with the found details as follows:

<f:metadata>
    <f:viewParam name="attractionId" value="#{attractionsBean.attractionId}" />
</f:metadata>

I have a google map using the primefaces API and when a marker is dragged, an ajax call is issued to update the 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 is that after every marker drag event and ajax call, the method setAttractionId from the metadata is called every time.

What can be a solution for this problem to prevent calling the setAttractionId method everytime?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:34:37+00:00Added an answer on May 22, 2026 at 2:34 am

    The solution for this problem is as follows after a lot of hours trying to find a workaround:

    1. Make the ManagedBean as @ViewScoped in order to be the same bean while still on the same page

    2. Instead of retrieving the entity from the database in the setter of the attractionId, I introduced a @PostConstruct method in the view scoped bean to retrieve the object by the view parameter using the code as follows:

      @PostConstruct
      public void setupAttractionModel() {
          this.attractionId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(ATTRACTION_ID_VIEW_PARAM);
          // Lookup by attractionId ...
      }
      

      The postconstruct method is called before every page that requires the bean.

    3. Remove the <f:metadata> tag which is causing the trouble

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSF page that displays a RichFaces Treeview, from a TreeNodeImpl model
We have a rich:comboBox on a JSF page which has a valueChangeListener that calls
I have a JSF page that includes a tree form tag which is rendered
I have a page that lists all from my Post table, it looks like
I have a JSF page which is outputting XHTML (from a facelet). One of
I have a JSF page on which I want to have a checkbox that,
I have simple jsf page with view params and load method which is processing
I have a JSF page. At one point, I have a <h:selectManyCheckbox> that is
I have a jsf page that contains some javascript includes. And I want to
I have JSF page has two drop down lists and I want to load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.