-1

Ok, what I'm trying to do is come up with a way to apply certain application settings (CSS to be exact) but only within an iframed version of the app.

If you've used Wordpress, I'm basically trying to implement a version of the theme live preview where it opens a version of the application in an iframe with theme changes made only to that instance of the site. I think it (Wordpress) does this by using JavaScript to change all the links to AJAX POST requests with the chosen theme as part the parameters.

I was thinking I might be able to do something similar by adding a page parameter (themePreview or something similar), detect that and apply the temporary (session) style properties. I already have a custom CssResourceReference that does this albeit without the page parameter detection though that seems simple enough.

My main problem is, I want the user to be able to navigate around the site within the iframe. To do so, I would need to maintain, persist or somehow inject the themePreview page parameter into all page requests when it is already set.

Does anybody know how to accomplish this or alternatively, have a better idea?

4

1 回答 1

1

wicket 中的链接通过调用请求周期的 urlFor 方法来工作。这包括一个 URL 渲染器,所有 URL 在生成时都会通过该渲染器。

如果你:

  • 如果它是请求中的参数,则编写一个子类UrlRenderer以将您的参数添加到所有 urlthemePreview
  • 编写一个子类RequestCycle并覆盖newUrlRenderer()返回你的UrlRenderer.
  • 创建您自己的实现IRequestCycleProvider以提供您的自定义RequestCycle
  • 在您的应用程序类中,在init方法中,调用setRequestCycleProvider传递您的自定义IRequestCycleProvider.

这样,如果themePreview参数出现在请求中,它将自动添加到生成的任何 URL 中,因此将出现在 iframe 中的任何链接上。

于 2013-12-29T21:35:53.913 回答