Populate <html:text> field from a <bean:write> tag

komidore64 picture komidore64 · Jun 17, 2010 · Viewed 17.3k times · Source

I want to populate a field from a session bean.

I attempted this:

`<html:text
    property="docId"
    value="<bean:write name="queryResponseBean" property="queryResults" />" />`

but to no avail.

thanks.

Answer

Salman Paracha picture Salman Paracha · May 13, 2011

The "value" attribute of the struts html:text tag will either except a string or a RT Expr (scriplet), therefore a nested expression like the one used above won't work. Instead, the value of the "queryResults" property will have to be set to a bean and then inserted into the "value" attribute using scripting language.

It will look something like this

<bean:define id="textVal" name="queryResponseBean" property="queryResults"/>
<html:text property="docId" value="<%=textVal%>"/>