我还有一个大问题。我有组件,带区域和刷新区域的表单。当我将组件放入循环时,它只显示最后一个区域。我为每个区域生成了唯一 ID。在页面源代码中,我可以看到每个区域都获得了正确的 ID,但在提交时它没有返回正确的 ID。反正有没有按ID返回区域?
这是我的代码:
<details>
<summary>Comments</summary><br />
<t:zone t:id="commentZone" id="prop:zoneId">
<t:commentlist materijalID="materijalID"></t:commentlist><br />
</t:zone>
<t:form t:id="komentar" t:context="materijalID" t:zone="prop:zoneId">
<t:textarea t:value="comment" rows="6" cols="40"></t:textarea><br />
<input type="submit" value="Add comment"/>
</t:form>
</details>
public class Comments
{
@Parameter(required=true)
@Property
private int materijalID;
@SessionState
@Property
private User user;
@Inject
private Session session;
@Property
private String comment;
@InjectComponent
private Zone commentZone;
@CommitAfter
public Object onSuccessFromKomentar(int materijalID)
{
Komentar k = new Komentar();
Date d = new Date();
Materijal m = (Materijal)session
.createCriteria(Materijal.class)
.add(Restrictions.eq("materijalID", materijalID))
.list()
.get(0);
k.setMaterijal(m);
k.setKorisnikID(this.user.getID());
k.setDatumUnosa(d);
k.setDatumModifikacije(d);
k.setKomentar(this.comment);
session.save(k);
this.comment = "";
return this.commentZone.getBody();
}
public String getZoneId()
{
return "Zone_" + this.materijalID;
}
}
提前致谢