You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bob Stine <bo...@waltonstine.net> on 2004/02/09 23:32:51 UTC

OGNL to force upper case in Tapestry bindings?

I have a tapestry component that uses lots of OGNL in lieu of class properties for component bindings, e.g., 
 
    <component id="reportingAddressText" type="TextField">
        <binding name="value" expression="foo.bar.addressTextLine1"/>
    </component>
 
My customer requires field values to be saved and displayed in upper case.
 
Is there a way to use OGNL to force the values to upper case?  Or, if not OGNL, some other way more elegant than writing separate getters & setters for each component?
 
I'm using Tapestry 2.3.
 
Thanks!
 
Bob Stine

Re: OGNL to force upper case in Tapestry bindings?

Posted by Matt Kerr <ma...@centralparksoftware.com>.
 >triggers
ummm ... can that lead to a situation where your app thinks the data 
looks like 'xyz' and the database has 'XYZ'?  i suppose it depends on 
how roughly you deal with the database.
m


On Feb 9, 2004, at 19:27, James Treleaven wrote:

> Since it seems that OGNL trickery is out of the question I was going 
> to suggest you put the setter in a base page class, and subclass your 
> other pages from it.
>
> However, it occurs to me that if I was in your position I would 
> probably attack it on the database end with triggers on the columns 
> that need to be zotted to uppercase.
>
> James
>
>
> Bob Stine wrote:
>> I have a tapestry component that uses lots of OGNL in lieu of class 
>> properties for component bindings, e.g.,      <component 
>> id="reportingAddressText" type="TextField">
>>         <binding name="value" expression="foo.bar.addressTextLine1"/>
>>     </component>
>>  My customer requires field values to be saved and displayed in upper 
>> case.
>>  Is there a way to use OGNL to force the values to upper case?  Or, 
>> if not OGNL, some other way more elegant than writing separate 
>> getters & setters for each component?
>>  I'm using Tapestry 2.3.
>>  Thanks!
>>  Bob Stine
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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


Re: OGNL to force upper case in Tapestry bindings?

Posted by James Treleaven <ja...@enoreo.on.ca>.
Since it seems that OGNL trickery is out of the question I was going to 
suggest you put the setter in a base page class, and subclass your other 
pages from it.

However, it occurs to me that if I was in your position I would probably 
attack it on the database end with triggers on the columns that need to 
be zotted to uppercase.

James


Bob Stine wrote:
> I have a tapestry component that uses lots of OGNL in lieu of class properties for component bindings, e.g., 
>  
>     <component id="reportingAddressText" type="TextField">
>         <binding name="value" expression="foo.bar.addressTextLine1"/>
>     </component>
>  
> My customer requires field values to be saved and displayed in upper case.
>  
> Is there a way to use OGNL to force the values to upper case?  Or, if not OGNL, some other way more elegant than writing separate getters & setters for each component?
>  
> I'm using Tapestry 2.3.
>  
> Thanks!
>  
> Bob Stine


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


Re: OGNL to force upper case in Tapestry bindings?

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Oops, you're right!


----- Original Message ----- 
From: "Paul Ferraro" <pm...@columbia.edu>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Monday, February 09, 2004 6:01 PM
Subject: Re: OGNL to force upper case in Tapestry bindings?


> That won't work, since the value is an in-out parameter.  The binding
> must have an accessor and mutator.  I don't think there any OGNL
> trickery that can shield you from having to write a custom mutator method.
>
> Paul Ferraro


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


Re: OGNL to force upper case in Tapestry bindings?

Posted by Paul Ferraro <pm...@columbia.edu>.
That won't work, since the value is an in-out parameter.  The binding 
must have an accessor and mutator.  I don't think there any OGNL 
trickery that can shield you from having to write a custom mutator method.

Paul Ferraro

Jamie Orchard-Hays wrote:

>If they're Strings, you just call ".toUpperCase()":
><binding name="value" expression="foo.bar.addressTextLine1.toUpperCase()"/>
>
>
>Jamie
>----- Original Message ----- 
>From: "Bob Stine" <bo...@waltonstine.net>
>To: <ta...@jakarta.apache.org>
>Sent: Monday, February 09, 2004 5:32 PM
>Subject: OGNL to force upper case in Tapestry bindings?
>
>
>  
>
>>I have a tapestry component that uses lots of OGNL in lieu of class
>>    
>>
>properties for component bindings, e.g.,
>  
>
>>    <component id="reportingAddressText" type="TextField">
>>        <binding name="value" expression="foo.bar.addressTextLine1"/>
>>    </component>
>>
>>My customer requires field values to be saved and displayed in upper case.
>>
>>Is there a way to use OGNL to force the values to upper case?  Or, if not
>>    
>>
>OGNL, some other way more elegant than writing separate getters & setters
>for each component?
>  
>
>>I'm using Tapestry 2.3.
>>
>>Thanks!
>>
>>Bob Stine
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


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


Re: OGNL to force upper case in Tapestry bindings?

Posted by Jamie Orchard-Hays <ja...@dang.com>.
If they're Strings, you just call ".toUpperCase()":
<binding name="value" expression="foo.bar.addressTextLine1.toUpperCase()"/>


Jamie
----- Original Message ----- 
From: "Bob Stine" <bo...@waltonstine.net>
To: <ta...@jakarta.apache.org>
Sent: Monday, February 09, 2004 5:32 PM
Subject: OGNL to force upper case in Tapestry bindings?


> I have a tapestry component that uses lots of OGNL in lieu of class
properties for component bindings, e.g.,
>
>     <component id="reportingAddressText" type="TextField">
>         <binding name="value" expression="foo.bar.addressTextLine1"/>
>     </component>
>
> My customer requires field values to be saved and displayed in upper case.
>
> Is there a way to use OGNL to force the values to upper case?  Or, if not
OGNL, some other way more elegant than writing separate getters & setters
for each component?
>
> I'm using Tapestry 2.3.
>
> Thanks!
>
> Bob Stine
>


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


Re: OGNL to force upper case in Tapestry bindings?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
I added OGNL TypeConverter capability to expression bindings.  Look at 
Tapestry's test cases for an example.  I added it in the middle of the 
3.0 betas somewhere, so be sure you are at the latest codebase (I 
believe it has been in the last couple of betas at least).

Register an extension with the key 
"org.apache.tapestry.ognl-type-converter" with a custom class 
implementing ognl.TypeConverter (best to extend 
ognl.DefaultTypeConverter though).

More info here: 
http://www.ognl.org/2.6.3/Documentation/html/typeConversion.html

I have not tried it to see if OGNL calls the type converter if the 
types are the same, so maybe this won't work.

Other options:
   - Modify all the setters to do the upper-casing
   - A utility you use to pass the objects through before saving, which 
could reflectively walk the getters, toUpperCase, and call setters.
   - Looks like a great use of aspects :)

	Erik

On Feb 9, 2004, at 5:32 PM, Bob Stine wrote:
> I have a tapestry component that uses lots of OGNL in lieu of class 
> properties for component bindings, e.g.,
>
>     <component id="reportingAddressText" type="TextField">
>         <binding name="value" expression="foo.bar.addressTextLine1"/>
>     </component>
>
> My customer requires field values to be saved and displayed in upper 
> case.
>
> Is there a way to use OGNL to force the values to upper case?  Or, if 
> not OGNL, some other way more elegant than writing separate getters & 
> setters for each component?
>
> I'm using Tapestry 2.3.
>
> Thanks!
>
> Bob Stine


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


RE: OGNL to force upper case in Tapestry bindings?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
You probably could make use of ValidField and create a validator (or validator subclass) that did
the conversion.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
http://howardlewisship.com


> -----Original Message-----
> From: Bob Stine [mailto:bob@waltonstine.net] 
> Sent: Monday, February 09, 2004 5:33 PM
> To: tapestry-user@jakarta.apache.org
> Subject: OGNL to force upper case in Tapestry bindings?
> 
> 
> I have a tapestry component that uses lots of OGNL in lieu of 
> class properties for component bindings, e.g., 
>  
>     <component id="reportingAddressText" type="TextField">
>         <binding name="value" expression="foo.bar.addressTextLine1"/>
>     </component>
>  
> My customer requires field values to be saved and displayed 
> in upper case.
>  
> Is there a way to use OGNL to force the values to upper case? 
>  Or, if not OGNL, some other way more elegant than writing 
> separate getters & setters for each component?
>  
> I'm using Tapestry 2.3.
>  
> Thanks!
>  
> Bob Stine
> 


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