使用 JSP 的条件列
我最近开始使用 DisplayTag 库,但遇到了问题。
我正在尝试创建一个列,如果其他页面实际上有要显示的内容,则允许用户链接到另一个页面。我已经设置了它,以便那里总是有一个超链接,但我在条件条件方面遇到了麻烦。我有一个变量设置,它要么是空的,要么是其他的(通常是成功的)。这是我到目前为止所尝试过的...
<display:table uid="log" pagesize="20" defaultsort="2" name="logs" class="displayTag" sort="list" requestURI="savedReports.action" >
<display:column property="reportName" titleKey="label.report" <%if(!((ReportLog)pageContext.getAttribute("log")).getStatus().equals("empty")){ %>href="pdfReportViewer.action" paramId="reportLogId" paramProperty="id" <%} %> sortable="true" headerClass="sortable"></display:column>
此方法尝试在 display:column 标记中间使用 jsp,但最终出现未终止的 display:column 标记错误。
接下来我尝试了这个...
<display:table uid="log" pagesize="20" defaultsort="2" name="logs" class="displayTag" sort="list" requestURI="savedReports.action" >
<%if(((ReportLog)pageContext.getAttribute("log")).getStatus().equals("empty")){ %>
<display:column property="reportName" titleKey="label.report" sortable="true" headerClass="sortable"/>
<%}else{ %>
<display:column property="reportName" titleKey="label.report" href="pdfReportViewer.action" paramId="reportLogId" paramProperty="id" sortable="true" headerClass="sortable"/>
<%}%>
这没有引发任何错误,但每一行都默认为超链接列。我测试了一下这是否是我的条件中的错误,但可惜事实并非如此,创建一个虚拟列并显示条件的结果,我得到了一系列可爱的真值和假值。
我不知道为什么第二种方法不起作用,所以我希望这里有人对显示标签有更好的经验!
谢谢!
I recently started using the DisplayTag library and I've run into a problem.
I'm trying to create a column that will allow the user to link to another page if that other page will actually have something to display. I have it setup so that there's always a hyperlink there but I'm having trouble with the conditional. I have a variable setup that will either be empty or something else (usually success). This is what I have tried so far...
<display:table uid="log" pagesize="20" defaultsort="2" name="logs" class="displayTag" sort="list" requestURI="savedReports.action" >
<display:column property="reportName" titleKey="label.report" <%if(!((ReportLog)pageContext.getAttribute("log")).getStatus().equals("empty")){ %>href="pdfReportViewer.action" paramId="reportLogId" paramProperty="id" <%} %> sortable="true" headerClass="sortable"></display:column>
This method tries to use jsp in the middle of the display:column tag, and I end up getting an unterminated display:column tag error.
Next I tried this...
<display:table uid="log" pagesize="20" defaultsort="2" name="logs" class="displayTag" sort="list" requestURI="savedReports.action" >
<%if(((ReportLog)pageContext.getAttribute("log")).getStatus().equals("empty")){ %>
<display:column property="reportName" titleKey="label.report" sortable="true" headerClass="sortable"/>
<%}else{ %>
<display:column property="reportName" titleKey="label.report" href="pdfReportViewer.action" paramId="reportLogId" paramProperty="id" sortable="true" headerClass="sortable"/>
<%}%>
This didn't throw any errors, but every line defaulted to the hyperlink column. I tested to see if this was an error in my conditional, but alas it was not, creating a dummy column and displaying the result of the conditional, and I get a lovely assortment of trues and falses.
I'm at a loss as to why the second method doesn't work so I'm hoping someone here has some better experience with displaytags!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从我的头顶来看,有点丑:
A bit ugly, from the top of my head:
我最终用一些jsp来完成它......下面的代码......
I ended up doing it with a little jsp... code below...