即时写表
我有以下功能,我想写入页面而不是 println。我怎样才能做到这一点?我的页面中需要一个包含该信息的表格,但我没有找到任何相关信息,我看到了如何将集合写入页面,但我更喜欢动态写入页面。
预先感谢您的回复。
def tablaAmortizacion(xhtml:NodeSeq,monto:Double,amort:Double,start:java.util.Calendar) {
var formatter = new java.text.SimpleDateFormat("dd/MM/yyyy")
var end = new java.util.GregorianCalendar()
end.setTime(start.getTime)
end.add(java.util.Calendar.MONTH,1)
var difference = Math.abs(start.getTimeInMillis - end.getTimeInMillis)
var days = difference / (1000 * 60 * 60 * 24)
println("Monto sal: " + monto + " Amortizacion: " + amort + " Start: " + formatter.format(start.getTime) + " End: " + formatter.format(end.getTime) + " Days: " + days)
if (monto > amort) {
tablaAmortizacion(xhtml,monto-amort,amort,end)
}
}
费尔南多·阿瓦洛斯.
I have the following function, and I would like to write to the page instead of the println. How can I do that? I need a table with that information in my page, But I did't find any information about that, I saw how to write collections to the page, but I would rather prefer write to the page on the fly.
Thanks in advance and I hope for your response.
def tablaAmortizacion(xhtml:NodeSeq,monto:Double,amort:Double,start:java.util.Calendar) {
var formatter = new java.text.SimpleDateFormat("dd/MM/yyyy")
var end = new java.util.GregorianCalendar()
end.setTime(start.getTime)
end.add(java.util.Calendar.MONTH,1)
var difference = Math.abs(start.getTimeInMillis - end.getTimeInMillis)
var days = difference / (1000 * 60 * 60 * 24)
println("Monto sal: " + monto + " Amortizacion: " + amort + " Start: " + formatter.format(start.getTime) + " End: " + formatter.format(end.getTime) + " Days: " + days)
if (monto > amort) {
tablaAmortizacion(xhtml,monto-amort,amort,end)
}
}
Fernando Avalos.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或者您可以执行类似的操作,在方法中生成表。
Or you can do something like this where you generate the table in the method.
我不确定你的意思是写入页面。您的意思是要在渲染后将表格动态添加到页面吗?
如果您指的是 ajax 方式,您应该查看 comet 聊天应用程序。
或者你的意思是你想要某种像 jsp/jsf 页面那样的表达语言?
如果您的意思是 jsp/jsf 页面,那么答案是您不能,根据设计。如果您需要动态生成 html,请在代码片段中执行此操作,而不是在 xhtml 中。
答案如下:
在你的 xhtml 文件中,你可以有类似的内容:
然后你的代码片段看起来像:
}
I'm not sure what you mean write to the page. Do you mean you want to dynamically add your table to the page after it's rendered?
If you mean in an ajax kind of way, you should look at the comet chat app.
Or do you mean you want some sort of expression language like jsp/jsf pages do?
If you mean like jsp/jsf pages, the answer is you can't, by design. If you need to dynamically generate html, you do that in your snippet, not in the xhtml.
here's the answer:
In your xhtml file you can have something like:
Then your snippet looks like:
}