How to save JSF textbox contents after page refresh?
What is the easiest way to save text that use开发者_JAVA技巧rs type into the following JSF HTML textbox, so that the text stays in the textbox even after the page is refreshed (e.g. for when the user may navigate away from the page and then return, wishing to see what they had put into the textbox earlier)?
<s:decorate template="layout/display.xhtml">
<ui:define name="label">Name</ui:define>
<h:inputText id="name" value="#{countriesList.countries.id.name}"/>
</s:decorate>
Thanks in advance for your reply.
To give further explanation of the above code: I created a sample JBoss Seam Web Project, reverse-engineering code from an Oracle 10g database that had a table called "Countries" in it. The only problem that I have now is the fact that, whenever users leave the records list page to view or edit records, they lose all of their search criteria in the page that lists results.
Surely there is a simple setting in the web project that I can change to make this happen? Or am I being too optimistic?
Bind the value of the inputText to a component with session scope.
@Name("valueHolder")
@Scope(ScopeType.SESSION)
public class ValueHolder
{
private String value;
...set/get
}
And in the xhtml:
<h:inputText value="#{valueHOlder.value}"/>
精彩评论