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?
Related
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.
This question already has answers here:
Clear JSF form input values after submitting
(5 answers)
Closed 5 years ago.
I'm developing a project using JSF and Primefaces and I got some forms.
Every time I open those forms all fields are already filled with the last information I saved on database.
I'd like every time I open those forms all fields were blank.
How can I do this?
Thank you!!
What Scope are you using in your managed bean? if you are using session scope for example it will hold the last values of your bean properties as long as the application session exists. Depending on what you doing, I would use request scope instead. This will delete the bean when it is not being use and therefore clear the values when you request again. Or perhaps view scope, this will keep the values as long as you are in the same view. Another way would be to use javascript to clear the values by Ids.
if u are using
#SessionScoped
Try to change to :
#ViewScoped
This question already has an answer here:
How to decrease request payload of p:ajax during e.g. p:dataTable pagination
(1 answer)
Closed 6 years ago.
I am facing such a problem. I want to refresh one internal element of a h:form, a p:dataList, and in order to do it I have
<p:remoteCommand name="updateSet" update="import-statuses-admin-list" process="import-statuses-admin-list"/>
Function updateSet is called in every 5 seconds. The thing is that, there are some other elements in my form and they are also sent, eg.
<h:selectOneMenu value="#{importXmlManagementBean.statusFilter}" id="statusFilter">
I'd rather have only this list p:dataList submitted, without sending all form.
Is it normal behaviour or I am missing something?
Add to remoteCommand the attribute update with the id of the datalist you want to update, and in the process specify the same.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to choose the right bean scope?
I'm newbie in JSF programming, and I need a clarification about bean scopes. I have already read all the questions about this argument, but is not so clear.
I don't understand the request scope well. I understand that: "This is the default scope and basically the bean is alive throughout a single HTTP request."
So for example, suppose that we ask the browser to open a web page with a form. When we make the request, a request scope bean is created, the life-cycle begins and after the render response phase, the Java bean is destroyed.
Then we fill out the form and we press a button. This will start another HTTP request, right?
In the same context, if a have a view scope bean instead of a request scope bean, what is the difference? How many bean instances are created? Why is it better to use this with a datatable?
The request scope as all your sources including the post linked by BalusC say starts living a short while after your request hits the server, and is destroyed shortly after the last bit of the response has been send back.
Indeed, if you postback a form a new request starts and thus a new request scope. This means everything that is request scoped will be created again. So for a form that is first rendered, and then posted back once, 2 request scoped beans will be created.
The view scope lives as long as you do postbacks to the same view (page). This works by means of the hidden form parameter called javax.faces.ViewState. The value of this is an entry into some kind of logical Map if you use save state on server. How a JSF implementation actually resolves this is not that important here (but yes, it's mostly just a Map).
After the postback JSF is able to retrieve the exact same view scoped beans again by means of this parameter. So for a form that is first rendered, and then posted back once, 1 view scoped bean will be created.
For a datatable you will almost always want to use the view scope. The reason is that you want the data to be the same before and after a postback. If your data is 100% static and/or you don't have postbacks (your table is not in a form), you can use the request scope instead.
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.