Author: dolander Date: Thu Jan 27 14:20:35 2005 New Revision: 128432 URL: http://svn.apache.org/viewcvs?view=rev&rev=128432 Log: Refactor a bit more of the script code so that the tag code only talks with the ScriptRequestState and doesn't talk to the IScriptReporter.
Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java?view=diff&rev=128432&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java&r1=128431&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java&r2=128432 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java Thu Jan 27 14:20:35 2005 @@ -177,13 +177,7 @@ // Write the callback that's triggered when the popup window is closing. assert (_onPopupDone != null); // addParams() should ensure that this isn't null - String func = ScriptRequestState.getString("popupSupportOnPopupDone", new Object[]{_onPopupDone}); - if (scriptReporter != null) { - scriptReporter.addScriptFunction(null, func); - } - else { - ScriptRequestState.writeScriptBlock(req, results, func); - } + srs.writeFeature(scriptReporter,results, "popupSupportOnPopupDone", new Object[]{_onPopupDone}); } private void putFeature(String featureName, boolean val) Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java?view=diff&rev=128432&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java&r1=128431&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java&r2=128432 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java Thu Jan 27 14:20:35 2005 @@ -33,6 +33,8 @@ ALLOCATE_ID (0x0100), ALLOCATE_NAME (0x0200), LEGACY_SCOPE_LOOKUP (0x0400), + + // These features are not written out once. They are identified by setting the top bit SET_FOCUS (0x10000001); public int value; Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java?view=diff&rev=128432&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java&r1=128431&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java&r2=128432 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java Thu Jan 27 14:20:35 2005 @@ -449,7 +449,7 @@ if (TagConfig.isLegacyJavaScript()) { val = processIdMap(_idMap, "idMappingEntry", _idScope); if (val != null) { - jsu.writeIdMap(this, "idMappingTable", val); + writeIdMap(this, "idMappingTable", val); writeLegacy = true; } } @@ -461,7 +461,7 @@ idScope = null; val = processIdMap(_idToNameMap, "tagIdNameMappingEntry", idScope); if (val != null) { - jsu.writeIdMap(this, "tagIdNameMappingTable", val); + writeIdMap(this, "tagIdNameMappingTable", val); writeName = true; } } @@ -500,6 +500,23 @@ } /////////////////////////////////// Private Support //////////////////////////////////// + + /** + * @param scriptRepoter + * @param mapObj + * @param entries + * @return + */ + private String writeIdMap(IScriptReporter scriptRepoter, String mapObj, String entries) + { + String s = ScriptRequestState.getString(mapObj, new Object[]{entries}); + if (scriptRepoter != null) { + scriptRepoter.addScriptFunction(null, s); + return null; + } + return s; + } + private String getJavaScriptId() { Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java?view=diff&rev=128432&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java&r1=128431&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java&r2=128432 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptPlacement.java Thu Jan 27 14:20:35 2005 @@ -1,5 +1,5 @@ /* - * Copyright 2004 The Apache Software Foundation. + * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ /** * */ -public enum ScriptPlacement +public enum ScriptPlacement { PLACE_BEFORE, PLACE_AFTER, Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java?view=diff&rev=128432&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java&r1=128431&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java&r2=128432 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java Thu Jan 27 14:20:35 2005 @@ -46,6 +46,8 @@ private static ResourceBundle _bundle; // This points to the bundle private ServletRequest _req; + //*************************** PUBLIC STATIC METHODS ***************************************** + /** * This method will return the <code>javaScriptUtils</code> that is assocated * with this request. If this doesn't exist, it will be created before it is @@ -67,6 +69,26 @@ } /** + * Returns the string specified by aKey from the errors.properties bundle. + * @param aKey The key for the message pattern in the bundle. + * @param args The args to use in the message format. + */ + public static String getString(String aKey, Object[] args) + { + assert (aKey != null); + + String pattern = getBundle().getString(aKey); + if (args == null) + return pattern; + + MessageFormat format = new MessageFormat(pattern); + String result = format.format(args).toString(); + return result; + } + + ////************************** MEMBER FUNCTIONS ************************************** + + /** * A ScriptRequestState is obtained through the factory method ScriptRequestState.getScriptRequestState() * The constructor is private so that these cannot be created outside of the factory. */ @@ -74,12 +96,22 @@ } /** - * The ScriptRequestState is stored in a request. This is a back pointer to that request. - * When this is created it the pointer will be stored. - * @param req the Outer Request that this object is stored in + * @param scriptReporter + * @param results + * @param featureKey + * @param args */ - private void setRequest(ServletRequest req) { - _req = req; + public void writeFeature(IScriptReporter scriptReporter, AbstractRenderAppender results, + String featureKey, Object[] args) + { + String s = getString(featureKey, args); + + if (scriptReporter != null) { + scriptReporter.addScriptFunction(null, s); + } + else { + writeScriptBlock(_req, results, s); + } } /** @@ -114,7 +146,6 @@ } /** - * * @param scriptReporter * @param tagId * @param realId @@ -162,22 +193,6 @@ } /** - * @param scriptRepoter - * @param mapObj - * @param entries - * @return - */ - public String writeIdMap(IScriptReporter scriptRepoter, String mapObj, String entries) - { - String s = getString(mapObj, new Object[]{entries}); - if (scriptRepoter != null) { - scriptRepoter.addScriptFunction(null, s); - return null; - } - return s; - } - - /** * @param scriptReporter * @param writeLegacy * @param writeId @@ -234,25 +249,16 @@ results.append("\n\n"); } + /////************************* Private Methods ******************************************* + /** - * Returns the string specified by aKey from the errors.properties bundle. - * @param aKey The key for the message pattern in the bundle. - * @param args The args to use in the message format. + * The ScriptRequestState is stored in a request. This is a back pointer to that request. + * When this is created it the pointer will be stored. + * @param req the Outer Request that this object is stored in */ - public static String getString(String aKey, Object[] args) - { - assert (aKey != null); - - String pattern = getBundle().getString(aKey); - if (args == null) - return pattern; - - MessageFormat format = new MessageFormat(pattern); - String result = format.format(args).toString(); - return result; + private void setRequest(ServletRequest req) { + _req = req; } - - /////************************* Private Methods ******************************************* /** * This will map the Features into their keys Modified: incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java?view=diff&rev=128432&p1=incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java&r1=128431&p2=incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java&r2=128432 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java (original) +++ incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java Thu Jan 27 14:20:35 2005 @@ -19,11 +19,13 @@ import org.apache.beehive.netui.tags.AbstractClassicTag; import org.apache.beehive.netui.tags.javascript.IScriptReporter; +import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.divpanel.DivPanel; import org.apache.beehive.netui.tags.databinding.repeater.Repeater; import org.apache.beehive.netui.util.Bundle; import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.BodyContent; import javax.servlet.jsp.tagext.Tag; @@ -326,7 +328,7 @@ * @param buffer * @return String */ - protected final String renderTagId(StringBuilder buffer) + private final String renderTagId(StringBuilder buffer) throws JspException { assert(_name != null); @@ -343,10 +345,8 @@ { // @todo: this is sort of broken, it needs to be updated IScriptReporter scriptReporter = getScriptReporter(); - if (scriptReporter != null) { - scriptReporter.addLegacyTagIdMappings(tagId, value); - return null; - } - return tagId; + ScriptRequestState srs = ScriptRequestState.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); + String scriptId = srs.mapLegacyTagId(scriptReporter,tagId, value); + return scriptId; } }
