我如何从 Wicket Page 对象判断它已更改?
这是我的场景。我正在测试 Wicket 应用程序,并将页面文本 wicktetTester.getServletResponse.getDocument
解析为 XML,以便使用 XPath 查找组件。这是相当昂贵的,所以我想保留 dom4j.Document 直到页面更改,然后重建它。
我知道当前页面 - wicketTester.getLastRenderedPage
但如果我提交表单并停留在同一页面上,则 Page
对象是同一个对象。我可以查询页面的哪些属性来知道它已被重新渲染并且我需要重建我的 DOM?
public Document getDocument() {
if (tester.getLastRenderedPage() != lastPageParsed && SOME_OTHER_TEST) {
cachedDocument = parse(tester.getServletResponse().getDocument();
lastPageParsed = tester.getLastRenderedPage();
}
return cachedDocument;
}
Here's my scenario. I'm testing a Wicket app, and I'm parsing the page text wicktetTester.getServletResponse.getDocument
as XML in order to find components with XPath. This is quite expensive, so I'd like to keep the dom4j.Document
until the page changes, then rebuild it.
I know the current page - wicketTester.getLastRenderedPage
but if I for example submit a form and stay on the same page, the Page
object is the same object. What property of the page can I query to know that it has been re-rendered and that I need to rebuild my DOM?
public Document getDocument() {
if (tester.getLastRenderedPage() != lastPageParsed && SOME_OTHER_TEST) {
cachedDocument = parse(tester.getServletResponse().getDocument();
lastPageParsed = tester.getLastRenderedPage();
}
return cachedDocument;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好看看 TagTester。我想它会比 XPath 更好地为您服务。
Better see TagTester. I guess it will serve you better than XPath.