简体   繁体   中英

Struts2 textfield not retaining the value after submit

I am using Struts2 and using hidden fields to pass a value from one jsp containing textfield to other action.

Implementation steps in brief :-

  1. Action1 -->jsp --> one.jsp (has <textfield name="one"></textfield> ) on submit it goes to Action2
  2. Action 2 has jsp-->two.jsp (here the value of previous textfield is display as a plain text) here also i have put the hidden field to retain the value for further submission.
  3. Now, Action2 jsp has a back button that take the control back to the Action1. Can be considered as Action1 has next button and Action2 has back button to go back and forth.

Issue:- on click of back I am not able to see the value in the textfield that i first set..

Scenario.

  1. Action1-- textfield had value [200] one.jsp
  2. (Click Next button)--takes the control to Action2's two.jsp
  3. Action2-- plain text get the value and displays it as it [200] two.jsp
  4. (Click Back button)....takes the control to Action1's one.jsp.
  5. Expected result the value on the textfield should be retain. but its not.

However if I do a F12 on the browser (to see the value in the developer mode) <textfield> generates a tag of <input> type and that has value="200".. But it is not getting displayed on the actual screen.

Fixed it. Found the issue. It was related to JScript used in the jsp file. This occured because JS written on the jsp was erasing input field value when page was getting re-loaded or accessed.. Lesson learnt, at times JS could be the culprit. :)

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