属性 对象没有改变值
property object is not changing value
我有以下 Page.tml 代码:
<span class="dropdown">
<t:pagelink page="tracker" data-toggle="dropdown" class="dropdown-toggle disabled" style="padding-top: 5px; padding-bottom: 5px;">
<span>
<b class="caret"></b>
<t:if test="!project"> All Tickets</t:if>
<t:if test="project"> Project</t:if>
</span>
</t:pagelink>
<ul class="dropdown-menu">
<li>
<t:pagelink page="tracker" data-toggle="dropdown" class="dropdown-toggle disabled">
<span>All Tickets</span>
</t:pagelink>
</li>
<t:loop source="projectList" value="project">
<li><t:pagelink page="tracker" context="${project.id}">${project.title}</t:pagelink></li>
</t:loop>
</ul>
</span>
<t:if test="project">
<span class="path-divider"> > </span>
<strong>
<t:pagelink page="tracker" context="project.id">
<span>${project.title}</span>
</t:pagelink>
</strong>
</t:if>
我的页面 java class:
@Property
@Inject
private ProjectDao projectDao;
@Property
private Project project;
@Property
private List<Project> projectList;
@Property
@Inject
private TicketDao ticketDao;
@Property
private List<Ticket> ticketList;
@PageLoaded
void onPageLoad() {
projectList = projectDao.loadAll();
ticketList = ticketDao.loadAll();
}
void onActivate(Integer contextValue) {
if (contextValue != null) {
project = projectDao.getByID(contextValue);
}
if (project != null) {
List ticketListByProjectID = ticketDao.getTicketsByProjectID(project.getId());
if (!ticketListByProjectID.isEmpty()) {
ticketList = ticketListByProjectID;
}
} else {
ticketList = ticketDao.loadAll();
}
}
当我从 contextValue 中 select 时,我无法将对象 project
更改为其他对象。它在 TML 中始终是同一个对象(它是循环中最后一个元素的值),但在 java 代码中,当我打印到控制台时它正在改变。我做错了什么?
您将项目 属性 用于 2 个不同的相互冲突的目的 -- 循环变量和所选项目。尝试为这两个目的使用不同的变量。
我有以下 Page.tml 代码:
<span class="dropdown">
<t:pagelink page="tracker" data-toggle="dropdown" class="dropdown-toggle disabled" style="padding-top: 5px; padding-bottom: 5px;">
<span>
<b class="caret"></b>
<t:if test="!project"> All Tickets</t:if>
<t:if test="project"> Project</t:if>
</span>
</t:pagelink>
<ul class="dropdown-menu">
<li>
<t:pagelink page="tracker" data-toggle="dropdown" class="dropdown-toggle disabled">
<span>All Tickets</span>
</t:pagelink>
</li>
<t:loop source="projectList" value="project">
<li><t:pagelink page="tracker" context="${project.id}">${project.title}</t:pagelink></li>
</t:loop>
</ul>
</span>
<t:if test="project">
<span class="path-divider"> > </span>
<strong>
<t:pagelink page="tracker" context="project.id">
<span>${project.title}</span>
</t:pagelink>
</strong>
</t:if>
我的页面 java class:
@Property
@Inject
private ProjectDao projectDao;
@Property
private Project project;
@Property
private List<Project> projectList;
@Property
@Inject
private TicketDao ticketDao;
@Property
private List<Ticket> ticketList;
@PageLoaded
void onPageLoad() {
projectList = projectDao.loadAll();
ticketList = ticketDao.loadAll();
}
void onActivate(Integer contextValue) {
if (contextValue != null) {
project = projectDao.getByID(contextValue);
}
if (project != null) {
List ticketListByProjectID = ticketDao.getTicketsByProjectID(project.getId());
if (!ticketListByProjectID.isEmpty()) {
ticketList = ticketListByProjectID;
}
} else {
ticketList = ticketDao.loadAll();
}
}
当我从 contextValue 中 select 时,我无法将对象 project
更改为其他对象。它在 TML 中始终是同一个对象(它是循环中最后一个元素的值),但在 java 代码中,当我打印到控制台时它正在改变。我做错了什么?
您将项目 属性 用于 2 个不同的相互冲突的目的 -- 循环变量和所选项目。尝试为这两个目的使用不同的变量。