Author: dolander Date: Wed Jan 26 21:07:55 2005 New Revision: 126585 URL: http://svn.apache.org/viewcvs?view=rev&rev=126585 Log: Begin the clean up of the ScriptContainer and ScriptRequestState so that the tags go through ScriptRequestState to write out all of their JavaScript.
Added: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java 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/html/RewriteName.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.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/ScriptRequestState.java incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/AbstractClassicTag.java Wed Jan 26 21:07:55 2005 @@ -456,28 +456,6 @@ return sr; } - /** - * This method will add a tagId and value to the ScriptRepoter TagId map. - * The a ScriptContainer tag will create a JavaScript table that allows - * the container, such as a portal, to rewrite the id so it's unique. - * The real name may be looked up based upon the tagId. - * - * If the no ScriptReporter is found, a script string will be returned - * to the caller so they can output the script block. - * @param tagId - * @param value - * @return String - */ - protected String mapLegacyTagId(String tagId, String value) - { - IScriptReporter scriptReporter = getScriptReporter(); - if (scriptReporter != null) { - scriptReporter.addLegacyTagIdMappings(tagId, value); - return null; - } - return tagId; - } - /////////////////////////// Misc Features Support //////////////////////////// /** Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/RequestUtils.java Wed Jan 26 21:07:55 2005 @@ -17,7 +17,6 @@ */ package org.apache.beehive.netui.tags; -import org.apache.beehive.netui.pageflow.PageFlowUtils; import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils; import javax.servlet.ServletRequest; @@ -36,19 +35,19 @@ * @param name * @param value */ - static void setOuterAttribute(HttpServletRequest req,String name,Object value) + public static void setOuterAttribute(HttpServletRequest req,String name,Object value) { ServletRequest realReq = ScopedServletUtils.getOuterRequest(req); realReq.setAttribute(name,value); } /** - * + * * @param req * @param name * @return */ - static Object getOuterAttribute(HttpServletRequest req,String name) + public static Object getOuterAttribute(HttpServletRequest req,String name) { ServletRequest realReq = ScopedServletUtils.getOuterRequest(req); return realReq.getAttribute(name); Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/AnchorBase.java Wed Jan 26 21:07:55 2005 @@ -7,6 +7,7 @@ import org.apache.beehive.netui.tags.javascript.IScriptReporter; import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.javascript.ScriptContainer; +import org.apache.beehive.netui.tags.javascript.CoreScriptFeature; import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; import org.apache.beehive.netui.tags.rendering.*; import org.apache.beehive.netui.util.Bundle; @@ -308,7 +309,7 @@ if (_formSubmit) _form = getNearestForm(); - ScriptRequestState jsu = ScriptContainer.getScriptRequestState(request); + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); // check the parameters that the user provided if (_href != null) have++; @@ -374,7 +375,7 @@ // are defined. if (tagId != null) { _state.id = tagId; - idScript = renderNameAndId(_state, null); + idScript = renderNameAndId(request,_state, null); } // Special case for name anchors @@ -440,7 +441,7 @@ if (_state.onClick == null) { if (_formSubmit && formAction != null) { String realFormName = getFormId(); - _state.onClick = jsu.writeAnchorFormSubmitAction(realFormName, _state.href); + _state.onClick = srs.writeAnchorFormSubmitAction(realFormName, _state.href); if (_form != null) _form.insureRealId(); } @@ -460,9 +461,10 @@ StringBuilderRenderAppender scriptWriter = new StringBuilderRenderAppender(script); if (_formSubmit && formAction != null) - jsu.writeAnchorFormSubmit(getScriptReporter(), scriptWriter); + srs.writeFeature(getScriptReporter(), scriptWriter, CoreScriptFeature.ANCHOR_SUBMIT,true,false, + null); if (_popupSupport != null) - _popupSupport.writeScript(jsu, getScriptReporter(), scriptWriter); + _popupSupport.writeScript(srs, getScriptReporter(), scriptWriter); if (idScript != null) scriptWriter.append(idScript); scriptRef.setRef(script.toString()); @@ -494,7 +496,7 @@ // the tagId must be qualified and we need to output the lookup methods _state.id = getIdForTagId(_state.id); - renderDefaultNameAndId(_state,_state.id,null); + renderDefaultNameAndId((HttpServletRequest) req,_state,_state.id,null); //set the name so legacy browsers can support this. _state.name = _state.id; @@ -530,7 +532,7 @@ // if the tagId was set then rewrite it and output it. if (_state.id != null) { _state.id = getIdForTagId(_state.id); - renderDefaultNameAndId(_state,_state.id,null); + renderDefaultNameAndId((HttpServletRequest) req,_state,_state.id,null); } // write out the tag. Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Body.java Wed Jan 26 21:07:55 2005 @@ -27,6 +27,7 @@ import org.apache.beehive.netui.util.Bundle; import javax.servlet.jsp.JspException; +import javax.servlet.http.HttpServletRequest; /** * @jsptagref.tagdescription <p> @@ -188,7 +189,7 @@ { // we assume that tagId will over have override id if both are defined. if (_state.id != null) { - _idScript = renderNameAndId(_state, null); + _idScript = renderNameAndId((HttpServletRequest) pageContext.getRequest(),_state, null); } // render the header... Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Button.java Wed Jan 26 21:07:55 2005 @@ -286,7 +286,7 @@ // don't write the id attribute Form parentForm = getNearestForm(); - idScript = renderNameAndId(_state, parentForm); + idScript = renderNameAndId(request,_state, parentForm); } else { // set the error because the action is invalid @@ -294,7 +294,7 @@ } } else { - idScript = renderNameAndId(_state, null); + idScript = renderNameAndId(request,_state, null); } // report any errors that may have been generated. Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java Wed Jan 26 21:07:55 2005 @@ -30,6 +30,7 @@ import org.apache.beehive.netui.tags.javascript.IScriptReporter; import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.javascript.ScriptContainer; +import org.apache.beehive.netui.tags.javascript.CoreScriptFeature; import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; import org.apache.beehive.netui.tags.rendering.*; import org.apache.beehive.netui.util.Bundle; @@ -715,7 +716,7 @@ } // if tagId is set we need to add a mapping to the 'id' - idScript = renderNameAndId(); + idScript = renderNameAndId(request); // create real form name attribute if (_state.id == null && _setRealName) @@ -839,13 +840,15 @@ if (focusName != null) { String formName = (_beanName != null) ? _beanName : _formId; - ScriptRequestState.getFocusScript(formName, focusName, writer); + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); + srs.writeFeature(getScriptReporter(), writer, CoreScriptFeature.SET_FOCUS, false, true, + new Object[]{formName, focusName}); } } if (_formSubmit) { - ScriptRequestState jsu = ScriptContainer.getScriptRequestState(request); - jsu.writeAnchorFormSubmit(getScriptReporter(), writer); + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); + srs.writeFeature(getScriptReporter(), writer, CoreScriptFeature.ANCHOR_SUBMIT,true,false, null); } // output any generated javascript @@ -856,7 +859,7 @@ return EVAL_PAGE; } - private String renderNameAndId() + private String renderNameAndId(HttpServletRequest request) { // if id is not set then we need to exit if (_id == null) @@ -865,14 +868,15 @@ // Legacy Java Script support -- This writes out a single table with both the id and names // mixed. This is legacy support to match the pre beehive behavior. String idScript = null; + IScriptReporter scriptReporter = getScriptReporter(); + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); if (TagConfig.isLegacyJavaScript()) { - idScript = mapLegacyTagId(_id, _state.id); + idScript = srs.mapLegacyTagId(scriptReporter, _id, _state.id); } // map the tagId to the real id if (TagConfig.isDefaultJavaScript()) { - - String script = mapTagId(_id, _state.id, _state.name); + String script = srs.mapTagId(scriptReporter, _id, _state.id, _state.name); // if we wrote out script in legacy mode, we need to make sure we preserve it. if (idScript != null) { Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlBaseTag.java Wed Jan 26 21:07:55 2005 @@ -475,7 +475,7 @@ * @param parentForm * @return */ - protected final String renderNameAndId(AbstractHtmlState state, Form parentForm) + protected final String renderNameAndId(HttpServletRequest request,AbstractHtmlState state, Form parentForm) { // if id is not set then we need to exit if (state.id == null) @@ -497,14 +497,15 @@ // mixed. This is legacy support to match the pre beehive behavior. String idScript = null; if (TagConfig.isLegacyJavaScript()) { + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); if (!ctrlState) { - idScript = mapLegacyTagId(id, state.id); + idScript = srs.mapLegacyTagId(getScriptReporter(), id, state.id); } else { AbstractHtmlControlState cState = (AbstractHtmlControlState) state; if (cState.name != null) - idScript = mapLegacyTagId(id, cState.name); + idScript = srs.mapLegacyTagId(getScriptReporter(), id, cState.name); else - idScript = mapLegacyTagId(id, state.id); + idScript = srs.mapLegacyTagId(getScriptReporter(), id, state.id); } } @@ -515,7 +516,7 @@ name = cState.name; } - String script = renderDefaultNameAndId(state, id, name); + String script = renderDefaultNameAndId((HttpServletRequest) pageContext.getRequest(),state, id, name); if (script != null) { if (idScript != null) { idScript = idScript + script; @@ -526,13 +527,15 @@ return idScript; } - protected String renderDefaultNameAndId(AbstractHtmlState state, String id, String name) + + protected String renderDefaultNameAndId(HttpServletRequest request, AbstractHtmlState state, String id, String name) { // map the tagId to the real id String script = null; if (TagConfig.isDefaultJavaScript()) { - script = mapTagId(id, state.id, name); + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); + script = srs.mapTagId(getScriptReporter(), id, state.id, name); } return script; } @@ -557,11 +560,15 @@ * @param value * @return String */ + /* + // @todo: delete this protected String mapLegacyTagId(String tagId, String value) { - String s = super.mapLegacyTagId(tagId, value); - if (s == null) + IScriptReporter scriptReporter = getScriptReporter(); + if (scriptReporter != null) { + scriptReporter.addLegacyTagIdMappings(tagId, value); return null; + } // without a scripRepoter we need to create the actual JavaScript that will be written out ScriptRequestState jsu = ScriptContainer.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); @@ -570,7 +577,10 @@ jsu.getTagIdMapping(tagId, value, writer); return sb.toString(); } + */ + /* + // @todo: delete this protected String mapTagId(String tagId, String realId, String realName) { IScriptReporter scriptReporter = getScriptReporter(); @@ -586,6 +596,7 @@ jsu.getTagIdMapping(tagId, realId, realName, writer); return sb.toString(); } + */ /** * This method will take any absolute URL that doesn't contain the scheme part and append Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/HtmlDataSourceTag.java Wed Jan 26 21:07:55 2005 @@ -23,6 +23,7 @@ import org.apache.beehive.netui.tags.rendering.AbstractHtmlControlState; import javax.servlet.jsp.JspException; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -139,7 +140,7 @@ state.name = applyNamingChain(datasource); Form parentForm = getNearestForm(); - String idScript = renderNameAndId(state, parentForm); + String idScript = renderNameAndId((HttpServletRequest) pageContext.getRequest(),state, parentForm); if (idScript != null) javaScript.setRef(idScript); } Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Image.java Wed Jan 26 21:07:55 2005 @@ -28,6 +28,7 @@ import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; import java.net.URISyntaxException; import java.util.HashMap; @@ -326,7 +327,7 @@ // @todo: should we move the tagId stuff to the base class? //String tagId = getTagId(); if (_state.id != null) { - scriptId = renderNameAndId(_state, null); + scriptId = renderNameAndId((HttpServletRequest) req,_state, null); } WriteRenderAppender writer = new WriteRenderAppender(pageContext); Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageAnchor.java Wed Jan 26 21:07:55 2005 @@ -22,6 +22,7 @@ import org.apache.beehive.netui.tags.IHtmlAccessable; import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.javascript.ScriptContainer; +import org.apache.beehive.netui.tags.javascript.CoreScriptFeature; import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; import org.apache.beehive.netui.tags.rendering.AbstractHtmlState; import org.apache.beehive.netui.tags.rendering.ImageTag; @@ -374,8 +375,8 @@ if (_rolloverImage != null && getJavaScriptAttribute(ONMOUSEOVER) == null) { // cause the roll over script to be inserted WriteRenderAppender writer = new WriteRenderAppender(pageContext); - ScriptRequestState jsu = ScriptContainer.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); - jsu.writeRollover(getScriptReporter(), writer); + ScriptRequestState srs = ScriptContainer.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); + srs.writeFeature(getScriptReporter(), writer, CoreScriptFeature.ROLLOVER,true,false, null); } return EVAL_BODY_BUFFERED; Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/ImageButton.java Wed Jan 26 21:07:55 2005 @@ -21,6 +21,7 @@ import org.apache.beehive.netui.tags.IHtmlAccessable; import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.javascript.ScriptContainer; +import org.apache.beehive.netui.tags.javascript.CoreScriptFeature; import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; import org.apache.beehive.netui.tags.rendering.AbstractHtmlState; import org.apache.beehive.netui.tags.rendering.InputImageTag; @@ -264,9 +265,9 @@ if (_rolloverImage != null && getJavaScriptAttribute(ONMOUSEOVER) == null) { // cause the roll over script to be inserted - ScriptRequestState jsu = ScriptContainer.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); + ScriptRequestState srs = ScriptContainer.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); WriteRenderAppender writer = new WriteRenderAppender(pageContext); - jsu.writeRollover(getScriptReporter(), writer); + srs.writeFeature(getScriptReporter(), writer, CoreScriptFeature.ROLLOVER,true,false, null); } return EVAL_BODY_BUFFERED; @@ -298,7 +299,7 @@ // we assume that tagId will over have override id if both // are defined. if (getTagId() != null) { - idScript = renderNameAndId(_state, null); + idScript = renderNameAndId((HttpServletRequest) req, _state, null); } HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Label.java Wed Jan 26 21:07:55 2005 @@ -26,6 +26,7 @@ import org.apache.beehive.netui.util.logging.Logger; import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; /** @@ -115,7 +116,7 @@ // are defined. //String tagId = getTagId(); if (_state.id != null) { - scriptId = renderNameAndId(_state, null); + scriptId = renderNameAndId((HttpServletRequest) req,_state, null); } if (hasErrors()) 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=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/PopupSupport.java&r2=126585 ============================================================================== --- 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 Wed Jan 26 21:07:55 2005 @@ -22,6 +22,7 @@ import org.apache.beehive.netui.tags.javascript.IScriptReporter; import org.apache.beehive.netui.tags.AbstractClassicTag; import org.apache.beehive.netui.tags.javascript.ScriptRequestState; +import org.apache.beehive.netui.tags.javascript.CoreScriptFeature; import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender; import javax.servlet.jsp.JspException; @@ -169,11 +170,11 @@ return ret; } - public void writeScript(ScriptRequestState jsu, IScriptReporter scriptReporter, AbstractRenderAppender results) + public void writeScript(ScriptRequestState srs, IScriptReporter scriptReporter, AbstractRenderAppender results) { // Write the generic function for popping a window. - jsu.writePopupFunc(scriptReporter, results); - + srs.writeFeature(scriptReporter, results, CoreScriptFeature.POPUP_FUNC, true, false, null); + // 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}); Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteName.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteName.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteName.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteName.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteName.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteName.java Wed Jan 26 21:07:55 2005 @@ -18,8 +18,13 @@ package org.apache.beehive.netui.tags.html; import org.apache.beehive.netui.tags.AbstractClassicTag; +import org.apache.beehive.netui.tags.TagConfig; +import org.apache.beehive.netui.tags.javascript.IScriptReporter; +import org.apache.beehive.netui.tags.javascript.ScriptRequestState; +import org.apache.beehive.netui.tags.javascript.ScriptContainer; import javax.servlet.jsp.JspException; +import javax.servlet.http.HttpServletRequest; /** * Allow a name, typically either an <code>id</code> or <code>name</code> attribute, to participate in URL @@ -104,7 +109,11 @@ // there is now script container, we will eat the <script> blocks // because we cannot write them out in the middle of the tag being // written - mapLegacyTagId(_name, realName); + IScriptReporter scriptReporter = getScriptReporter(); + ScriptRequestState srs = ScriptContainer.getScriptRequestState((HttpServletRequest) pageContext.getRequest()); + if (TagConfig.isLegacyJavaScript()) { + srs.mapLegacyTagId(scriptReporter, _name, realName); + } write(realName); localRelease(); return SKIP_BODY; Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/SelectOption.java Wed Jan 26 21:07:55 2005 @@ -24,6 +24,7 @@ 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.Tag; @@ -275,7 +276,7 @@ // we assume that tagId will over have override id if both // are defined. if (_state.id != null) { - scriptId = renderNameAndId(_state, null); + scriptId = renderNameAndId((HttpServletRequest) req,_state, null); } _state.disabled = _disabled; Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Span.java Wed Jan 26 21:07:55 2005 @@ -26,6 +26,7 @@ import org.apache.beehive.netui.util.logging.Logger; import javax.servlet.ServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; /** @@ -149,7 +150,7 @@ // we assume that tagId will over have override id if both // are defined. if (_state.id != null) { - scriptId = renderNameAndId(_state, null); + scriptId = renderNameAndId((HttpServletRequest) req, _state, null); } // push the evaluated expression when we are not client side bound... Added: 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=auto&rev=126585 ============================================================================== --- (empty file) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/CoreScriptFeature.java Wed Jan 26 21:07:55 2005 @@ -0,0 +1,44 @@ +/* + * Copyright 2004 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * $Header:$ + */ +package org.apache.beehive.netui.tags.javascript; + +/** + * + */ +public enum CoreScriptFeature +{ + LEGACY_LOOKUP (0x0001), + ID_LOOKUP (0x0002), + NAME_LOOKUP (0x0004), + SCOPE_LOOKUP (0x0008), + ROLLOVER (0x0010), + ANCHOR_SUBMIT (0x0020), + POPUP_FUNC (0x0040), + ALLOCATE_LEGACY (0x0080), + ALLOCATE_ID (0x0100), + ALLOCATE_NAME (0x0200), + LEGACY_SCOPE_LOOKUP (0x0400), + SET_FOCUS (0x10000001); + + public int value; + + CoreScriptFeature(int val) + { + value = val; + } +} 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=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptContainer.java&r2=126585 ============================================================================== --- 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 Wed Jan 26 21:07:55 2005 @@ -18,16 +18,15 @@ package org.apache.beehive.netui.tags.javascript; import org.apache.beehive.netui.tags.AbstractClassicTag; +import org.apache.beehive.netui.tags.RequestUtils; import org.apache.beehive.netui.tags.TagConfig; -import org.apache.beehive.netui.tags.html.HtmlBaseTag; import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender; import org.apache.beehive.netui.tags.rendering.WriteRenderAppender; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; -import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.SimpleTagSupport; -import javax.servlet.ServletRequest; +import javax.servlet.jsp.tagext.Tag; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -168,7 +167,7 @@ } /** - * + * This will add the mapping between the tagId and the real name to the NameMap hashmap. * @param tagId * @param realId * @param realName @@ -616,13 +615,13 @@ * @param request the HttpServletRequest associated with this request * @return a <code>ScriptRequestState</code> assocated with the request */ - static public ScriptRequestState getScriptRequestState(ServletRequest request) + static public ScriptRequestState getScriptRequestState(HttpServletRequest request) { assert (request != null); - ScriptRequestState srs = (ScriptRequestState) request.getAttribute(JAVASCRIPT_STATUS); + ScriptRequestState srs = (ScriptRequestState) RequestUtils.getOuterAttribute(request,JAVASCRIPT_STATUS); if (srs == null) { srs = new ScriptRequestState(); - request.setAttribute(JAVASCRIPT_STATUS, srs); + RequestUtils.setOuterAttribute(request,JAVASCRIPT_STATUS, srs); } assert (srs != null); return srs; 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=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/javascript/ScriptRequestState.java&r2=126585 ============================================================================== --- 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 Wed Jan 26 21:07:55 2005 @@ -19,6 +19,7 @@ import org.apache.beehive.netui.tags.TagConfig; import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender; +import org.apache.beehive.netui.tags.rendering.StringBuilderRenderAppender; import java.io.Serializable; import java.text.MessageFormat; @@ -38,9 +39,6 @@ private static final int ID_LOOKUP = 0x0002; private static final int NAME_LOOKUP = 0x0004; private static final int SCOPE_LOOKUP = 0x0008; - private static final int ROLLOVER = 0x0010; - private static final int ANCHOR_SUBMIT = 0x0020; - private static final int POPUP_FUNC = 0x0040; private static final int ALLOCATE_LEGACY = 0x0080; private static final int ALLOCATE_ID = 0x0100; private static final int ALLOCATE_NAME = 0x0200; @@ -49,12 +47,100 @@ private int _javaScriptFeatures; // this is a integer bitmap indicating various feature have been written out or not private static ResourceBundle _bundle; // This points to the bundle + + public void writeFeature(IScriptReporter scriptReporter, AbstractRenderAppender results, + CoreScriptFeature feature, boolean singleInstance, boolean inline, + Object[] args) + { + if (singleInstance) { + if ((_javaScriptFeatures & feature.value) != 0) + return; + _javaScriptFeatures |= feature.value; + } + + // get the JavaScript to write out + String jsKey = getFeatureKey(feature); + String s = getString(jsKey, args); + + if (inline || scriptReporter == null) { + writeScriptBlock(results,s); + return; + } + + scriptReporter.addScriptFunction(s); + } + + private String getFeatureKey(CoreScriptFeature feature) + { + switch (feature) { + case ANCHOR_SUBMIT: + return "anchorFormSubmit"; + case SET_FOCUS: + return "setFocus"; + case POPUP_FUNC: + return "popupFunc"; + case ROLLOVER: + return "rollover"; + } + assert(false) : "getFeature Fell through on feature:" + feature; + return null; + } + + /** + * + * @param scriptReporter + * @param tagId + * @param realId + * @param realName + * @return + */ + public String mapTagId(IScriptReporter scriptReporter, String tagId, String realId, String realName) + { + if (scriptReporter != null) { + scriptReporter.addTagIdMappings(tagId, realId, realName); + return null; + } + + // without a scripRepoter we need to create the actual JavaScript that will be written out + StringBuilder sb = new StringBuilder(128); + StringBuilderRenderAppender writer = new StringBuilderRenderAppender(sb); + getTagIdMapping(tagId, realId, realName, writer); + return sb.toString(); + } + + /** + * This method will add a tagId and value to the ScriptRepoter TagId map. + * The a ScriptContainer tag will create a JavaScript table that allows + * the container, such as a portal, to rewrite the id so it's unique. + * The real name may be looked up based upon the tagId. + * + * If the no ScriptReporter is found, a script string will be returned + * to the caller so they can output the script block. + * @param tagId + * @param value + * @return String + */ + public String mapLegacyTagId(IScriptReporter scriptReporter, String tagId, String value) + { + if (scriptReporter != null) { + scriptReporter.addLegacyTagIdMappings(tagId, value); + return null; + } + + // without a scripRepoter we need to create the actual JavaScript that will be written out + StringBuilder sb = new StringBuilder(64); + StringBuilderRenderAppender writer = new StringBuilderRenderAppender(sb); + getTagIdMapping(tagId, value, writer); + return sb.toString(); + } + /** * @param scriptReporter * @param results */ + /* public void writeAnchorFormSubmit(IScriptReporter scriptReporter, AbstractRenderAppender results) - { + // check to see if we have already written out the form submit if ((_javaScriptFeatures & ANCHOR_SUBMIT) != 0) return; @@ -73,8 +159,10 @@ writeScriptBlock(results, s); } + */ /** + * This will create the onClick JavaScript that will cause an anchor to submit a form. * @param action * @param newAction * @return @@ -94,16 +182,17 @@ * @param scriptReporter * @param results */ + /* public void writePopupFunc(IScriptReporter scriptReporter, AbstractRenderAppender results) { // check to see if we have already written out the popup function if ((_javaScriptFeatures & POPUP_FUNC) != 0) return; _javaScriptFeatures |= POPUP_FUNC; - + // get the method and write it. String s = getString("popupFunc", null); - + // if we passed in a script reporter, it will handle the // javaScript, otherwise update the buffer by writing a // script block into it. @@ -111,16 +200,18 @@ scriptReporter.addScriptFunction(s); return; } - + writeScriptBlock(results, s); } - + */ + /** * this will write out the form focus script block * @param formName * @param fieldName * @param results */ + /* public static void getFocusScript(String formName, String fieldName, AbstractRenderAppender results) { assert (formName != null); @@ -130,6 +221,7 @@ String s = getString("setFocus", new Object[]{formName, fieldName}); writeScriptBlock(results, s); } + */ /** * This method will write out a tagId map entry for when there @@ -138,10 +230,10 @@ * @param value the "real" value of the written out * @param results the JavaScript that will be output */ - public void getTagIdMapping(String tagId, String value, AbstractRenderAppender results) + private void getTagIdMapping(String tagId, String value, AbstractRenderAppender results) { - if ((_javaScriptFeatures & ALLOCATE_LEGACY) == 0) { - _javaScriptFeatures |= ALLOCATE_LEGACY; + if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_LEGACY.value) == 0) { + _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_LEGACY.value; String s = getString("singleIdMappingTable", new Object[]{tagId, value}); String meths = writeNetuiNameFunctions(null, true, false, false); if (meths != null) @@ -161,12 +253,12 @@ * @param realName * @param results */ - public void getTagIdMapping(String tagId, String realId, String realName, AbstractRenderAppender results) + private void getTagIdMapping(String tagId, String realId, String realName, AbstractRenderAppender results) { StringBuilder sb = new StringBuilder(128); if (realId != null) { - if ((_javaScriptFeatures & ALLOCATE_ID) == 0) { - _javaScriptFeatures |= ALLOCATE_ID; + if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_ID.value) == 0) { + _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_ID.value; String meths = writeNetuiNameFunctions(null, false, true, false); if (meths != null) sb.append(meths); @@ -174,8 +266,8 @@ } if (realName != null) { - if ((_javaScriptFeatures & ALLOCATE_NAME) == 0) { - _javaScriptFeatures |= ALLOCATE_NAME; + if ((_javaScriptFeatures & CoreScriptFeature.ALLOCATE_NAME.value) == 0) { + _javaScriptFeatures |= CoreScriptFeature.ALLOCATE_NAME.value; String s = getString("singleIdToNameMappingTable", new Object[]{tagId, realName}); String meths = writeNetuiNameFunctions(null, false, false, true); if (meths != null) @@ -194,6 +286,7 @@ * @param scriptReporter * @param results */ + /* public void writeRollover(IScriptReporter scriptReporter, AbstractRenderAppender results) { // check if we have already written out the rollover feature @@ -210,6 +303,7 @@ writeScriptBlock(results, s); return; } + */ /** * @param scriptRepoter Modified: incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java (original) +++ incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/tree/Tree.java Wed Jan 26 21:07:55 2005 @@ -19,21 +19,19 @@ import org.apache.beehive.netui.core.URLCodec; import org.apache.beehive.netui.core.urls.MutableURI; -import org.apache.beehive.netui.pageflow.internal.InternalUtils; import org.apache.beehive.netui.pageflow.internal.AdapterManager; -import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils; -import org.apache.beehive.netui.pageflow.requeststate.NameService; +import org.apache.beehive.netui.pageflow.internal.InternalUtils; import org.apache.beehive.netui.pageflow.requeststate.INameable; +import org.apache.beehive.netui.pageflow.requeststate.NameService; +import org.apache.beehive.netui.pageflow.scoping.ScopedServletUtils; import org.apache.beehive.netui.script.ExpressionUpdateException; import org.apache.beehive.netui.script.IllegalExpressionException; import org.apache.beehive.netui.tags.*; -import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.html.HtmlConstants; -import org.apache.beehive.netui.tags.javascript.ScriptRequestState; +import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; import org.apache.beehive.netui.tags.javascript.IScriptReporter; import org.apache.beehive.netui.tags.javascript.ScriptContainer; -import org.apache.beehive.netui.tags.html.HtmlBaseTag; -import org.apache.beehive.netui.tags.internal.PageFlowTagUtils; +import org.apache.beehive.netui.tags.javascript.ScriptRequestState; import org.apache.beehive.netui.tags.rendering.*; import org.apache.beehive.netui.util.Bundle; @@ -717,7 +715,7 @@ // check to see if we are writing out the java. if (_outputJavaScript) { - String jsOut = renderDefaultJavaScript(divId); + String jsOut = renderDefaultJavaScript(request,divId); if (jsOut != null) write(jsOut); } @@ -803,7 +801,7 @@ String tagId = node.getTagId(); String script = null; if (tagId != null) { - script = renderTagId(tagId, _divState); + script = renderTagId(request, tagId, _divState); } attrs.renderDiv(_divState, node); if (_runAtClient) { @@ -1199,11 +1197,11 @@ * @param state * @return String */ - protected final String renderTagId(String tagId, AbstractHtmlState state) + protected final String renderTagId(HttpServletRequest request,String tagId, AbstractHtmlState state) { assert(_tagId != null); state.id = getIdForTagId(tagId); - String script = renderDefaultJavaScript(state.id); + String script = renderDefaultJavaScript(request,state.id); return script; } @@ -1220,21 +1218,23 @@ } //**************************** - //@TODO: move this into a tag helper class of some type and remove the duplication from HtmlBaseTag /** Much of the code below is taken from the HtmlBaseTag. We need to eliminate this duplication * through some type of helper methods. */ - private String renderDefaultJavaScript(String realId) + private String renderDefaultJavaScript(HttpServletRequest request,String realId) { String idScript = null; // map the tagId to the real id if (TagConfig.isDefaultJavaScript()) { - idScript = mapTagId(_tagId, realId); + ScriptRequestState srs = ScriptContainer.getScriptRequestState(request); + idScript = srs.mapTagId(getScriptReporter(), _tagId, realId, null); } return idScript; } + /* + // @todo: delete this private String mapTagId(String tagId, String realId) { IScriptReporter scriptReporter = getScriptReporter(); @@ -1250,6 +1250,7 @@ jsu.getTagIdMapping(tagId, realId, null, writer); return sb.toString(); } + */ /** * This method will return the <code>javaScriptUtils</code> that is assocated 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=126585&p1=incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java&r1=126584&p2=incubator/beehive/trunk/netui/src/tags-template/org/apache/beehive/netui/tags/template/Section.java&r2=126585 ============================================================================== --- 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 Wed Jan 26 21:07:55 2005 @@ -18,6 +18,7 @@ package org.apache.beehive.netui.tags.template; import org.apache.beehive.netui.tags.AbstractClassicTag; +import org.apache.beehive.netui.tags.javascript.IScriptReporter; import org.apache.beehive.netui.tags.divpanel.DivPanel; import org.apache.beehive.netui.tags.databinding.repeater.Repeater; import org.apache.beehive.netui.util.Bundle; @@ -329,11 +330,23 @@ throws JspException { assert(_name != null); + // @todo: this is busted. It should be writting out inline. String realName = rewriteName(_name); String idScript = mapLegacyTagId(_name, realName); // some tags will output the id attribute themselves so they don't write this out renderAttribute(buffer, "id", realName); return idScript; + } + + private String mapLegacyTagId(String tagId, String value) + { + // @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; } } Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp&r1=126584&p2=incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/idmap/treeNested/index.jsp Wed Jan 26 21:07:55 2005 @@ -1,7 +1,7 @@ <%@ page language="java" contentType="text/html;charset=UTF-8"%> <%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%> -<netui:html generateIdScope="true" runAtClient="true"> +<netui:html generateIdScope="true"> <head> <netui:base/> </head> Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml Url: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml?view=diff&rev=126585&p1=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml&r1=126584&p2=incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml&r2=126585 ============================================================================== --- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml (original) +++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/MockPortal.xml Wed Jan 26 21:07:55 2005 @@ -2,7 +2,7 @@ <ses:recorderSession xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session"> <ses:sessionName>MockPortal</ses:sessionName> <ses:tester>rich</ses:tester> - <ses:startDate>18 Jan 2005, 06:49:12.031 PM MST</ses:startDate> + <ses:startDate>26 Jan 2005, 06:25:25.993 PM MST</ses:startDate> <ses:description>rich</ses:description> <ses:tests> <ses:test> @@ -18,7 +18,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -44,7 +44,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -56,7 +56,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -247,63 +247,6 @@ var netui_tagIdNameMap = new Object(); netui_tagIdNameMap.tb="smokeTestB{pageFlow.data}" - -// **** This section contains functions typically run as events **** - - -// method which will return a real id for a tagId, -// the tag parameter will be used to find the idScope for -// containers that may scope their ids -function getNetuiTagName(id, tag) -{ - var idScope = getScopeId(tag); - if (idScope == "") - return netui_names[id]; - else - return netui_names[idScope + "__" + id]; -} - -// This method will walk the hierarchy from the pass element looking for a idScope. -// The first idScope found will be returned or the empty string if a idScope is not found. -function getScopeId(tag) -{ - if (tag == null || tag.getAttribute == null) - return ""; - var attrVal = tag.getAttribute("netui:idScope"); - if (attrVal != null) - return attrVal; - return getScopeId(tag.parentNode); -} - -// lookup by tagId to "real id" -function lookupIdByTagId(id, tag) -{ - var idScope = lookupIdScope(tag,"."); - return (idScope == "") ? id : idScope + id; -} - -// lookup by tagId to "real name" -function lookupNameByTagId(id, tag) -{ - var idScope = lookupIdScope(tag,"_"); - if (idScope == "") - return netui_tagIdNameMap[id]; - else - return netui_tagIdNameMap[idScope + "__" + id]; -} - -//Non-Legacy lookup method creating a fully qualified scope id -function lookupIdScope(tag,sep) -{ - var val = ""; - while (tag != null && tag.getAttribute != null) { - var attrVal = tag.getAttribute("netui:idScope"); - if (attrVal != null) - val = attrVal + sep + val; - tag = tag.parentNode; - } - return val; -} --> </script> @@ -349,7 +292,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -383,7 +326,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -395,7 +338,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -501,6 +444,63 @@ var netui_tagIdNameMap = new Object(); netui_tagIdNameMap.tb="smokeTestB{pageFlow.data}" + +// **** This section contains functions typically run as events **** + + +// method which will return a real id for a tagId, +// the tag parameter will be used to find the idScope for +// containers that may scope their ids +function getNetuiTagName(id, tag) +{ + var idScope = getScopeId(tag); + if (idScope == "") + return netui_names[id]; + else + return netui_names[idScope + "__" + id]; +} + +// This method will walk the hierarchy from the pass element looking for a idScope. +// The first idScope found will be returned or the empty string if a idScope is not found. +function getScopeId(tag) +{ + if (tag == null || tag.getAttribute == null) + return ""; + var attrVal = tag.getAttribute("netui:idScope"); + if (attrVal != null) + return attrVal; + return getScopeId(tag.parentNode); +} + +// lookup by tagId to "real id" +function lookupIdByTagId(id, tag) +{ + var idScope = lookupIdScope(tag,"."); + return (idScope == "") ? id : idScope + id; +} + +// lookup by tagId to "real name" +function lookupNameByTagId(id, tag) +{ + var idScope = lookupIdScope(tag,"_"); + if (idScope == "") + return netui_tagIdNameMap[id]; + else + return netui_tagIdNameMap[idScope + "__" + id]; +} + +//Non-Legacy lookup method creating a fully qualified scope id +function lookupIdScope(tag,sep) +{ + var val = ""; + while (tag != null && tag.getAttribute != null) { + var attrVal = tag.getAttribute("netui:idScope"); + if (attrVal != null) + val = attrVal + sep + val; + tag = tag.parentNode; + } + return val; +} --> </script> @@ -546,7 +546,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -580,7 +580,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -592,7 +592,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -689,7 +689,7 @@ </html>]]></ses:responseBody> </ses:response> <ses:testResults> - <ses:testStatus>fail</ses:testStatus> + <ses:testStatus>pass</ses:testStatus> </ses:testResults> </ses:test> <ses:test> @@ -714,7 +714,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -740,7 +740,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -752,7 +752,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -931,7 +931,7 @@ </html>]]></ses:responseBody> </ses:response> <ses:testResults> - <ses:testStatus>fail</ses:testStatus> + <ses:testStatus>pass</ses:testStatus> </ses:testResults> </ses:test> <ses:test> @@ -956,7 +956,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -982,7 +982,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -994,7 +994,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -1090,7 +1090,7 @@ </html>]]></ses:responseBody> </ses:response> <ses:testResults> - <ses:testStatus>fail</ses:testStatus> + <ses:testStatus>pass</ses:testStatus> </ses:testResults> </ses:test> <ses:test> @@ -1115,7 +1115,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -1141,7 +1141,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -1153,7 +1153,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -1331,7 +1331,7 @@ </html>]]></ses:responseBody> </ses:response> <ses:testResults> - <ses:testStatus>fail</ses:testStatus> + <ses:testStatus>pass</ses:testStatus> </ses:testResults> </ses:test> <ses:test> @@ -1356,7 +1356,7 @@ <ses:cookies> <ses:cookie> <ses:name>JSESSIONID</ses:name> - <ses:value>401BA83031A94CBDA416B26EB0A88FB5</ses:value> + <ses:value>64DD8FD524EC991D2603B1FD31D5F5FC</ses:value> </ses:cookie> </ses:cookies> <ses:headers> @@ -1382,7 +1382,7 @@ </ses:header> <ses:header> <ses:name>cookie</ses:name> - <ses:value>$Version=0; JSESSIONID=401BA83031A94CBDA416B26EB0A88FB5; $Path=/coreWeb</ses:value> + <ses:value>$Version=0; JSESSIONID=64DD8FD524EC991D2603B1FD31D5F5FC; $Path=/coreWeb</ses:value> </ses:header> <ses:header> <ses:name>host</ses:name> @@ -1394,7 +1394,7 @@ </ses:header> <ses:header> <ses:name>testrecorder.playback.testid</ses:name> - <ses:value>-54834ffa:101889e165b:-7c0e</ses:value> + <ses:value>2359fcf6:101b1baed23:-7beb</ses:value> </ses:header> <ses:header> <ses:name>user-agent</ses:name> @@ -1598,13 +1598,13 @@ </html>]]></ses:responseBody> </ses:response> <ses:testResults> - <ses:testStatus>fail</ses:testStatus> + <ses:testStatus>pass</ses:testStatus> </ses:testResults> </ses:test> </ses:tests> - <ses:endDate>18 Jan 2005, 06:49:16.781 PM MST</ses:endDate> + <ses:endDate>26 Jan 2005, 06:25:33.734 PM MST</ses:endDate> <ses:sessionStatus>fail</ses:sessionStatus> <ses:testCount>7</ses:testCount> - <ses:passedCount>0</ses:passedCount> - <ses:failedCount>7</ses:failedCount> + <ses:passedCount>5</ses:passedCount> + <ses:failedCount>2</ses:failedCount> </ses:recorderSession>
