org.zkoss.zkplus.liferay.JQueryRenderCachedPatch Maven / Gradle / Ivy
/* JQueryRenderPatch.java
Purpose:
Description:
History:
Sun Jan 17 11:48:04 TST 2010, Created by tomyeh
Copyright (C) 2010 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zkplus.liferay;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Used to patch the rendering result of a ZK portlet for Liferay.
* When using ZK portlets with Liferay under Internet Explorer, we have
* to delay the processing at the client a bit. This patch assume
* "/zkau/web/js/zk.wpd" has loaded by Liferay, please refer to
* www.liferay.com document for configuration
*
* To use it, you have to specify a library property called
* ""org.zkoss.zk.portlet.PageRenderPatch.class" with this class's name
* ("org.zkoss.zkplus.liferay.JQueryRenderCachedPatch").
*
* @author tomyeh, sam
* @since 5.0.1
*/
public class JQueryRenderCachedPatch extends JQueryRenderPatch {
private static final Logger log = LoggerFactory.getLogger(JQueryRenderCachedPatch.class);
protected String getBrowserDelay() {
return "zk.ie6_ || zk.ie7_ ? 1300 : 100";
}
/**
* Append CSS link to head, and remove zk.wpd script
*/
protected String[] processHtml(String html) {
boolean isAppendCSS = false;
StringBuffer script = new StringBuffer(
")");
StringBuffer buffer = new StringBuffer();
int parseStart = 0, scriptStart = 0, scriptEnd = 0;
for (scriptStart = html.indexOf("".length();
removeScript(html, scriptStart, scriptEnd, scriptPattern, script, buffer);
if ((scriptStart = html.indexOf("