[Tapestry5] 哥哥,姐姐,请帮忙。tapestry5 loop组件 循环输出html标签的问题

hongyuzhe 2008-01-28
这个是一个很实际的东西,就是我想 if 里面输出 <td> 然后在 if 外面输出 </td>

<t:loop source="genusCol" value="_genus">
      <t:if text="currentGenus">
          <td bgcolor="red">
  <t:parameter name="else">
<td bgcolor="blue">
  </t:parameter>
       </t:if>      
</td>
</t:loop>
出错了:
The element type "td" must be terminated by the matching end-tag "</td>".

这是第二个
<tr>
    <t:loop source="sortCol" value="_sort" index="tR">
       <t:if test="printTR">
           </tr><tr>
       </t:if>
       <td>字符串</td>
    </t:loop>
</tr>
出错了:
The element type "tr" must be terminated by the matching end-tag "</tr>".


我觉的有时候tapestry这种强制性检查结束标签给我带来很多麻烦请问怎么解决呢。

这里祝哥哥姐姐,春节快了,有时间帮我解决一下了。
tapestry 2008-01-29
第一个,你可以写在page类中,在get方法里判断,还有个笨办法可以试试
<t:loop source="genusCol" value="_genus">
<t:if test="currentGenus">
<td bgcolor="red">
<t:parameter name="else">
<td bgcolor="blue">
</t:parameter>
</t:if>

<t:if test="currentGenus">
</td>
<t:parameter name="else">
</td>
</t:parameter>
</t:if>
</t:loop>
第二个,不知道你怎么非要这么写,你试试这个
<tr>
<t:loop source="sortCol" value="_sort" index="tR">
<t:if test="printTR">
<t:outputraw value="&lt;/tr&gt;&lt;tr&gt;"/>
</t:if>
<td>字符串</td>
</t:loop>
</tr>

上边的都没有测试,只是个思路,你自己搞搞。
tapestry 2008-01-29
<t:outputraw value="</tr><tr>"/>里边的<>用转义字符
hongyuzhe 2008-01-30
好了,是可以的,谢谢了。
LoneySky 2010-01-22
我的怎么报错呢?
Exception assembling root component of page enterprise/buy/StepOne: Could not convert '</tr><tr>' into a component parameter binding: Error parsing property expression '</tr><tr>': Unable to parse input at character position 1.
fantify 2010-01-25
应该这么写:<t:outputraw value="literal:&lt;/tr&gt;&lt;tr&gt;"/>

默认是prop:绑定
Global site tag (gtag.js) - Google Analytics