CVS: Tapestry/framework/src/net/sf/tapestry/pageload PageLoader.java,1.15.2.9,1.15.2.10

Howard Lewis Ship <[email protected]>
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/pageload
In directory sc8-pr-cvs1:/tmp/cvs-serv9593/framework/src/net/sf/tapestry/pageload

Modified Files:
      Tag: hship-2-3
	PageLoader.java 
Log Message:
Support 1.4 specification DTD, where the class in pages and components is optional.

Index: PageLoader.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/pageload/PageLoader.java,v
retrieving revision 1.15.2.9
retrieving revision 1.15.2.10
diff -C2 -d -r1.15.2.9 -r1.15.2.10
*** PageLoader.java	30 Dec 2002 03:04:57 -0000	1.15.2.9
--- PageLoader.java	2 Jan 2003 03:11:23 -0000	1.15.2.10
***************
*** 15,18 ****
--- 15,19 ----
  
  import net.sf.tapestry.ApplicationRuntimeException;
+ import net.sf.tapestry.BaseComponent;
  import net.sf.tapestry.IAsset;
  import net.sf.tapestry.IBinding;
***************
*** 33,36 ****
--- 34,38 ----
  import net.sf.tapestry.binding.ExpressionBinding;
  import net.sf.tapestry.binding.StringBinding;
+ import net.sf.tapestry.html.BasePage;
  import net.sf.tapestry.resolver.ComponentSpecificationResolver;
  import net.sf.tapestry.resource.ContextResourceLocation;
***************
*** 463,498 ****
  
          String className = spec.getComponentClassName();
-         Class componentClass = _resolver.findClass(className);
  
!         try
!         {
!             result = (IComponent) componentClass.newInstance();
! 
!             result.setNamespace(namespace);
!             result.setSpecification(spec);
!             result.setPage(page);
!             result.setContainer(container);
!             result.setId(id);
! 
!         }
!         catch (ClassCastException ex)
          {
!             throw new PageLoaderException(
!                 Tapestry.getString("PageLoader.class-not-component", className),
!                 container,
!                 ex);
          }
!         catch (Exception ex)
          {
!             throw new PageLoaderException(
!                 Tapestry.getString("PageLoader.unable-to-instantiate", className),
!                 container,
!                 ex);
          }
  
!         if (result instanceof IPage)
!             throw new PageLoaderException(
!                 Tapestry.getString("PageLoader.page-not-allowed", result.getExtendedId()),
!                 result);
  
          _count++;
--- 465,510 ----
  
          String className = spec.getComponentClassName();
  
!         if (Tapestry.isNull(className))
          {
!             result = new BaseComponent();
          }
!         else
          {
! 
!             Class componentClass = _resolver.findClass(className);
! 
!             try
!             {
!                 result = (IComponent) componentClass.newInstance();
! 
!             }
!             catch (ClassCastException ex)
!             {
!                 throw new PageLoaderException(
!                     Tapestry.getString("PageLoader.class-not-component", className),
!                     container,
!                     ex);
!             }
!             catch (Exception ex)
!             {
!                 throw new PageLoaderException(
!                     Tapestry.getString("PageLoader.unable-to-instantiate", className),
!                     container,
!                     ex);
!             }
! 
!             if (result instanceof IPage)
!                 throw new PageLoaderException(
!                     Tapestry.getString("PageLoader.page-not-allowed", result.getExtendedId()),
!                     result);
! 
          }
  
!         result.setNamespace(namespace);
!         result.setSpecification(spec);
!         result.setPage(page);
!         result.setContainer(container);
!         result.setId(id);
  
          _count++;
***************
*** 520,524 ****
--- 532,552 ----
          IPage result = null;
  
+         String pageName = namespace.constructQualifiedName(name);
          String className = spec.getComponentClassName();
+ 
+         if (Tapestry.isNull(className))
+         {
+             if (LOG.isDebugEnabled())
+                 LOG.debug("Page " + namespace.constructQualifiedName(name) + " does not specify a component class.");
+ 
+             className = _engine.getPropertySource().getPropertyValue("net.sf.tapestry.default-page-class");
+ 
+             if (className == null)
+                 className = BasePage.class.getName();
+ 
+             if (LOG.isDebugEnabled())
+                 LOG.debug("Instantiating as class " + className);
+         }
+ 
          Class pageClass = _resolver.findClass(className);
  
***************
*** 530,534 ****
              result.setSpecification(spec);
              result.setName(name);
!             result.setPageName(namespace.constructQualifiedName(name));
              result.setLocale(_locale);
          }
--- 558,562 ----
              result.setSpecification(spec);
              result.setName(name);
!             result.setPageName(pageName);
              result.setLocale(_locale);
          }



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.