Search code examples
htmljspstrutsjsp-tagsjavabeans

Enter bean value into hidden input in Struts (1.x) with different name than bean


So I have a generic form bean I am using that has a few values such as action, offer, code.

I am developing a new form that uses this generic form (required) but I want to use the value of a bean that has a name different from the bean I get values from to populate the form page.

On the first load of the page it displays some basic data:

Action: (hidden input, name the same as the bean)
<html:hidden property="action"/>

Offer: (user input, name the same as the bean)
<html:text property="offer"/>

Code: (hidden input, name not the same as the bean)
<html:hidden property="code"/>

The bean I was to use is something like:

<bean:write name="data" property="data.code.description"/>

How do I get that value (data.code.desription) into the "hidden" code area so that when the form is submitted the generic form bean picks up the value?


Solution

  • You could try like this:

    <input type="hidden" name="code" value="<bean:write name="data" property="data.code.description"/>" />