我有FindMyBids.java
和FindMyBids.tml
,但我收到了下一个错误:
引起: org.apache.tapestry5.internal.services.RenderQueueException:渲染 BeginRender中的队列错误[search / FindMyBids:if]:读取失败 组件搜索/ FindMyBids的参数'test':if: org.apache.tapestry5.ioc.internal.util.TapestryException [at classpath:es / udc / subasta / web / pages / search / FindMyBids.tml,第7行]
@AuthenticationPolicy(AuthenticationPolicyType.AUTHENTICATED_USERS)
public class FindMyBids {
private final static int BIDS_PER_PAGE = 10;
private int startIndex = 0;
private Bid bid;
private BidBlock bidBlock;
@Property
@SessionState(create = false)
private UserSession userSession;
@Inject
private BidService bidService;
@Inject
private Locale locale;
public Bid getBid() {
return bid;
}
public void setBid(Bid bid) {
this.bid = bid;
}
public List<Bid> getbids() {
// System.out.println("ENTRA " + bidBlock.getBids().size());
List<Bid> bids = bidBlock.getBids();
return bids;
}
public Format getNumberFormat() {
return NumberFormat.getInstance(locale);
}
public Format getDateFormat() {
return NumberFormat.getInstance(locale);
}
public Object[] getPreviousLinkContext() {
if (startIndex - BIDS_PER_PAGE >= 0) {
return new Object[] { startIndex - BIDS_PER_PAGE };
} else {
return null;
}
}
public Object[] getNextLinkContext() {
if (bidBlock.getExistMoreBids()) {
return new Object[] { startIndex + BIDS_PER_PAGE };
} else {
return null;
}
}
void onActivate(int startIndex) throws InstanceNotFoundException {
this.startIndex = startIndex;
bidBlock = bidService.findBidsByUserId(userSession.getUserProfileId(),
startIndex, BIDS_PER_PAGE);
}
Object[] onPassivate() {
return new Object[] { startIndex };
}
}
这是FindMyBids.tml
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter" t:type="Layout" t:title="title"
showTitleInBody="false">
<p class="text-center">${message:welcome}</p>
<t:if test="bids">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>${message:productName-label}</th>
<th>${message:bidAmount-label}</th>
<th>${message:winName-label}</th>
<th>${message:bidFecha-label}</th>
</tr>
</thead>
<tbody>
<tr t:type="Loop" t:source="bids" t:value="bid">
<td>
<a href="#" t:type="PageLink" t:page="search/productdetails"
t:context="bid.product.productId">
${bid.product.name}
</a>
</td>
<td><t:output value="bid.amount" format="NumberFormat"/></td>
<td> ${bid.currentWinnerProduct.loginName}</td>
<td><t:output value="bid.date" format="DateFormat"/></td>
</tr>
</tbody>
</table>
<!-- "Previous" and "Next" links. -->
<ul class="pager">
<t:if test="previousLinkContext">
<li><a href="#" t:type="PageLink" t:page="search/findmybids"
t:context="previousLinkContext">← ${message:link-previous}</a></li>
</t:if>
<li> </li>
<t:if test="nextLinkContext">
<li><a href="#" t:type="PageLink" t:page="search/findmybids"
t:context="nextLinkContext">${message:link-next} →</a></li>
</t:if>
</ul>
<p:else>
<h4 class="alert alert-danger text-center">${message:noBids}</h4>
</p:else>
</t:if>
</html>
答案 0 :(得分:0)
test
参数需要boolean
,您要从List
方法返回getBids()
。试试这个:
<t:unless test="bids?.empty">
...
</t:unless>
这与t:if
相反,使用bids?.empty
您实际上会调用bids == null || bids.isEmpty()