开发者

How can data be passed into an <s:> tag within a Struts tag file via attributes?

开发者 https://www.devze.com 2023-01-03 21:42 出处:网络
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 thumbnail.tag, which calls thumb.tag twice:

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 thumbnail.tag, which calls thumb.tag twice:

<thumbnail:thumb label="75px Thumbnail" />
<thumbnail:thumb label="Wide Thumbnail" />

thumb.tag in turn has the following:

<s:if test="#attr.label == '75px Thumbnail开发者_StackOverflow'">
  <thumbnail:standardThumb />
</s:if>
<s:elseif test="#attr.label == 'Wide Thumbnail'">
  <thumbnail:wideThumb />
</s:elseif>

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

<thumbnail:standardThumb tst="standard" />

and to standardThumb.tag:

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

and this works as expected. I can't seem to find a way to get "standard" into

<s:if test="content.standardThumbUrl != null">

in the same file. I've tried every combination of % and $ and # and {} that I can think of, but nothing has worked. Is there some proper syntax that will help me achieve the effect I'm looking for?

0

精彩评论

暂无评论...
验证码 换一张
取 消