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

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-serv2336/framework/src/net/sf/tapestry/pageload

Modified Files:
      Tag: hship-2-3
	PageLoader.java 
Log Message:
Add support for <listener-binding>.
Use a ResourceBundle for "factory default" configuration properties.

Index: PageLoader.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/pageload/PageLoader.java,v
retrieving revision 1.15.2.10
retrieving revision 1.15.2.11
diff -C2 -d -r1.15.2.10 -r1.15.2.11
*** PageLoader.java	2 Jan 2003 03:11:23 -0000	1.15.2.10
--- PageLoader.java	4 Jan 2003 02:46:49 -0000	1.15.2.11
***************
*** 33,36 ****
--- 33,37 ----
  import net.sf.tapestry.Tapestry;
  import net.sf.tapestry.binding.ExpressionBinding;
+ import net.sf.tapestry.binding.ListenerBinding;
  import net.sf.tapestry.binding.StringBinding;
  import net.sf.tapestry.html.BasePage;
***************
*** 43,46 ****
--- 44,48 ----
  import net.sf.tapestry.spec.ComponentSpecification;
  import net.sf.tapestry.spec.ContainedComponent;
+ import net.sf.tapestry.spec.ListenerBindingSpecification;
  import net.sf.tapestry.spec.ParameterSpecification;
  
***************
*** 209,215 ****
              // As a nested property name (relative to the component)
              // As the name of a binding inherited from the containing component.
  
              BindingType type = bspec.getType();
-             String bindingValue = bspec.getValue();
  
              // For inherited bindings, defer until later.  This gives components
--- 211,218 ----
              // As a nested property name (relative to the component)
              // As the name of a binding inherited from the containing component.
+             // As the name of a public field
+             // As a script for a listener
  
              BindingType type = bspec.getType();
  
              // For inherited bindings, defer until later.  This gives components
***************
*** 220,229 ****
              if (type == BindingType.INHERITED)
              {
!                 QueuedInheritedBinding queued = new QueuedInheritedBinding(component, bindingValue, name);
                  _inheritedBindingQueue.add(queued);
                  continue;
              }
  
!             IBinding binding = convert(type, bindingValue, container, propertyBindings);
  
              if (binding != null)
--- 223,238 ----
              if (type == BindingType.INHERITED)
              {
!                 QueuedInheritedBinding queued = new QueuedInheritedBinding(component, bspec.getValue(), name);
                  _inheritedBindingQueue.add(queued);
                  continue;
              }
  
!             if (type == BindingType.LISTENER)
!             {
!                 constructListenerBinding(component, name, (ListenerBindingSpecification) bspec);
!                 continue;
!             }
! 
!             IBinding binding = convert(type, bspec.getValue(), container, propertyBindings);
  
              if (binding != null)
***************
*** 307,310 ****
--- 316,322 ----
              return _pageSource.getStaticBinding(bindingValue);
  
+         // BindingType.FIELD is on the way out, it is in the
+         // 1.3 DTD but not the 1.4 DTD.
+ 
          if (type == BindingType.FIELD)
              return _pageSource.getFieldBinding(bindingValue);
***************
*** 314,317 ****
--- 326,353 ----
  
          throw new ApplicationRuntimeException("Unexpected type: " + type + ".");
+     }
+ 
+     /**
+      *  Construct a {@link ListenerBinding} for the component, and add it.
+      * 
+      *  @since 2.4
+      * 
+      **/
+     
+     private void constructListenerBinding(IComponent component, String bindingName, ListenerBindingSpecification spec)
+     {
+         String location = Tapestry.getString("PageLoader.script-location", bindingName, component.getExtendedId());
+ 
+         String language = spec.getLanguage();
+         
+         // If not provided in the page or component specification, then
+         // search for a default (factory default is "jython").
+         
+         if (Tapestry.isNull(language))
+             language = _engine.getPropertySource().getPropertyValue("net.sf.tapestry.default-script-language");
+             
+         IBinding binding = new ListenerBinding(component, language, location, spec.getScript());
+ 
+         component.setBinding(bindingName, binding);
      }
  



-------------------------------------------------------
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.