I am learning JSF and when I send an object to a bean parameter the instance of the object is not correct.
I have a page that list a lot of movies, if I want to see the complete information about a movie, I click on a link that send me to a page with this code:
<h:form>
<h:commandLink action="#{sharedMovie.share(movie)}" value="Share">
<div class="movieDetail">
<div class="movieDetailTitle">"#{movie.title}"</div>
<div class="movieDetailYear">"#{movie.year}"</div>
<div class="movieDetailSynopsis">"#{movie.synopsis}"</div>
</div>
</h:form>
The movie bean have a request scope.
The problem is that when I click on "Share" my class sharedMovie
receives a new instance of Movie
, instead of the displayed movie in the page. All the displayed data is correct, only when I call the other page that this problem happens.
I already tried sending just the movie ID (but it is always 0), using f:setPropertyActionListener
, f:param
, but nothing works. If I debug my project, when I click on share link it always hit the breakpoint inside the constructor of Movie class.
How I can pass this instance correctly?