confirm form resubmission problem in primefaces 8 [duplicate] - jsf

This question already has answers here:
Pure Java/JSF implementation for double submit prevention
(3 answers)
How to avoid re-execution of last form submit action when the page is refreshed?
(1 answer)
Closed 1 year ago.
Hello I have a form in my webpage. I search and data comes to my table. if I click to a row, redirect to another webpage. if I want to return back browser ask to me :
Confirm Form Resubmission
This webpage requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed.
Press the reload button to resubmit the data needed to load the page.
ERR_CACHE_MISS
I use primefaces 8, javascript:history.back()(for back to previous page).
If I open the developer tools(F12) problem is disappering interestingly.

Related

how to Disable click on btn after first or do not send action [duplicate]

This question already has answers here:
Pure Java/JSF implementation for double submit prevention
(3 answers)
How to do double-click prevention in JSF
(9 answers)
Closed 2 months ago.
I have tried different solutions but what I want to achivie is:
When you press the button (a tag / h:commandlink ) I want to disable the button or do no action at the second click because the first one is loading. Right now I have a issue that you can double click on the button and it can give me error.
I have this code:
<h:commandLink id="btn" styleClass="link"
onclick="test()"
action="#{use.enterAgentMode(user, myBean.guardEnum)}">
</h:commandLink>
for example is it possible to create a variable and set it to true/false and set condition inside of action=... if true do the code else nothing
I also tried with JQuery and document.getElement to set attr.disabled true but did not work.
I saw it disabled with inspect but it was still clickable
I have tried different stuff, tried to add some debounce on the button..
any advices please

Capture the last rendered response and access in backing bean [duplicate]

This question already has answers here:
How to read and copy the HTTP servlet response output stream content for logging
(6 answers)
How to get current view HTML source and pass it JSF ManagedBean as String
(1 answer)
Closed 2 years ago.
I have a multi-step signup wizard whereby the users progress is tracked as they progress through each step in the wizard and saved to the database on every AJAX request (the entire signup process consists of about 10-20 AJAX updates and finishes with a POST)
If a user does not complete the signup process we would like to see the rendered view at the point at which they left, this would require us to capture and overwrite the rendered response after each request, when the users signup state is saved we could then store their last response as a string.
I am just trying to figure out the best way to achieve this, using a PhaseListener at RenderResponse stage or would we need a Filter to capture the raw output? Presumably we could then store output in the Page/Conversation scope so it survives the next request?

Why does selecting the browser Refresh button not replace edited fields in my JSF form with values from server? [duplicate]

This question already has answers here:
javax.faces.application.ViewExpiredException: View could not be restored
(11 answers)
Closed 4 years ago.
During normal operation, everything works well on my Java EE note taking application running on GlassFish 4.1.2 with STATE_SAVING_METHOD set to server. I can open the ViewScoped Note.xhtml client in my Firefox browser; type text in the CKEditor field; select the [Create] button to save the note to the Derby database; edit the text and finally select the [Update] button to update the note information in the database.
The only issue that I have is when I edit my note and don't select create or update before the view expires. When this happens, the server reports a ViewExpiredException, and I see my default PrimeFaces error page.
Luckily, I discovered that I can perform the following steps to save the edited data.
Select the browser back button.
Select the browser refresh button.
Select create or update buttons on the client.
When I select the browser back button, I see the previously edited page. I believe this is because the browser cached the page locally and is displaying the cached version of the previous page. The browser does not appear to communicate with the server when I select the back button.
If I select the create or update button immediately after selecting the back button, I see the ViewExpiredException again.
However, if I select the back button and then the refresh button, I can save or update my edited note.
I believe that selecting the refresh button creates a new view for the page but what I don't understand is why I don't lose my edits. When I select the refresh button, the server reports it creates a new backing bean and goes to the server to get the data for note. I would have expected the server to send this information back to the client and overwrite the edited values but it doesn't. After the refresh, a new view is created (I think?) but the client still has the edited values. When I select the update button the edited values are saved in the database.
I'm very glad that it works this way, because, if it didn't, I would lose my edits every time the view expired.
My question is why does it work this way. What I am missing about the JSF lifecyle that allows the browser to create a new view using a form containing edited data?
I read javax.faces.application.ViewExpiredException: View could not be restored before posting this question. This question builds on that question by specifically looking at what happened to edited data in a form when the page is refreshed when the view is expired which was not addressed in the original question.
To get rid of the set values when the user refreshes the page, set textbox/textarea autocomplete to off or create a function that will check whether the variables are null or not during the prerenderview event or in the constructor. If they aren't null, make them null.

Forcing a save as dialogue from any web browser from JSF application [duplicate]

This question already has answers here:
Forcing a save as dialogue from any web browser from JSF application [duplicate]
(3 answers)
Closed 9 years ago.
I have a modal that will be shown and then I have an export button which should bring up the save dialog, if I have use h:commandButton, the validation checks are bypassed , but works well. If I use a4j:commandButton, validations are done perfectly but I dont see the save file dialog.
Can somebody help me.
thanks
I don't do RichFaces, so I can't tell from top of head, but Google learns me that a4j:htmlCommandLink may help. If it does and you'd rather like to have a button, then just throw some CSS in to make the link look like a button.

JSF Back Button [duplicate]

This question already has answers here:
back commandbutton in jsf
(5 answers)
Closed 8 years ago.
How do I make a link which navigates the user back one page (i.e. same as clicking browser back)?
Thanks.
To the point: just remember the request URL or the JSF viewId of the previous page so that you can use it in the href or value of the output/commandlink. There are several ways to achieve it, depending on how you're actually navigating through the pages and how "jsfish" you want to achieve it. You could pass it as a request parameter by f:param in h:outputLink, or you could set it as a bean property by f:setPropertyActionListener in h:commandLink, or you could create a PhaseListener which remembers the viewId and make use of navigation cases, or you could grab the -much less reliable- JavaScript history.go() function.

Resources