From: Gautam J. <ga...@us...> - 2006-10-18 02:05:46
|
Update of /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17744/source/java/org/jaffa/presentation/portlet/widgets/taglib Modified Files: Tag: BRANCH_3_1_0 CheckBoxTag.java CustomModelTag.java DateTimeTag.java DropDownTag.java EditBoxTag.java GridTag.java HeaderTag.java RadioButtonTag.java TableTag.java TagHelper.java Log Message: Enhanced the javascript to cache the various widgets in a tree-like structure, so that the entire DOM isn't scanned for packing Grid data into XML Index: TagHelper.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/TagHelper.java,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -C2 -d -r1.12 -r1.12.2.1 *** TagHelper.java 21 Oct 2005 14:28:52 -0000 1.12 --- TagHelper.java 18 Oct 2006 02:05:41 -0000 1.12.2.1 *************** *** 63,68 **** import javax.servlet.http.HttpSession; import javax.servlet.jsp.JspException; - import javax.servlet.jsp.tagext.Tag; - import javax.servlet.ServletRequest; import org.jaffa.metadata.FieldMetaData; import org.jaffa.persistence.util.PersistentHelper; --- 63,66 ---- *************** *** 137,140 **** --- 135,145 ---- /** + * This is a standard attribute which carries the id of the Parent tag. + * This may differ from the ATTRIBUTE_ID_PREFIX, which typically carries extra context like the columnNo. + * Its removed in the FormTag.release() + */ + public static final String ATTRIBUTE_PARENT_NODE_ID = "org.jaffa.presentation.portlet.widgets.taglib.parentNodeId"; + + /** * This is a standard attribute which carries the eventPrefix, set by the enclosing tags of the parent tag * Its removed in the FormTag.release() *************** *** 152,156 **** /** This is the name of the Form bean accessable via Expression Language */ public static final String ATTRIBUTE_EL_FORM = "form"; ! /** * This is a session-level attribute which will contain the prefix to use for hyperlinking to the LabelEditor. --- 157,161 ---- /** This is the name of the Form bean accessable via Expression Language */ public static final String ATTRIBUTE_EL_FORM = "form"; ! /** * This is a session-level attribute which will contain the prefix to use for hyperlinking to the LabelEditor. *************** *** 173,179 **** ! /** Returns a Map containing the attributes ATTRIBUTE_ENCLOSED, ATTRIBUTE_ID_PREFIX, ATTRIBUTE_EVENT_PREFIX, ATTRIBUTE_MODEL_MAP. * @param pageContext The PageContext of the jsp. ! * @return a Map containing the attributes ATTRIBUTE_ENCLOSED, ATTRIBUTE_ID_PREFIX, ATTRIBUTE_EVENT_PREFIX, ATTRIBUTE_MODEL_MAP. */ public static Map getOriginalAttributes(PageContext pageContext) { --- 178,184 ---- ! /** Returns a Map containing the attributes ATTRIBUTE_ENCLOSED, ATTRIBUTE_ID_PREFIX, ATTRIBUTE_PARENT_NODE_ID, ATTRIBUTE_EVENT_PREFIX, ATTRIBUTE_MODEL_MAP. * @param pageContext The PageContext of the jsp. ! * @return a Map containing the attributes ATTRIBUTE_ENCLOSED, ATTRIBUTE_ID_PREFIX, ATTRIBUTE_PARENT_NODE_ID, ATTRIBUTE_EVENT_PREFIX, ATTRIBUTE_MODEL_MAP. */ public static Map getOriginalAttributes(PageContext pageContext) { *************** *** 181,184 **** --- 186,190 ---- map.put(ATTRIBUTE_ENCLOSED, pageContext.findAttribute(ATTRIBUTE_ENCLOSED)); map.put(ATTRIBUTE_ID_PREFIX, pageContext.findAttribute(ATTRIBUTE_ID_PREFIX)); + map.put(ATTRIBUTE_PARENT_NODE_ID, pageContext.findAttribute(ATTRIBUTE_PARENT_NODE_ID)); map.put(ATTRIBUTE_EVENT_PREFIX, pageContext.findAttribute(ATTRIBUTE_EVENT_PREFIX)); map.put(ATTRIBUTE_MODEL_MAP, pageContext.findAttribute(ATTRIBUTE_MODEL_MAP)); *************** *** 187,191 **** } ! /** Restores the attributes ATTRIBUTE_ENCLOSED, ATTRIBUTE_ID_PREFIX, ATTRIBUTE_EVENT_PREFIX, ATTRIBUTE_MODEL_MAP in the PageContext to the values passed in the input Map. * @param pageContext The PageContext of the jsp. * @param map The Map containing the original values. --- 193,197 ---- } ! /** Restores the attributes ATTRIBUTE_ENCLOSED, ATTRIBUTE_ID_PREFIX, ATTRIBUTE_PARENT_NODE_ID, ATTRIBUTE_EVENT_PREFIX, ATTRIBUTE_MODEL_MAP in the PageContext to the values passed in the input Map. * @param pageContext The PageContext of the jsp. * @param map The Map containing the original values. *************** *** 194,197 **** --- 200,204 ---- restoreOriginalAttribute(pageContext, map, ATTRIBUTE_ENCLOSED); restoreOriginalAttribute(pageContext, map, ATTRIBUTE_ID_PREFIX); + restoreOriginalAttribute(pageContext, map, ATTRIBUTE_PARENT_NODE_ID); restoreOriginalAttribute(pageContext, map, ATTRIBUTE_EVENT_PREFIX); restoreOriginalAttribute(pageContext, map, ATTRIBUTE_MODEL_MAP); *************** *** 226,230 **** return f==null?null:f.getHtmlName(); } ! /** Returns the name of the Form. * @param pageContext The PageContext of the jsp. --- 233,237 ---- return f==null?null:f.getHtmlName(); } ! /** Returns the name of the Form. * @param pageContext The PageContext of the jsp. *************** *** 263,266 **** --- 270,281 ---- } + /** Returns the id of the Parent tag. + * @param pageContext The PageContext of the jsp. + * @return the id of the Parent tag. + */ + public static String getParentNodeId(PageContext pageContext) { + return (String) pageContext.findAttribute(ATTRIBUTE_PARENT_NODE_ID); + } + /** Returns the event prefix. * @param pageContext The PageContext of the jsp. Index: CheckBoxTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/CheckBoxTag.java,v retrieving revision 1.19 retrieving revision 1.19.2.1 diff -C2 -d -r1.19 -r1.19.2.1 *** CheckBoxTag.java 15 Aug 2006 02:07:07 -0000 1.19 --- CheckBoxTag.java 18 Oct 2006 02:05:41 -0000 1.19.2.1 *************** *** 298,301 **** --- 298,302 ---- sb.append(" CLASS=\"WidgetCheckBox\""); sb.append(" VALUE=\"" + (widgetValue ? "true" : "false") + "\"/>\n"); + sb.append(getWidgetRegistrationScript(idPrefix, false)); return sb.toString(); } *************** *** 315,318 **** --- 316,320 ---- sb.append(" CLASS=\"WidgetCheckBox\""); sb.append(" VALUE=\"" + (widgetValue ? "true" : "false") + "\"/>\n"); + sb.append(getWidgetRegistrationScript(idPrefix, false)); return sb.toString(); *************** *** 384,387 **** --- 386,390 ---- .append(" class='WidgetCheckBox' value='true'/>\n"); } + sb.append(getWidgetRegistrationScript(idPrefix, false)); return sb.toString(); } Index: RadioButtonTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/RadioButtonTag.java,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -C2 -d -r1.17 -r1.17.2.1 *** RadioButtonTag.java 15 Aug 2006 20:08:26 -0000 1.17 --- RadioButtonTag.java 18 Oct 2006 02:05:41 -0000 1.17.2.1 *************** *** 168,171 **** --- 168,172 ---- sb.append("value=\"" + getSelectValue() + "\"" + (getSelectValue().equals(widgetValue) ? " checked" : "") + ">\n"); + sb.append(getWidgetRegistrationScript(idPrefix, false)); return sb.toString(); } Index: DropDownTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/DropDownTag.java,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -C2 -d -r1.24 -r1.24.2.1 *** DropDownTag.java 15 Aug 2006 20:08:26 -0000 1.24 --- DropDownTag.java 18 Oct 2006 02:05:41 -0000 1.24.2.1 *************** *** 366,371 **** private String getHtml() { StringBuffer b = new StringBuffer(); ! b.append("<select id = \"" + getHtmlIdPrefix() + "\""+ (TagHelper.isEnclosed(pageContext) ? "" : " name=\"" + getField() + "WV\"") + " class=\"WidgetDropDown\">\n"); Object widgetValueObject = m_model.getWidgetValue(); String widgetValue = widgetValueObject != null ? m_propertyRuleIntrospector.format(widgetValueObject) : m_model.getStringValue(); --- 366,372 ---- private String getHtml() { + String idPrefix = getHtmlIdPrefix(); StringBuffer b = new StringBuffer(); ! b.append("<select id = \"" + idPrefix + "\""+ (TagHelper.isEnclosed(pageContext) ? "" : " name=\"" + getField() + "WV\"") + " class=\"WidgetDropDown\">\n"); Object widgetValueObject = m_model.getWidgetValue(); String widgetValue = widgetValueObject != null ? m_propertyRuleIntrospector.format(widgetValueObject) : m_model.getStringValue(); *************** *** 412,415 **** --- 413,417 ---- } b.append("</select>\n"); + b.append(getWidgetRegistrationScript(idPrefix, false)); return b.toString(); } Index: TableTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/TableTag.java,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -C2 -d -r1.15 -r1.15.2.1 *** TableTag.java 21 Oct 2005 14:28:52 -0000 1.15 --- TableTag.java 18 Oct 2006 02:05:41 -0000 1.15.2.1 *************** *** 50,66 **** package org.jaffa.presentation.portlet.widgets.taglib; - import java.io.PrintWriter; import java.io.IOException; import java.util.*; - - import javax.servlet.ServletRequest; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; - import javax.servlet.jsp.PageContext; [...966 lines suppressed...] * This method is not invoked if the Throwable occurs during one of the setter methods. *************** *** 714,721 **** initTag(); } ! public String getFooterHtml() { return c_header; } ! } --- 710,717 ---- initTag(); } ! public String getFooterHtml() { return c_header; } ! } Index: GridTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/GridTag.java,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -C2 -d -r1.23 -r1.23.2.1 *** GridTag.java 2 Jun 2006 00:57:51 -0000 1.23 --- GridTag.java 18 Oct 2006 02:05:41 -0000 1.23.2.1 *************** *** 52,56 **** import java.io.IOException; import java.util.*; - import java.util.Map.Entry; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; --- 52,55 ---- *************** *** 61,65 **** import org.apache.struts.action.ActionMessages; import org.jaffa.metadata.DateTimeFieldMetaData; [...1733 lines suppressed...] * Setter for property rowStyle. *************** *** 1484,1487 **** m_rowStyle = rowStyle; } ! } --- 1487,1498 ---- m_rowStyle = rowStyle; } ! ! private String getNodeId() { ! if (m_nodeId == null) { ! String parentNodeId = TagHelper.getParentNodeId(pageContext); ! m_nodeId = (parentNodeId != null ? parentNodeId + '_' + getField() : getHtmlIdPrefix()) + "_h"; ! } ! return m_nodeId; ! } ! } Index: HeaderTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/HeaderTag.java,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -C2 -d -r1.11 -r1.11.2.1 *** HeaderTag.java 5 Apr 2006 18:04:49 -0000 1.11 --- HeaderTag.java 18 Oct 2006 02:05:41 -0000 1.11.2.1 *************** *** 51,61 **** import java.io.IOException; - import java.io.PrintWriter; import java.util.Calendar; - import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; - import javax.servlet.jsp.PageContext; import org.apache.log4j.Logger; import org.jaffa.datatypes.Parser; --- 51,58 ---- *************** *** 64,69 **** import org.jaffa.util.URLHelper; - import javax.servlet.jsp.tagext.*; - /** Tag Handler for the Header tag.*/ public class HeaderTag extends CustomTag { --- 61,64 ---- *************** *** 135,145 **** buf.append(getNoCacheTag()); buf.append(getBaseTag()); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/panels/header.js\"/></SCRIPT>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/panels/errorpopup.js\"/></SCRIPT>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/rules/coreRules.js\"/></SCRIPT>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/rules/rulesValidator.js\"/></SCRIPT>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/rules/initializeRules.js\"/></SCRIPT>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/widgets/datetimePicker.js\"/></SCRIPT>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/widgets/dropdownManager.js\"/></SCRIPT>\n" ); if ( getErrorBoxInSameWindow() ) { --- 130,141 ---- buf.append(getNoCacheTag()); buf.append(getBaseTag()); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/panels/header.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/panels/errorpopup.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/rules/coreRules.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/rules/rulesValidator.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/rules/initializeRules.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/widgets/datetimePicker.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/widgets/dropdownManager.js\"></script>\n" ); ! buf.append( "<SCRIPT type=\"text/javascript\" src=\"jaffa/js/widgets/widgetCache.js\"></script>\n" ); if ( getErrorBoxInSameWindow() ) { *************** *** 235,238 **** return buf.toString(); } ! } --- 231,234 ---- return buf.toString(); } ! } Index: EditBoxTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/EditBoxTag.java,v retrieving revision 1.50 retrieving revision 1.50.2.1 diff -C2 -d -r1.50 -r1.50.2.1 *** EditBoxTag.java 31 Aug 2006 20:35:38 -0000 1.50 --- EditBoxTag.java 18 Oct 2006 02:05:41 -0000 1.50.2.1 *************** *** 674,679 **** .append(getAutoTabTo()) .append("',this)\""); ! sb.append(">\n"); ! sb.append("<script>validationRules.addField(document.getElementById('").append(idPrefix).append("'));</script>"); return sb.toString(); --- 674,679 ---- .append(getAutoTabTo()) .append("',this)\""); ! sb.append(">\n") ! .append(getWidgetRegistrationScript(idPrefix, true)); return sb.toString(); *************** *** 708,712 **** .append( StringHelper.convertToHTML(value)) .append("</textarea>\n") ! .append("<script>validationRules.addField(document.getElementById('"+ idPrefix +"'));</script>"); if (m_percentageH != null || m_percentageW != null ) { sb.append("<script>resizeTextArea(document.getElementById('" + idPrefix + "') , " + m_percentageW + " , " + m_percentageH + " , " + m_horizontalOffset + " , " + m_verticalOffset + " , " + m_horizontalMax + " , " + m_verticalMax + ");</script>" ); --- 708,712 ---- .append( StringHelper.convertToHTML(value)) .append("</textarea>\n") ! .append(getWidgetRegistrationScript(idPrefix, true)); if (m_percentageH != null || m_percentageW != null ) { sb.append("<script>resizeTextArea(document.getElementById('" + idPrefix + "') , " + m_percentageW + " , " + m_percentageH + " , " + m_horizontalOffset + " , " + m_verticalOffset + " , " + m_horizontalMax + " , " + m_verticalMax + ");</script>" ); Index: DateTimeTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/DateTimeTag.java,v retrieving revision 1.24 retrieving revision 1.24.2.1 diff -C2 -d -r1.24 -r1.24.2.1 *** DateTimeTag.java 15 Aug 2006 20:08:26 -0000 1.24 --- DateTimeTag.java 18 Oct 2006 02:05:41 -0000 1.24.2.1 *************** *** 388,392 **** formattedDateTime = formattedDate + " " + value.getHourOfDay() + ":" + value.getMinute(); sb.append(" VALUE=\"" + formattedDateTime + "\"\n>"); ! return sb.toString(); } --- 388,392 ---- formattedDateTime = formattedDate + " " + value.getHourOfDay() + ":" + value.getMinute(); sb.append(" VALUE=\"" + formattedDateTime + "\"\n>"); ! sb.append(getWidgetRegistrationScript(idPrefix, false)); return sb.toString(); } Index: CustomModelTag.java =================================================================== RCS file: /cvsroot/jaffa/JaffaCore/source/java/org/jaffa/presentation/portlet/widgets/taglib/CustomModelTag.java,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** CustomModelTag.java 21 Oct 2005 14:28:50 -0000 1.8 --- CustomModelTag.java 18 Oct 2006 02:05:41 -0000 1.8.2.1 *************** *** 64,69 **** protected String m_htmlIdPrefix = null; protected String m_jaffaEventNamePrefix = null; ! ! /** Getter for the attribute field. * @return Value of attribute field. --- 64,69 ---- protected String m_htmlIdPrefix = null; protected String m_jaffaEventNamePrefix = null; ! ! /** Getter for the attribute field. * @return Value of attribute field. *************** *** 80,84 **** } ! /** Returns a unqiue string that can be used at the html id to identify this * widget */ --- 80,84 ---- } ! /** Returns a unqiue string that can be used at the html id to identify this * widget */ *************** *** 90,94 **** /** For the widget get the prefixed used for any callback events this method will call ! * This will be put in the eventId field and interpreted by the ActionBase to figure out * which widget to call back to. As widgets can have multiple events, the event name will be * added to this name. For nested fields (in grids, the ';' will be used as a field path seperator --- 90,94 ---- /** For the widget get the prefixed used for any callback events this method will call ! * This will be put in the eventId field and interpreted by the ActionBase to figure out * which widget to call back to. As widgets can have multiple events, the event name will be * added to this name. For nested fields (in grids, the ';' will be used as a field path seperator *************** *** 99,103 **** String addToPrefix = StringHelper.getUpper1( getField() ); if (eventPrefix == null || eventPrefix.length() == 0) ! m_jaffaEventNamePrefix = addToPrefix; else m_jaffaEventNamePrefix = eventPrefix + ';' + addToPrefix; --- 99,103 ---- String addToPrefix = StringHelper.getUpper1( getField() ); if (eventPrefix == null || eventPrefix.length() == 0) ! m_jaffaEventNamePrefix = addToPrefix; else m_jaffaEventNamePrefix = eventPrefix + ';' + addToPrefix; *************** *** 105,110 **** return m_jaffaEventNamePrefix; } ! ! /** This finally method cleans up any state in this base class. * There could be serious side effects if derived classes to not invoke this, --- 105,138 ---- return m_jaffaEventNamePrefix; } ! ! /** A convenience method which returns the javascript for registering the Tag with the global widgetCache, and with the RulesEngine. ! * The id for this Tag's parent is obtained from the TagHelper. ! * @param id The id for this tag. ! * @param registerWithRulesEngine If true, this tag will be registered with the javascript-RulesEngine. ! * @return the javascript for registering this tag. ! */ ! protected String getWidgetRegistrationScript(String id, boolean registerWithRulesEngine) { ! return getWidgetRegistrationScript(TagHelper.getParentNodeId(pageContext), id, registerWithRulesEngine); ! } ! ! /** A convenience method which returns the javascript for registering the Tag with the global widgetCache, and with the RulesEngine. ! * @param parentId The id for this Tag's parent. ! * @param id The id for this tag. ! * @param registerWithRulesEngine If true, this tag will be registered with the javascript-RulesEngine. ! * @return the javascript for registering this tag. ! */ ! protected String getWidgetRegistrationScript(String parentId, String id, boolean registerWithRulesEngine) { ! String parentNodeIdScript = parentId != null ? "document.getElementById('" + parentId + "')" : "null"; ! StringBuffer buf = new StringBuffer("<script>var tmp = document.getElementById('") ! .append(id) ! .append("');"); ! if (registerWithRulesEngine) ! buf.append("validationRules.addField(tmp);"); ! buf.append("registerWidget(tmp.form, ") ! .append(parentNodeIdScript) ! .append(", tmp);</script>\n"); ! return buf.toString(); ! } ! /** This finally method cleans up any state in this base class. * There could be serious side effects if derived classes to not invoke this, *************** *** 118,132 **** } ! public String toString() { ! if(m_field==null) ! return super.toString(); ! else { ! String x=super.toString(); ! return (new StringBuffer(x==null?"<??? ":x.substring(0,x.length()-2))) ! .append(" field='") ! .append(m_field) ! .append("'>") ! .toString(); ! } } } --- 146,160 ---- } ! public String toString() { ! if(m_field==null) ! return super.toString(); ! else { ! String x=super.toString(); ! return (new StringBuffer(x==null?"<??? ":x.substring(0,x.length()-2))) ! .append(" field='") ! .append(m_field) ! .append("'>") ! .toString(); ! } } } |