Skip to content

Commit aa6e999

Browse files
Start planning for element namespacing
1 parent f4d6190 commit aa6e999

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

ng-appserver/src/main/java/ng/appserver/elements/NGSwitchComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import ng.appserver.NGElement;
1515
import ng.appserver.NGRequest;
1616
import ng.appserver.NGResponse;
17+
import ng.appserver.templating.NGElementManager;
1718

1819
/**
1920
* Implementation based on Project Wonder's ERXWOSwitchComponent by
@@ -83,7 +84,7 @@ public NGElement _realComponentWithName( final String name, final String element
8384

8485
// No component instance found so we're going to have to construct a new one
8586
if( localWOElement == null ) {
86-
localWOElement = NGApplication.application().elementManager().dynamicElementWithName( name, _componentAssociations, _contentTemplate );
87+
localWOElement = NGApplication.application().elementManager().dynamicElementWithName( NGElementManager.GLOBAL_UNNAMESPACED_NAMESPACE, name, _componentAssociations, _contentTemplate );
8788

8889
if( localWOElement == null ) {
8990
throw new RuntimeException( "<" + getClass().getName() + "> : cannot find component or dynamic element named " + name );

ng-appserver/src/main/java/ng/appserver/templating/NGElementManager.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,20 @@
1313
import ng.appserver.NGElement;
1414
import ng.appserver.NGElementUtils;
1515

16+
/**
17+
* Manages access to and location of dynamic elements and components registered with a project
18+
*/
19+
1620
public class NGElementManager {
1721

22+
/**
23+
* I WO, elements are not namespaced. To help porting older templates, we therefore allow unnamespaced elements
24+
* by designating the namespace "wo" a "magic namespace" which when used for locating elements means searching every namespace.
25+
*
26+
* This is probably/hopefully temporary.
27+
*/
28+
public static final String GLOBAL_UNNAMESPACED_NAMESPACE = "wo";
29+
1830
/**
1931
* @return The named component, where [componentName] can be either the component's simple class name or full class name.
2032
*/
@@ -73,7 +85,7 @@ private static NGComponentDefinition componentDefinition( final String component
7385
*
7486
* FIXME: We're missing a cache for dynamic element name resolution // Hugi 2025-03-05
7587
*/
76-
public static NGDynamicElement dynamicElementWithName( final String elementIdentifier, final Map<String, NGAssociation> associations, final NGElement contentTemplate ) {
88+
public static NGDynamicElement dynamicElementWithName( final String namespace, final String elementIdentifier, final Map<String, NGAssociation> associations, final NGElement contentTemplate ) {
7789
Objects.requireNonNull( elementIdentifier );
7890
Objects.requireNonNull( associations );
7991

ng-appserver/src/main/java/ng/appserver/templating/NGTemplateParserProxy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static NGElement toDynamicElement( final PBasicNode node ) {
7373
final NGElement childTemplate = toTemplate( node.children() );
7474

7575
try {
76-
return NGApplication.application().elementManager().dynamicElementWithName( type, associations, childTemplate );
76+
return NGApplication.application().elementManager().dynamicElementWithName( NGElementManager.GLOBAL_UNNAMESPACED_NAMESPACE, type, associations, childTemplate );
7777
}
7878
catch( NGElementNotFoundException e ) {
7979
// FIXME: Experimental functionality, probably doesn't belong with the parser part of the framework.

0 commit comments

Comments
 (0)