system/src/sc/lang/html/Element.java
public void addServerTags(ScopeDefinition scopeDef, ServerTagContext stCtx, boolean defaultServerTag) {
      if (replaceWith != null) {
         replaceWith.addServerTags(scopeDef, stCtx, defaultServerTag);
         return;
      }
      if (defaultServerTag || serverTag) {
         String tagId = getServerTagId();
         if (tagId != null) {
            ServerTag serverTagInfo = getServerTagInfo(tagId);
            if (serverTagInfo != null) {
               // This call only returns the server tags which need to be sent to the client.  All server tags though will be registered in the sync system
               if (serverTagInfo.eventSource || serverTagInfo.initScript != null || serverTagInfo.stopScript != null) {

                  stCtx.addServerTagInfo(tagId, serverTagInfo);
               }

               if (stCtx.serverTagTypes != null) {
                  stCtx.serverTagTypes.add(DynUtil.getTypeName(DynUtil.getType(this), false));
                  if (serverTag && !defaultServerTag) // These need to be added the first time only
                     stCtx.serverTagTypes.addAll(Arrays.asList("sc.js.ServerTagManager", "sc.js.ServerTag"));
               }

               if (scopeDef != null) {
                  ScopeContext scopeCtx = scopeDef.getScopeContext(true);
                  if (scopeCtx != null) {
                     Object oldValue = scopeCtx.getValue(tagId);
                     if (oldValue != null) {
                        if (oldValue != this) {
                           System.err.println("*** Conflicting value for tag id: " + tagId + " in scope: " + scopeDef.name);
                        }
                     }
                     else {
                        // Set the serverTag flag for elements where we did not set it during code-generation. Currently we only set the serverTag flag
                        // for the parent element in a tree of server tags but since it's inherited, sub-tags should get this flag set too so we set it
                        // here to avoid walking up the tree to determine if an element is a server tag or not.
                        this.serverTag = true;

                        // If the tag object class has its own synchronized properties, and it's a serverTag need to make sure the server tag properties
                        // are also synchronized. We don't have a way to easily do this at code-gen time and it's possible the same component is used
                        // without server tags
                        Object thisType = DynUtil.getType(this);
                        SyncProperties curProps = SyncManager.getSyncProperties(thisType, null);
                        if (curProps != null && !curProps.isSynced("innerHTML", false)) {
                           SyncProperties newProps = SyncProperties.appendProps(SyncManager.getSyncProperties(Element.class, null), curProps);
                           SyncManager.addSyncType(thisType, newProps);
                        }

                        // Even though this tag is already part of some ScopeContext, here we are adding it here by reference with it's tagId in the document.
                        // It seems to make sense to use the DOM id over the wire for readability and they are shorter although some of these ids
                        // are just the tag-name _ <ix>. By ref means it won't be disposed when this context is destroyed.
                        scopeCtx.setValueByRef(tagId, this);
                        // Register this with the sync system so we can apply changes made on the client and detect changes
                        // made on the server to send back to the client.  Using the DOM element id so the sync results are traceable
                        // and those should be unique cause they are already a global name space used by this page.
                        // TODO: if we have name conflicts, we could pass the DOM element id in the ServerTagInfo as well as the object name
                        SyncManager.registerSyncInst(this, null, tagId, scopeDef.scopeId, true);
                     }
                  }
               }
            }
         }
         else {
            // No id is normal for the 'repeat wrapper' class. We also get here for an object that is subclasses from Element
            // but that is not actually used as a tag object so in that case we also want to just skip this.
            //if (!(this instanceof IRepeatWrapper))
            //   System.out.println("*** null id for server tag");
            // else - TODO: is this a case we want to handle?
         }
         defaultServerTag = true;
      }
      Object[] children = getObjChildren(false);
      if (children != null) {
         for (Object child:children) {
            if (child instanceof Element) {
               ((Element) child).addServerTags(scopeDef, stCtx, defaultServerTag);
            }
         }
      }
   }
/**
    * Walks the tree represented by this element and adds or updates the server tag information necessary for this tag.
    * The scopeDef provided is the scope to store the server tag instances - usually 'window' for stateful pages but for
    * request pages, we need to store this in the request scope and re-create it from scratch on each request.
    */
Walks the tree represented by this element and adds or updates the server tag information necessary for this tag.
The scopeDef provided is the scope to store the server tag instances - usually 'window' for stateful pages but for
request pages, we need to store this in the request scope and re-create it from scratch on each request.
Walks the tree represented by this element and adds or updates the server tag information necessary for this tag . The scopeDef provided is the scope to store the server tag instances - usually ' window ' for stateful pages but for request pages we need to store this in the request scope and re - create it from scratch on each request .
public void addServerTags(ScopeDefinition scopeDef, ServerTagContext stCtx, boolean defaultServerTag) {
      if (replaceWith != null) {
         replaceWith.addServerTags(scopeDef, stCtx, defaultServerTag);
         return;
      }
      if (defaultServerTag || serverTag) {
         String tagId = getServerTagId();
         if (tagId != null) {
            ServerTag serverTagInfo = getServerTagInfo(tagId);
            if (serverTagInfo != null) {
               if (serverTagInfo.eventSource || serverTagInfo.initScript != null || serverTagInfo.stopScript != null) {
                  stCtx.addServerTagInfo(tagId, serverTagInfo);
               }
               if (stCtx.serverTagTypes != null) {
                  stCtx.serverTagTypes.add(DynUtil.getTypeName(DynUtil.getType(this), false));
                  if (serverTag && !defaultServerTag) 
                     stCtx.serverTagTypes.addAll(Arrays.asList("sc.js.ServerTagManager", "sc.js.ServerTag"));
               }
               if (scopeDef != null) {
                  ScopeContext scopeCtx = scopeDef.getScopeContext(true);
                  if (scopeCtx != null) {
                     Object oldValue = scopeCtx.getValue(tagId);
                     if (oldValue != null) {
                        if (oldValue != this) {
                           System.err.println("*** Conflicting value for tag id: " + tagId + " in scope: " + scopeDef.name);
                        }
                     }
                     else {
                        this.serverTag = true;
                        Object thisType = DynUtil.getType(this);
                        SyncProperties curProps = SyncManager.getSyncProperties(thisType, null);
                        if (curProps != null && !curProps.isSynced("innerHTML", false)) {
                           SyncProperties newProps = SyncProperties.appendProps(SyncManager.getSyncProperties(Element.class, null), curProps);
                           SyncManager.addSyncType(thisType, newProps);
                        }
                        scopeCtx.setValueByRef(tagId, this);
                        SyncManager.registerSyncInst(this, null, tagId, scopeDef.scopeId, true);
                     }
                  }
               }
            }
         }
         else {
         }
         defaultServerTag = true;
      }
      Object[] children = getObjChildren(false);
      if (children != null) {
         for (Object child:children) {
            if (child instanceof Element) {
               ((Element) child).addServerTags(scopeDef, stCtx, defaultServerTag);
            }
         }
      }
   }
public void addServerTags ( ScopeDefinition scopeDef , ServerTagContext stCtx , boolean defaultServerTag ) { if ( replaceWith != null ) { replaceWith . addServerTags ( scopeDef , stCtx , defaultServerTag ) ; return ; } if ( defaultServerTag || serverTag ) { String tagId = getServerTagId ( ) ; if ( tagId != null ) { ServerTag serverTagInfo = getServerTagInfo ( tagId ) ; if ( serverTagInfo != null ) { if ( serverTagInfo . eventSource || serverTagInfo . initScript != null || serverTagInfo . stopScript != null ) { stCtx . addServerTagInfo ( tagId , serverTagInfo ) ; } if ( stCtx . serverTagTypes != null ) { stCtx . serverTagTypes . add ( DynUtil . getTypeName ( DynUtil . getType ( this ) , false ) ) ; if ( serverTag && ! defaultServerTag ) stCtx . serverTagTypes . addAll ( Arrays . asList ( "sc.js.ServerTagManager" , "sc.js.ServerTag" ) ) ; } if ( scopeDef != null ) { ScopeContext scopeCtx = scopeDef . getScopeContext ( true ) ; if ( scopeCtx != null ) { Object oldValue = scopeCtx . getValue ( tagId ) ; if ( oldValue != null ) { if ( oldValue != this ) { System . err . println ( "*** Conflicting value for tag id: " + tagId + " in scope: " + scopeDef . name ) ; } } else { this . serverTag = true ; Object thisType = DynUtil . getType ( this ) ; SyncProperties curProps = SyncManager . getSyncProperties ( thisType , null ) ; if ( curProps != null && ! curProps . isSynced ( "innerHTML" , false ) ) { SyncProperties newProps = SyncProperties . appendProps ( SyncManager . getSyncProperties ( Element . class , null ) , curProps ) ; SyncManager . addSyncType ( thisType , newProps ) ; } scopeCtx . setValueByRef ( tagId , this ) ; SyncManager . registerSyncInst ( this , null , tagId , scopeDef . scopeId , true ) ; } } } } } else { } defaultServerTag = true ; } Object [ ] children = getObjChildren ( false ) ; if ( children != null ) { for ( Object child : children ) { if ( child instanceof Element ) { ( ( Element ) child ) . addServerTags ( scopeDef , stCtx , defaultServerTag ) ; } } } }
Walks the tree represented by this element and adds or updates the server tag information necessary for this tag.
Walks the tree represented by this element and adds or updates the server tag information necessary for this tag .
// This call only returns the server tags which need to be sent to the client.  All server tags though will be registered in the sync system // These need to be added the first time only // Set the serverTag flag for elements where we did not set it during code-generation. Currently we only set the serverTag flag // for the parent element in a tree of server tags but since it's inherited, sub-tags should get this flag set too so we set it // here to avoid walking up the tree to determine if an element is a server tag or not. // If the tag object class has its own synchronized properties, and it's a serverTag need to make sure the server tag properties // are also synchronized. We don't have a way to easily do this at code-gen time and it's possible the same component is used // without server tags // Even though this tag is already part of some ScopeContext, here we are adding it here by reference with it's tagId in the document. // It seems to make sense to use the DOM id over the wire for readability and they are shorter although some of these ids // are just the tag-name _ <ix>. By ref means it won't be disposed when this context is destroyed. // Register this with the sync system so we can apply changes made on the client and detect changes // made on the server to send back to the client.  Using the DOM element id so the sync results are traceable // and those should be unique cause they are already a global name space used by this page. // TODO: if we have name conflicts, we could pass the DOM element id in the ServerTagInfo as well as the object name // No id is normal for the 'repeat wrapper' class. We also get here for an object that is subclasses from Element // but that is not actually used as a tag object so in that case we also want to just skip this. //if (!(this instanceof IRepeatWrapper)) //   System.out.println("*** null id for server tag"); // else - TODO: is this a case we want to handle?