You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2003/11/18 17:51:23 UTC

ExpressionBinding type conversion patch

I know I'm a committer, but this is my first change to Tapestry's  
actual functionality... so being a good citizen, I'm asking if the  
below patch is ok to commit or not.  I've tested in on our system and  
it works wonderfully.

The dilemma is that a configured TypeConverter would not be used when  
OgnlUtils is used directly, only for expression bindings.  This is ok  
for our current needs though.

Anyone object to this patch being made?

Thanks,
	Erik


RCS file:  
/home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/binding/ 
ExpressionBinding.java,v
retrieving revision 1.8
diff -u -w -b -r1.8 ExpressionBinding.java
---  
framework/src/org/apache/tapestry/binding/ExpressionBinding.java   4  
Nov 200315:09:37-0000  1.8
+++  
framework/src/org/apache/tapestry/binding/ExpressionBinding.java   18  
Nov 200316:34:58-0000
     private Map getOgnlContext()

     {
-        if (_context == null)
+        if (_context == null) {
             _context = Ognl.createDefaultContext(_root, _resolver);
+        }
+
+        IApplicationSpecification appSpec =  
_root.getPage().getEngine().getSpecification();
+        if (appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) {
+            TypeConverter typeConverter = (TypeConverter)  
appSpec.getExtension(Tapestry.OGNL_TYPE_CONVERTER, null);
+            Ognl.setTypeConverter(_context, typeConverter);
+        }

         return _context;
     }

Index: framework/src/org/apache/tapestry/Tapestry.java
     /**
+     * Class name of an {@link ognl.TypeConverter} implementing class
+     * to use as a type converter for {@link  
org.apache.tapestry.binding.ExpressionBinding}
+     */
+    public static final String OGNL_TYPE_CONVERTER =
+        "org.apache.tapestry.ognl-type-converter";
+


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: ExpressionBinding type conversion patch

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Tuesday, November 18, 2003, at 02:06  PM, Erik Hatcher wrote:
> On Tuesday, November 18, 2003, at 12:08  PM, Howard M. Lewis Ship 
> wrote:
>> I'd like to see a unit test related to this change.
>
> Sure, no problem.... except that running 'ant junit' gives me several 
> failures already (I haven't added a test case yet, just running from 
> HEAD of CVS).  The errors, ironically, are mostly in TestBindings 
> (unable to resolve 'page' in testExpressionBinding, and some others).

Ok, nevermind.... the errors in TestBindings was directly related to my 
changes causing an NPE because it couldn't get an 
IApplicationSpecification, which is due to the minimal mock environment 
during the tests.  So, writing a test was good!

But, in ExpressionBinding, there are several catch (Exception e), which 
really should be catch (OgnlException e) I think.  Or should we really 
be catching NullPointerException and wrapping it into a 
BindingException?


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: ExpressionBinding type conversion patch

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Tuesday, November 18, 2003, at 12:08  PM, Howard M. Lewis Ship wrote:
> I'd like to see a unit test related to this change.

Sure, no problem.... except that running 'ant junit' gives me several 
failures already (I haven't added a test case yet, just running from 
HEAD of CVS).  The errors, ironically, are mostly in TestBindings 
(unable to resolve 'page' in testExpressionBinding, and some others).

Are the test cases running green for everyone else?

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: ExpressionBinding type conversion patch

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Tuesday, November 18, 2003, at 03:24  PM, Erik Hatcher wrote:
> I added this to TestBindings.  Some other changes I made locally worth 
> noting:
>
> - added dateValue to BoundPage with setters/getters appropriately that 
> is of type java.sql.Timestamp
> - Modified MockEngine to have a setSpecification and modified the 
> getter to return what was set
> - Created MockApplicationSpecification which just has a dummy backing 
> Map to contain extensions and modified the checkExtensions and 
> getExtension methods to deal with the Map set with the setExtensions 
> method.
>
> Test worked just fine and I got the expected errors when I was 
> developing the test without the try/catch in there.
>
> So, whatcha think?

I committed all the Mock* stuff that I added/modified to get the test 
case to pass.  None of those changes break anything, just enhance the 
mock capabilities.  I figured it was easier to commit that stuff for 
you to see first hand.  My commit includes the MockTypeConverter which 
does special Date->Timestamp conversion.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: ExpressionBinding type conversion patch

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Monday, November 24, 2003, at 07:32  AM, Howard M. Lewis Ship wrote:
> Looks fine to me, with the test case. The Tapestry user's guide has a 
> section about configuration
> where we define all these extension points.

I documented it and committed it.  I just sent a follow-up message 
about a change I made to some exception handling in there, why may be 
incorrect - so please double-check that and let me know.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


RE: ExpressionBinding type conversion patch

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Looks fine to me, with the test case. The Tapestry user's guide has a section about configuration
where we define all these extension points.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
> Sent: Sunday, November 23, 2003 11:48 PM
> To: Tapestry development
> Subject: Re: ExpressionBinding type conversion patch
> 
> 
> Is my ExpressionBinding patch acceptable to commit?
> 
> If so, where should I document the additional extension point?  (I'll 
> search for the other special extension points and see where they are 
> mentioned and document there, just thought I'd ask in case 
> there was a 
> place I might miss)
> 
> On Tuesday, November 18, 2003, at 12:24  PM, Erik Hatcher wrote:
> >
> > On Tuesday, November 18, 2003, at 12:08  PM, Howard M. Lewis Ship 
> > wrote:
> >> I'd like to see a unit test related to this change.
> >
> > Ok, here ya go...
> >
> >     public void testTypeConverter() {
> >         BoundPage page = new BoundPage();
> >         page.setEngine(new MockEngine());
> >
> >         ExpressionBinding binding = new 
> ExpressionBinding(_resolver, 
> > page, "dateValue", null);
> >         Date date = new Date();
> >
> >         try {
> >             // try without a converter first, which should fail
> >             binding.setObject(date);
> >             fail("Should not be able to call setDateValue(Date)");
> >         }
> >         catch (BindingException expected) {
> >             assertTrue(true);
> >         }
> >
> >         // now test with a custom converter enabled
> >         MockEngine engine = (MockEngine) page.getEngine();
> >         MockApplicationSpecification appSpec = new 
> > MockApplicationSpecification();
> >         HashMap extensions = new HashMap();
> >         extensions.put(Tapestry.OGNL_TYPE_CONVERTER, new 
> > MockTypeConverter());
> >         appSpec.setExtensions(extensions);
> >         engine.setSpecification(appSpec);
> >
> >         binding.setObject(date);
> >         assertEquals(date, page.getDateValue());
> >     }
> >
> > I added this to TestBindings.  Some other changes I made 
> locally worth 
> > noting:
> >
> > - added dateValue to BoundPage with setters/getters 
> appropriately that 
> > is of type java.sql.Timestamp
> > - Modified MockEngine to have a setSpecification and modified the 
> > getter to return what was set
> > - Created MockApplicationSpecification which just has a 
> dummy backing 
> > Map to contain extensions and modified the checkExtensions and 
> > getExtension methods to deal with the Map set with the 
> setExtensions 
> > method.
> >
> > Test worked just fine and I got the expected errors when I was 
> > developing the test without the try/catch in there.
> >
> > So, whatcha think?
> >
> > 	Erik
> >
> >
> >>
> >> --
> >> Howard M. Lewis Ship
> >> Creator, Tapestry: Java Web Components
> >> http://jakarta.apache.org/tapestry
> >> http://jakarta.apache.org/commons/sandbox/hivemind/
> >> http://javatapestry.blogspot.com
> >>
> >>> -----Original Message-----
> >>> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> >>> Sent: Tuesday, November 18, 2003 8:51 AM
> >>> To: tapestry-dev@jakarta.apache.org
> >>> Subject: ExpressionBinding type conversion patch
> >>>
> >>>
> >>> I know I'm a committer, but this is my first change to Tapestry's
> >>> actual functionality... so being a good citizen, I'm asking if the
> >>> below patch is ok to commit or not.  I've tested in on our
> >>> system and
> >>> it works wonderfully.
> >>>
> >>> The dilemma is that a configured TypeConverter would not be
> >>> used when
> >>> OgnlUtils is used directly, only for expression bindings.
> >>> This is ok
> >>> for our current needs though.
> >>>
> >>> Anyone object to this patch being made?
> >>>
> >>> Thanks,
> >>> 	Erik
> >>>
> >>>
> >>> RCS file:
> >>> 
> /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/binding/
> >>> ExpressionBinding.java,v
> >>> retrieving revision 1.8
> >>> diff -u -w -b -r1.8 ExpressionBinding.java
> >>> ---
> >>> 
> framework/src/org/apache/tapestry/binding/ExpressionBinding.java   4
> >>> Nov 200315:09:37-0000  1.8
> >>> +++
> >>> framework/src/org/apache/tapestry/binding/ExpressionBinding.ja
> >>> va   18
> >>> Nov 200316:34:58-0000
> >>>      private Map getOgnlContext()
> >>>
> >>>      {
> >>> -        if (_context == null)
> >>> +        if (_context == null) {
> >>>              _context = Ognl.createDefaultContext(_root, 
> _resolver);
> >>> +        }
> >>> +
> >>> +        IApplicationSpecification appSpec =
> >>> _root.getPage().getEngine().getSpecification();
> >>> +        if 
> (appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) {
> >>> +            TypeConverter typeConverter = (TypeConverter)
> >>> appSpec.getExtension(Tapestry.OGNL_TYPE_CONVERTER, null);
> >>> +            Ognl.setTypeConverter(_context, typeConverter);
> >>> +        }
> >>>
> >>>          return _context;
> >>>      }
> >>>
> >>> Index: framework/src/org/apache/tapestry/Tapestry.java
> >>>      /**
> >>> +     * Class name of an {@link ognl.TypeConverter} implementing 
> >>> class
> >>> +     * to use as a type converter for {@link
> >>> org.apache.tapestry.binding.ExpressionBinding}
> >>> +     */
> >>> +    public static final String OGNL_TYPE_CONVERTER =
> >>> +        "org.apache.tapestry.ognl-type-converter";
> >>> +
> >>>
> >>>
> >>> 
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: 
> tapestry-dev-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail: 
> tapestry-dev-help@jakarta.apache.org
> >>>
> >>
> >>
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: 
> tapestry-dev-help@jakarta.apache.org
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> tapestry-dev-help@jakarta.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: ExpressionBinding type conversion patch

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Is my ExpressionBinding patch acceptable to commit?

If so, where should I document the additional extension point?  (I'll 
search for the other special extension points and see where they are 
mentioned and document there, just thought I'd ask in case there was a 
place I might miss)

On Tuesday, November 18, 2003, at 12:24  PM, Erik Hatcher wrote:
>
> On Tuesday, November 18, 2003, at 12:08  PM, Howard M. Lewis Ship 
> wrote:
>> I'd like to see a unit test related to this change.
>
> Ok, here ya go...
>
>     public void testTypeConverter() {
>         BoundPage page = new BoundPage();
>         page.setEngine(new MockEngine());
>
>         ExpressionBinding binding = new ExpressionBinding(_resolver, 
> page, "dateValue", null);
>         Date date = new Date();
>
>         try {
>             // try without a converter first, which should fail
>             binding.setObject(date);
>             fail("Should not be able to call setDateValue(Date)");
>         }
>         catch (BindingException expected) {
>             assertTrue(true);
>         }
>
>         // now test with a custom converter enabled
>         MockEngine engine = (MockEngine) page.getEngine();
>         MockApplicationSpecification appSpec = new 
> MockApplicationSpecification();
>         HashMap extensions = new HashMap();
>         extensions.put(Tapestry.OGNL_TYPE_CONVERTER, new 
> MockTypeConverter());
>         appSpec.setExtensions(extensions);
>         engine.setSpecification(appSpec);
>
>         binding.setObject(date);
>         assertEquals(date, page.getDateValue());
>     }
>
> I added this to TestBindings.  Some other changes I made locally worth 
> noting:
>
> - added dateValue to BoundPage with setters/getters appropriately that 
> is of type java.sql.Timestamp
> - Modified MockEngine to have a setSpecification and modified the 
> getter to return what was set
> - Created MockApplicationSpecification which just has a dummy backing 
> Map to contain extensions and modified the checkExtensions and 
> getExtension methods to deal with the Map set with the setExtensions 
> method.
>
> Test worked just fine and I got the expected errors when I was 
> developing the test without the try/catch in there.
>
> So, whatcha think?
>
> 	Erik
>
>
>>
>> --
>> Howard M. Lewis Ship
>> Creator, Tapestry: Java Web Components
>> http://jakarta.apache.org/tapestry
>> http://jakarta.apache.org/commons/sandbox/hivemind/
>> http://javatapestry.blogspot.com
>>
>>> -----Original Message-----
>>> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
>>> Sent: Tuesday, November 18, 2003 8:51 AM
>>> To: tapestry-dev@jakarta.apache.org
>>> Subject: ExpressionBinding type conversion patch
>>>
>>>
>>> I know I'm a committer, but this is my first change to Tapestry's
>>> actual functionality... so being a good citizen, I'm asking if the
>>> below patch is ok to commit or not.  I've tested in on our
>>> system and
>>> it works wonderfully.
>>>
>>> The dilemma is that a configured TypeConverter would not be
>>> used when
>>> OgnlUtils is used directly, only for expression bindings.
>>> This is ok
>>> for our current needs though.
>>>
>>> Anyone object to this patch being made?
>>>
>>> Thanks,
>>> 	Erik
>>>
>>>
>>> RCS file:
>>> /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/binding/
>>> ExpressionBinding.java,v
>>> retrieving revision 1.8
>>> diff -u -w -b -r1.8 ExpressionBinding.java
>>> ---
>>> framework/src/org/apache/tapestry/binding/ExpressionBinding.java   4
>>> Nov 200315:09:37-0000  1.8
>>> +++
>>> framework/src/org/apache/tapestry/binding/ExpressionBinding.ja
>>> va   18
>>> Nov 200316:34:58-0000
>>>      private Map getOgnlContext()
>>>
>>>      {
>>> -        if (_context == null)
>>> +        if (_context == null) {
>>>              _context = Ognl.createDefaultContext(_root, _resolver);
>>> +        }
>>> +
>>> +        IApplicationSpecification appSpec =
>>> _root.getPage().getEngine().getSpecification();
>>> +        if (appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) {
>>> +            TypeConverter typeConverter = (TypeConverter)
>>> appSpec.getExtension(Tapestry.OGNL_TYPE_CONVERTER, null);
>>> +            Ognl.setTypeConverter(_context, typeConverter);
>>> +        }
>>>
>>>          return _context;
>>>      }
>>>
>>> Index: framework/src/org/apache/tapestry/Tapestry.java
>>>      /**
>>> +     * Class name of an {@link ognl.TypeConverter} implementing 
>>> class
>>> +     * to use as a type converter for {@link
>>> org.apache.tapestry.binding.ExpressionBinding}
>>> +     */
>>> +    public static final String OGNL_TYPE_CONVERTER =
>>> +        "org.apache.tapestry.ognl-type-converter";
>>> +
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


Re: ExpressionBinding type conversion patch

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Tuesday, November 18, 2003, at 12:08  PM, Howard M. Lewis Ship wrote:
> I'd like to see a unit test related to this change.

Ok, here ya go...

     public void testTypeConverter() {
         BoundPage page = new BoundPage();
         page.setEngine(new MockEngine());

         ExpressionBinding binding = new ExpressionBinding(_resolver, 
page, "dateValue", null);
         Date date = new Date();

         try {
             // try without a converter first, which should fail
             binding.setObject(date);
             fail("Should not be able to call setDateValue(Date)");
         }
         catch (BindingException expected) {
             assertTrue(true);
         }

         // now test with a custom converter enabled
         MockEngine engine = (MockEngine) page.getEngine();
         MockApplicationSpecification appSpec = new 
MockApplicationSpecification();
         HashMap extensions = new HashMap();
         extensions.put(Tapestry.OGNL_TYPE_CONVERTER, new 
MockTypeConverter());
         appSpec.setExtensions(extensions);
         engine.setSpecification(appSpec);

         binding.setObject(date);
         assertEquals(date, page.getDateValue());
     }

I added this to TestBindings.  Some other changes I made locally worth 
noting:

- added dateValue to BoundPage with setters/getters appropriately that 
is of type java.sql.Timestamp
- Modified MockEngine to have a setSpecification and modified the 
getter to return what was set
- Created MockApplicationSpecification which just has a dummy backing 
Map to contain extensions and modified the checkExtensions and 
getExtension methods to deal with the Map set with the setExtensions 
method.

Test worked just fine and I got the expected errors when I was 
developing the test without the try/catch in there.

So, whatcha think?

	Erik


>
> --
> Howard M. Lewis Ship
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry
> http://jakarta.apache.org/commons/sandbox/hivemind/
> http://javatapestry.blogspot.com
>
>> -----Original Message-----
>> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
>> Sent: Tuesday, November 18, 2003 8:51 AM
>> To: tapestry-dev@jakarta.apache.org
>> Subject: ExpressionBinding type conversion patch
>>
>>
>> I know I'm a committer, but this is my first change to Tapestry's
>> actual functionality... so being a good citizen, I'm asking if the
>> below patch is ok to commit or not.  I've tested in on our
>> system and
>> it works wonderfully.
>>
>> The dilemma is that a configured TypeConverter would not be
>> used when
>> OgnlUtils is used directly, only for expression bindings.
>> This is ok
>> for our current needs though.
>>
>> Anyone object to this patch being made?
>>
>> Thanks,
>> 	Erik
>>
>>
>> RCS file:
>> /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/binding/
>> ExpressionBinding.java,v
>> retrieving revision 1.8
>> diff -u -w -b -r1.8 ExpressionBinding.java
>> ---
>> framework/src/org/apache/tapestry/binding/ExpressionBinding.java   4
>> Nov 200315:09:37-0000  1.8
>> +++
>> framework/src/org/apache/tapestry/binding/ExpressionBinding.ja
>> va   18
>> Nov 200316:34:58-0000
>>      private Map getOgnlContext()
>>
>>      {
>> -        if (_context == null)
>> +        if (_context == null) {
>>              _context = Ognl.createDefaultContext(_root, _resolver);
>> +        }
>> +
>> +        IApplicationSpecification appSpec =
>> _root.getPage().getEngine().getSpecification();
>> +        if (appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) {
>> +            TypeConverter typeConverter = (TypeConverter)
>> appSpec.getExtension(Tapestry.OGNL_TYPE_CONVERTER, null);
>> +            Ognl.setTypeConverter(_context, typeConverter);
>> +        }
>>
>>          return _context;
>>      }
>>
>> Index: framework/src/org/apache/tapestry/Tapestry.java
>>      /**
>> +     * Class name of an {@link ognl.TypeConverter} implementing class
>> +     * to use as a type converter for {@link
>> org.apache.tapestry.binding.ExpressionBinding}
>> +     */
>> +    public static final String OGNL_TYPE_CONVERTER =
>> +        "org.apache.tapestry.ognl-type-converter";
>> +
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org


RE: ExpressionBinding type conversion patch

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
I'd like to see a unit test related to this change.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
http://jakarta.apache.org/commons/sandbox/hivemind/
http://javatapestry.blogspot.com

> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com] 
> Sent: Tuesday, November 18, 2003 8:51 AM
> To: tapestry-dev@jakarta.apache.org
> Subject: ExpressionBinding type conversion patch
> 
> 
> I know I'm a committer, but this is my first change to Tapestry's  
> actual functionality... so being a good citizen, I'm asking if the  
> below patch is ok to commit or not.  I've tested in on our 
> system and  
> it works wonderfully.
> 
> The dilemma is that a configured TypeConverter would not be 
> used when  
> OgnlUtils is used directly, only for expression bindings.  
> This is ok  
> for our current needs though.
> 
> Anyone object to this patch being made?
> 
> Thanks,
> 	Erik
> 
> 
> RCS file:  
> /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/binding/ 
> ExpressionBinding.java,v
> retrieving revision 1.8
> diff -u -w -b -r1.8 ExpressionBinding.java
> ---  
> framework/src/org/apache/tapestry/binding/ExpressionBinding.java   4  
> Nov 200315:09:37-0000  1.8
> +++  
> framework/src/org/apache/tapestry/binding/ExpressionBinding.ja
> va   18  
> Nov 200316:34:58-0000
>      private Map getOgnlContext()
> 
>      {
> -        if (_context == null)
> +        if (_context == null) {
>              _context = Ognl.createDefaultContext(_root, _resolver);
> +        }
> +
> +        IApplicationSpecification appSpec =  
> _root.getPage().getEngine().getSpecification();
> +        if (appSpec.checkExtension(Tapestry.OGNL_TYPE_CONVERTER)) {
> +            TypeConverter typeConverter = (TypeConverter)  
> appSpec.getExtension(Tapestry.OGNL_TYPE_CONVERTER, null);
> +            Ognl.setTypeConverter(_context, typeConverter);
> +        }
> 
>          return _context;
>      }
> 
> Index: framework/src/org/apache/tapestry/Tapestry.java
>      /**
> +     * Class name of an {@link ognl.TypeConverter} implementing class
> +     * to use as a type converter for {@link  
> org.apache.tapestry.binding.ExpressionBinding}
> +     */
> +    public static final String OGNL_TYPE_CONVERTER =
> +        "org.apache.tapestry.ognl-type-converter";
> +
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org