You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Koenig <sc...@gmail.com> on 2010/06/18 19:17:39 UTC

injecting attribute into textfield value

Hello,

I have a form with two halves, one for attaching a wide thumbnail to an
asset and one for a standard-size thumbnail. The jsp file generating the
page calls standardThumb.tag and wideThumb.tag:

<thumbnail:standardThumb />
<thumbnail:wideThumb />

The sole difference between the two tag files is the variable names within
them, e.g. stdThumbUrl and wideThumbUrl. I have been assigned to refactor
this into a single thumb.tag file and pass in the "std" or "wide" string. I
have found this works just fine with regular HTML tags. For example, if I
add the attribute "type":

<thumbnail:standardThumb type="std" />

and to standardThumb.tag:

<%@ attribute name="type" required="true"%>
...
<iframe id="${type}ThumbImage" ... >

and this works as expected. I can't seem to find a way to get "std" into the
value of an s:textfield, though it works fine for the name. I assume this
has something to do with value being an object and not a string.

<s:textfield name="%{#attr.type}ThumbURLText"
value="%{content.contentRepresentation.stdThumbUrl}" />

The above line of code is also in standardThumb.tag. The value of the
textfield checks the std_thumb_url field in the content_representation table
in our database. This works as shown above, but not if I try, for example,

... value="%{content.contentRepresentation.+#attr.type+ThumbUrl}"...

Can someone help me out here?

Thanks so much.

~~Scott