简体   繁体   中英

How to retain previous entered data in h:inputText?

I'm using JSF 1,2 and I want the browser to retain previously entered values in h:inputText.

<h:inputText
id="testContact"
value="#{ObjectBeanHolder.testContact.targetAddress}"                           
onkeypress="if(event.keyCode==13) {setTimeout(function() {jQuery('input[id$=startTestButtonId]').click()}, 100);  return false;} "
styleClass="text-input testContact"  required="true"
label="#{fieldTitle}">

Is it possible? Or should I use another component to make a simple conservation, Thanks.

Browsers are keeping data for autocomplete on fields based on the website and input ID (when defined).

In the JSF case, form and input have automatically generated ID's when they are not defined. ID's can change at each application deployment, that is why it is not working in some case. To prevent this, one way is to define ID's to form and input that you want to activate autocomplete.

Note : The browser also need a submit to keep these values.

I found that a4j command buttons which I use have "return false;" statement in onclick event. So submit and autocomplete don't work on the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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