Reply To: Rewrite filter called twice, firing f:viewAction twice

Splash Forums Rewrite Users Rewrite filter called twice, firing f:viewAction twice Reply To: Rewrite filter called twice, firing f:viewAction twice

#26323

dobe
Participant

Thanks for your reply. I went ahead with your suggestion to create a sample app, but couldn’t reproduce the error, even though I was using all the same app and server configurations, package dependencies, etc.

I found out what actually caused the error. The problem was not caused by Rewrite itself, but how I handle navigation in my code. The problem was that in my navigation handling code, from the view parameters, I would load the appropriate data from the database. For example, index.xhtml?user=1, in my navigation handler would get a parameter user, with value 1.

Now to the error, on index.xhtml I have the following component:

<p:graphicImage url=”#{selection.pictureURL}”/>

When selection.pictureURL is empty or null, it will generate this html: , not sure why it puts ?pfrid_c in there, but it does. Before using Rewrite, this would make a get request for index.xhtml?pfrid_c, in my navigation handler, pfrid_c would not be recognised as a valid navigation rule and so just exit. With using Rewrite and the rules I have configured it with, it would make this request: /user/pfrid_c and then in my navigation handler, it would recoginse user as a valid navigation rule and try to load data for user with id pfrid_c from the database, …

I should probably fix this in my navigation handler, but for the time being, this does the trick:

<p:graphicImage url=”#{selection.pictureURL}” rendered=”#{not empty selection.pictureURL}”/>

Thanks for your help in finding this bug!