java - render whole Wicket Header in Body -


I am rendering my wicket page (version 6.x) in a PortletContainer - which Actually works fine (with some restrictions)

One of these is that I can not use any Ajax because there is no html in my html markup and head is tag, it is only the content Body tag What am I doing rendering

I tried to use a headerresponsecontainer which works - As long as there is a head tag in the markup when there is no iHeaderResponseDecorator will not be set in RequestCycle .

I'm not sure whether the best way to render everything will be to do something in the body in head Tag in the tag, even if there are no head tags.

It looks like a hack but it works. If any cleaner can come up with the solution, then post it here.

Otherwise it can help in similar cases:

In your application class:

  @Override protected WebResponse newWebResponse (WebRequest webRequest, HttpServletResponse httpServletResponse) {New MyWebResponse ((ServletWebRequest) webRequest, httpServletResponse) Return; }  

Implementation of MyWebResponse:

  Public class MyWebResponse extends ServletWebResponse {static pattern bodyContentPattern = Pattern.compile ("& lt; body [^ & gt; ] * & Gt; (?. (S) *) & lt; / body & gt; "); Static pattern headContentPattern = Pattern.compile ("& lt; head [^> gt;] *> ((? S). *) & Lt; / head & gt;"); Public MyWebResponse (ServletWebRequest webRequest, HttpServletResponse httpServletResponse) {super (webRequest, httpServletResponse); } @ Override Public Wide List (square endorsed sequence) {string string = sequence.stressing (); // If there is an HTML tag, please take a div tag header material in body material and write it in the output stream (string.contains ("")) {StringBuilder sb = New stringbiller (); Sb.append (findContent (string, bodyContentPattern)); String headContent = findContent (string, head content split); If (headContent! = Null & amp; headContent.length ()> 0) {sb.append ("& lt; div class = \" head \ "& gt;"); Sb.append (headContent); Sb.append ("& lt; / div & gt;"); } Super.written (sb.toString ()); } Other {super. Written (sequence); }} Private string search content (string sequence, pattern p) {matures m = p. Matcher (sequence); If (m.find ()) {return m.group (1); } Return sequence; }}  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -