Daantie
Daantie

Reputation: 1011

struts2 jsp dynamic request attributes

I'm wondering how to get a dynamic request attribute. I'll try to explain:

My action make a List of some dynamic fields from database for a form. This List is iterated by the following code in the jsp file:

<s:iterator value="category.categoryFields">
 <s:textfield name="%{name}" label="%{name}" value="" />
</s:iterator>

With this, all the needed fields are displayed on the page.

What i want now, is the request attribute wich is named the same name as the value of %{name} in the value of the textfield. I thought it was this:

<s:iterator value="category.categoryFields">
 <s:textfield name="%{name}" label="%{name}" value="%{#request.name}" />
</s:iterator>

But that doesn't work.

I don't know how to put the %{name} variable in the place of the .name.

Can anyone help me?

Upvotes: 1

Views: 3014

Answers (1)

Daantie
Daantie

Reputation: 1011

Needed to use

 <s:textfield name="%{name}" label="%{name}" value="%{#request[name]}" />

instead of

 <s:textfield name="%{name}" label="%{name}" value="%{#request.name}" />

Upvotes: 1

Related Questions