从检票口组件获取HTML输出数据 [英] Get the HTML output data from a wicket component

查看:65
本文介绍了从检票口组件获取HTML输出数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在编写一个网络小部件,我想用服务器上 wicket组件生成的一些HTML数据填充此小部件的内容.

I'm currently writing a web widget, and I would like to fill the content of this widget with some HTML data generated by a wicket component on my server.

为此,服务器将通过JSONP输出HTML数据.到目前为止一切顺利.

To do that, the server will output the HTML data via JSONP. So far so good.

但是我需要获取此HTML数据. 我如何在服务器上获取 某些检票口组件的HTML输出?

However I need to get this HTML data. How can I get on the server the HTML output from some wicket component?

推荐答案

我不知道是否可以将其应用于您的配置,但是我使用的是代码行来检索我之前编写的用于构建的渲染的html.基于html的电子邮件,以便能够在其中使用检票口组件

I dont know if this can be applied to your configuration, but I am using a view lines of code to retrieve rendered html which I wrote some time ago for building html based emails to be able to use wicket components in it

protected final String renderPage(Component page)  {
        final Response oldResponse = RequestCycle.get().getResponse();
        BufferedWebResponse tempResponse = new BufferedWebResponse((WebResponse) RequestCycle.get().getOriginalResponse());

        try {
            RequestCycle.get().setResponse(tempResponse);
            page.render();
        }
        finally {
            RequestCycle.get().setResponse(oldResponse);
        }

        return tempResponse.toString();
    }

由于此呈现是在实际的Web应用程序周期内进行的,但与实际的请求周期无关,因此建议保留原始的请求周期.该页面将在您的临时网络响应中呈现,您可以从中检索呈现的html输出.

As this rendering is made within an actual webapplication cycle but independently from the actual requestcycle, it is recommended to preserve the original requestcycle. The page will be rendered in your temporary webresponse from which you can retrieve the rendered html output.

希望这可能是您想要的

这篇关于从检票口组件获取HTML输出数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆