How to show the saved text in text field

211 views Asked by At

In my HTML page, there is a button new and a button modify, when I click the button new, a new page will show with an empty single line text field, the code of the text field is:

<input type="text" name="functionInfo.paramsText"/>

so I can input some text in the text field and save it into the database (the data will be put to Java and saved into a database), this is exactly what I want, but when I click modify to modify a text which has been stored in the database, the new page is shown with an empty text field, how can I get a text field with the stored text shown on it? So I can see what I have saved before.

1

There are 1 answers

0
Roman C On

If you use Struts tags then it's simply

<s:textfield name="functionInfo.paramsText"/>

The value will be set via evaluating OGNL expression in the name attribute. You only need to provide a bean functionInfo with property paramsText and getters for both.

If you put a bean to the action class, then using a getter it's accessible from the value stack via OGNL since the action bean is on top of the value stack.