简体   繁体   English

如何在页面刷新后保存JSF文本框内容?

[英]How to save JSF textbox contents after page refresh?

What is the easiest way to save text that users type into the following JSF HTML textbox, so that the text stays in the textbox even after the page is refreshed (eg for when the user may navigate away from the page and then return, wishing to see what they had put into the textbox earlier)? 将用户键入的文本保存到以下JSF HTML文本框中的最简单方法是什么,以便即使在页面刷新后文本也保留在文本框中(例如,当用户可以离开页面然后返回时,希望看看他们之前在文本框中放了什么)?

       <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. 为了进一步解释上面的代码:我创建了一个JBoss Seam Web项目示例,从Oracle 10g数据库中反向工程代码,其中包含一个名为“Countries”的表。 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? 当然,在Web项目中有一个简单的设置,我可以改变它来实现这一目标吗? Or am I being too optimistic? 还是我太乐观了?

Bind the value of the inputText to a component with session scope. 将inputText的值绑定到具有会话范围的组件。

@Name("valueHolder")
@Scope(ScopeType.SESSION)
public class ValueHolder
{
    private String value;

    ...set/get

}

And in the xhtml: 在xhtml中:

<h:inputText value="#{valueHOlder.value}"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM