komidore64
komidore64

Reputation: 55

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

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.

Upvotes: 1

Views: 17890

Answers (4)

Salman Paracha
Salman Paracha

Reputation: 1703

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%>"/>

Upvotes: 3

Manish
Manish

Reputation: 11

You can assign a value directly, don't use the value='' attribute:

html:text property="docId" property="queryResults" />

where docId must be a BeanClass and the property (queryResults) must be a field inside the BeanClass.

Upvotes: 1

user754106
user754106

Reputation: 11

A RT Expr is only allowed in the value attribute of the struts html:text tag, so avoid using nested expressions or JSP expression language.

Upvotes: 1

Rakesh Goyal
Rakesh Goyal

Reputation: 3231

Try Using

<html:text 
    property="docId" 
    value="<bean:write name='${queryResponseBean}' property='queryResults' />" />

Upvotes: 0

Related Questions