Re: [T5] Expression Language

2009-01-27 Thread Francois Armand

iberck wrote:

thank you of your response and your time
Now I understand the concept.
  

No problem :)

--
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
---
http://fanf42.blogspot.com
InterLDAP - http://interldap.org 
FederID - http://www.federid.org/

Open Source identities management and federation


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [T5] Expression Language

2009-01-27 Thread iberck

thank you of your response and your time
Now I understand the concept.



Francois Armand wrote:
> 
> iberck wrote:
>> Hi, I'm developing an application with tap 5..
>>   
> Great, good new. Welcome on board !
>> I don't understand why I can't use OGNL inside tap5 and with tap4 yes !
>>   
> 
> That's a design choice made by HLS. OGNL suffer some drawbacks, 
> including a performance penalty (even after the amazing work Jesse 
> Kuhnert did on that area), and a non-type safe way of handling 
> properties access. Moreover, it's always hard to synchronize the needs 
> and development of two major and independents frameworks. Finally, the 
> spirit of T5 is "clean templates, logic in the code (where it belongs)"
> 
> So, HLS choose to build for 5.0 a simple, efficient expression language, 
> but clearly not as expressive as OGNL.
>> I found a set of components
>> (http://code.google.com/p/tapestry5-components/)
>> that has the OGNL component, the question is why outside of the core ?
>>   
> 
> That's the alternative. T5-component provides an OGNL binding that let 
> you use it if you want.
> 
>> what in tap5 OGNL is out, what is the alternative?
>>   
> Tapestry 5 has a simple expression language, the doc is under template 
> and binding related pages: 
> http://tapestry.apache.org/tapestry5/guide/templates.html and here: 
> http://tapestry.apache.org/tapestry5/guide/parameters.html
> 
> 
> -- 
> Francois Armand
> Etudes & Développements J2EE
> Groupe Linagora - http://www.linagora.com
> Tél.: +33 (0)1 58 18 68 28
> ---
> http://fanf42.blogspot.com
> InterLDAP - http://interldap.org 
> FederID - http://www.federid.org/
> Open Source identities management and federation
> 
> 
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-T5--Expression-Language-tp21674223p21685501.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [T5] Expression Language

2009-01-27 Thread Francois Armand

iberck wrote:

Hi, I'm developing an application with tap 5..
  

Great, good new. Welcome on board !

I don't understand why I can't use OGNL inside tap5 and with tap4 yes !
  


That's a design choice made by HLS. OGNL suffer some drawbacks, 
including a performance penalty (even after the amazing work Jesse 
Kuhnert did on that area), and a non-type safe way of handling 
properties access. Moreover, it's always hard to synchronize the needs 
and development of two major and independents frameworks. Finally, the 
spirit of T5 is "clean templates, logic in the code (where it belongs)"


So, HLS choose to build for 5.0 a simple, efficient expression language, 
but clearly not as expressive as OGNL.

I found a set of components (http://code.google.com/p/tapestry5-components/)
that has the OGNL component, the question is why outside of the core ?
  


That's the alternative. T5-component provides an OGNL binding that let 
you use it if you want.



what in tap5 OGNL is out, what is the alternative?
  
Tapestry 5 has a simple expression language, the doc is under template 
and binding related pages: 
http://tapestry.apache.org/tapestry5/guide/templates.html and here: 
http://tapestry.apache.org/tapestry5/guide/parameters.html



--
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
---
http://fanf42.blogspot.com
InterLDAP - http://interldap.org 
FederID - http://www.federid.org/

Open Source identities management and federation


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: T5: expression language

2007-11-19 Thread Peter Stavrinides


I think for T5 as default:
Tapestry's binding language might be extended to do some simple 
evaluation at best, and nothing more!  the simpler the better in my 
view, isn't this the general idea of using components and moving away 
from embedded scripting? I think, in general, support for pulggable 
views for different devices, platforms and resolutions is becoming more 
and more important, and is served best through using components.


OGNL is now super fast and powerful, good in many respects... but I am 
glad it's no longer in the picture (no offence intended Jessie). 
Expression binding is not something I want to even think about ever, nor 
do I want to do wonderful things with it, Java is best for this in my 
view... besides OGNL has caused me some pain in the past.


I think for a T5 as optional:
Some people require stuff like true recursion with fine grained control 
and complex evaluation of templates (there was a post on this a while back)
Components can be too inflexible for this type of thing, wheras 
scripting makes sense and almost effortlessly can do it. So there is a 
very valid argument, which I support, for some real scripting support in 
the framework and not just a more powerful expression binding 
language... as important as this is, it serves a niche so is best made 
optional in my view.


If you say that scripting support can be pluggable or language agnostic, 
then this is a MUST HAVE feature for Tapestry... is it a 'bad idea'? as 
you have correctly said, having an expression binding language to do the 
job of a scripting language is the only bad idea IMHO.


Peter

Jesse Kuhnert wrote:

Oh wellit wouldn't hurt my feelings if anyone used MVEL.   I'm
only as loyal to the best technology and hope everyone else would be
too.

On Nov 16, 2007 4:35 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:
  

thanks,
I've played with it only a bit...

It was that time that MVEL was said to be much faster than OGNL
and very long flame on serverside.

I've just wanted try both, and made a small project that adds
both binding prefixes..
(I was not testing speeds .. just integration...)

after playing with it I was more satisfied with OGNL,
and MVEL crashed on some simple examples when
byte code optimizer was turned on for it.

Davor Hrg



On Nov 16, 2007 10:06 PM, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:



You can know the type in advance by calling
OgnlContext.getCurrentType() after evaluating an expression (or
getPreviousType() / getFirstType() / the type and accessor types are
all pushed on to a stack now)..

It also supports generics / enums / varargs / etc now..

On Nov 16, 2007 2:42 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:
  

ognl can be easily added as a binding prefix,
however expect some features to not work
because tapestry in some occasions needs to
know in advance type that the expression will return






--
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

  
-

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  




  



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: expression language

2007-11-16 Thread Jesse Kuhnert
Oh wellit wouldn't hurt my feelings if anyone used MVEL.   I'm
only as loyal to the best technology and hope everyone else would be
too.

On Nov 16, 2007 4:35 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:
> thanks,
> I've played with it only a bit...
>
> It was that time that MVEL was said to be much faster than OGNL
> and very long flame on serverside.
>
> I've just wanted try both, and made a small project that adds
> both binding prefixes..
> (I was not testing speeds .. just integration...)
>
> after playing with it I was more satisfied with OGNL,
> and MVEL crashed on some simple examples when
> byte code optimizer was turned on for it.
>
> Davor Hrg
>
>
>
> On Nov 16, 2007 10:06 PM, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
>
> > You can know the type in advance by calling
> > OgnlContext.getCurrentType() after evaluating an expression (or
> > getPreviousType() / getFirstType() / the type and accessor types are
> > all pushed on to a stack now)..
> >
> > It also supports generics / enums / varargs / etc now..
> >
> > On Nov 16, 2007 2:42 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:
> > > ognl can be easily added as a binding prefix,
> > > however expect some features to not work
> > > because tapestry in some occasions needs to
> > > know in advance type that the expression will return
> > >
> > 
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
>
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: expression language

2007-11-16 Thread Davor Hrg
thanks,
I've played with it only a bit...

It was that time that MVEL was said to be much faster than OGNL
and very long flame on serverside.

I've just wanted try both, and made a small project that adds
both binding prefixes..
(I was not testing speeds .. just integration...)

after playing with it I was more satisfied with OGNL,
and MVEL crashed on some simple examples when
byte code optimizer was turned on for it.

Davor Hrg


On Nov 16, 2007 10:06 PM, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:

> You can know the type in advance by calling
> OgnlContext.getCurrentType() after evaluating an expression (or
> getPreviousType() / getFirstType() / the type and accessor types are
> all pushed on to a stack now)..
>
> It also supports generics / enums / varargs / etc now..
>
> On Nov 16, 2007 2:42 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:
> > ognl can be easily added as a binding prefix,
> > however expect some features to not work
> > because tapestry in some occasions needs to
> > know in advance type that the expression will return
> >
> 
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: T5: expression language

2007-11-16 Thread Jesse Kuhnert
You can know the type in advance by calling
OgnlContext.getCurrentType() after evaluating an expression (or
getPreviousType() / getFirstType() / the type and accessor types are
all pushed on to a stack now)..

It also supports generics / enums / varargs / etc now..

On Nov 16, 2007 2:42 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:
> ognl can be easily added as a binding prefix,
> however expect some features to not work
> because tapestry in some occasions needs to
> know in advance type that the expression will return
>



-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5: expression language

2007-11-16 Thread Davor Hrg
of course, youll need the dependancy in your pom:


ognl
ognl
2.6.9



On Nov 16, 2007 8:42 PM, Davor Hrg <[EMAIL PROTECTED]> wrote:

> ognl can be easily added as a binding prefix,
> however expect some features to not work
> because tapestry in some occasions needs to
> know in advance type that the expression will return
> (and this is statically, when bindings are prepared)
>
> I think I saw that ognl has methods that calculate
> return type for the expression ...
>
>
> read this:
> http://wiki.apache.org/tapestry/Tapestry5HowToAddBindingPrefix
>
>
> I didn't put the ognl example because it seems unwanted in T5
> (although byte code optimizer was introduced and it performs very well)
>
>
> here are classes you'll need to get it running
>
> /**
>  *
>  */
> package test.tapestry.services;
>
> import java.util.Map;
>
> import ognl.Node;
> import ognl.Ognl;
> import ognl.OgnlException;
> import ognl.TypeConverter;
>
> import org.apache.tapestry.ComponentResources ;
> import org.apache.tapestry.internal.bindings.AbstractBinding;
> import org.apache.tapestry.ioc.Location;
> import org.apache.tapestry.ioc.internal.util.TapestryException;
>
> public class OgnlBinding extends AbstractBinding{
> private final Object _root;
> private final Object _compiledExpression;
> private final String _expression;
> private final Location _location;
> private Map _defaultContext;
>
> public OgnlBinding(final ComponentResources resources, final String
> expression, final Location location, TypeConverter typeConverter) throws
> OgnlException {
> _root = resources.getComponent();
> _compiledExpression = Ognl.parseExpression(expression);
> _expression = expression;
> _location = location;
> _defaultContext = Ognl.createDefaultContext (_root, null,
> typeConverter);
> }
>
>
> public Object get(){
> try{
> return Ognl.getValue(_compiledExpression, _defaultContext,
> _root);
> }catch(Throwable t){
> throw new TapestryException("ERROR evaluating expression:
> "+_expression,_location, t);
> }
> }
>
> @Override
> public void set(final Object value) {
> try{
> Ognl.setValue(_compiledExpression, _defaultContext, _root,
> value);
> }catch(Throwable t){
> throw new TapestryException("ERROR evaluating expression:
> "+_expression,_location, t);
> }
> }
>
> @Override
> public boolean isInvariant() {
> return false;
> }
>
> @Override
> public Class getBindingType() {
> return Object.class;
> }
> }
>
> package test.tapestry.services;
>
> import ognl.OgnlException;
> import ognl.TypeConverter ;
>
> import org.apache.tapestry.Binding;
> import org.apache.tapestry.ComponentResources;
> import org.apache.tapestry.ioc.Location;
> import org.apache.tapestry.ioc.internal.util.TapestryException;
> import org.apache.tapestry.services.BindingFactory ;
>
> /**
>  * Implementation of the ognl: binding prefix -- the expression is passed
> to ognl library,
>  * and the component is set as context for the code
>  */
> public class OgnlBindingFactory implements BindingFactory {
> private final TypeConverter _typeConverter;
>
> public OgnlBindingFactory(TypeConverter typeConverter){
> _typeConverter = typeConverter;
> }
>
> public Binding newBinding(String description, ComponentResources
> container, ComponentResources component,
> String expression, Location location)
> {
> try {
> return new OgnlBinding(container, expression, location,
> _typeConverter);
> } catch (OgnlException e) {
> throw new TapestryException( e.getMessage(),location,e);
> }
> }
> }
>
>
>
>
> package test.tapestry.services;
>
> import java.lang.reflect.Member;
> import java.util.Map;
>
> import ognl.TypeConverter;
>
> import org.apache.tapestry.ioc.services.TypeCoercer ;
>
> public class OgnlTypeConverter implements TypeConverter{
>
> private final TypeCoercer _coercer;
>
> public OgnlTypeConverter(TypeCoercer coercer){
> _coercer = coercer;
> }
>
> public Object convertValue(Map context, Object target, Member member,
> String propertyName, Object value, Class toType) {
> return _coercer.coerce(value, toType);
>
> }
> }
>
>
>
>
>
>
>
> On Nov 16, 2007 3:52 PM, Massimo Lusetti <[EMAIL PROTECTED]> wrote:
>
> > On Nov 16, 2007 1:53 PM, Chris Lewis <[EMAIL PROTECTED]> wrote:
> >
> > > Perhaps this is a horrible idea, but if so I think it is transitive
> > and
> > > the actual bad idea is having an expression language at all. Its
> > > certainly true that with such power one has enough rope to hang
> > oneself,
> > > at least from the view point of what a 'view' should be able to do.
> > > Thoughts?
> >
> > I've never used the whole power of OGNL during T4 days, always used it
> > as a simple binding language.
> > 

Re: T5: expression language

2007-11-16 Thread Davor Hrg
ognl can be easily added as a binding prefix,
however expect some features to not work
because tapestry in some occasions needs to
know in advance type that the expression will return
(and this is statically, when bindings are prepared)

I think I saw that ognl has methods that calculate
return type for the expression ...


read this:
http://wiki.apache.org/tapestry/Tapestry5HowToAddBindingPrefix


I didn't put the ognl example because it seems unwanted in T5
(although byte code optimizer was introduced and it performs very well)


here are classes you'll need to get it running

/**
 *
 */
package test.tapestry.services;

import java.util.Map;

import ognl.Node;
import ognl.Ognl;
import ognl.OgnlException;
import ognl.TypeConverter;

import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.internal.bindings.AbstractBinding;
import org.apache.tapestry.ioc.Location;
import org.apache.tapestry.ioc.internal.util.TapestryException;

public class OgnlBinding extends AbstractBinding{
private final Object _root;
private final Object _compiledExpression;
private final String _expression;
private final Location _location;
private Map _defaultContext;

public OgnlBinding(final ComponentResources resources, final String
expression, final Location location, TypeConverter typeConverter) throws
OgnlException {
_root = resources.getComponent();
_compiledExpression = Ognl.parseExpression(expression);
_expression = expression;
_location = location;
_defaultContext = Ognl.createDefaultContext(_root, null,
typeConverter);
}


public Object get(){
try{
return Ognl.getValue(_compiledExpression, _defaultContext,
_root);
}catch(Throwable t){
throw new TapestryException("ERROR evaluating expression:
"+_expression,_location, t);
}
}

@Override
public void set(final Object value) {
try{
Ognl.setValue(_compiledExpression, _defaultContext, _root,
value);
}catch(Throwable t){
throw new TapestryException("ERROR evaluating expression:
"+_expression,_location, t);
}
}

@Override
public boolean isInvariant() {
return false;
}

@Override
public Class getBindingType() {
return Object.class;
}
}

package test.tapestry.services;

import ognl.OgnlException;
import ognl.TypeConverter;

import org.apache.tapestry.Binding;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.ioc.Location;
import org.apache.tapestry.ioc.internal.util.TapestryException;
import org.apache.tapestry.services.BindingFactory;

/**
 * Implementation of the ognl: binding prefix -- the expression is passed to
ognl library,
 * and the component is set as context for the code
 */
public class OgnlBindingFactory implements BindingFactory {
private final TypeConverter _typeConverter;

public OgnlBindingFactory(TypeConverter typeConverter){
_typeConverter = typeConverter;
}

public Binding newBinding(String description, ComponentResources
container, ComponentResources component,
String expression, Location location)
{
try {
return new OgnlBinding(container, expression, location,
_typeConverter);
} catch (OgnlException e) {
throw new TapestryException(e.getMessage(),location,e);
}
}
}




package test.tapestry.services;

import java.lang.reflect.Member;
import java.util.Map;

import ognl.TypeConverter;

import org.apache.tapestry.ioc.services.TypeCoercer;

public class OgnlTypeConverter implements TypeConverter{

private final TypeCoercer _coercer;

public OgnlTypeConverter(TypeCoercer coercer){
_coercer = coercer;
}

public Object convertValue(Map context, Object target, Member member,
String propertyName, Object value, Class toType) {
return _coercer.coerce(value, toType);
}
}







On Nov 16, 2007 3:52 PM, Massimo Lusetti <[EMAIL PROTECTED]> wrote:

> On Nov 16, 2007 1:53 PM, Chris Lewis <[EMAIL PROTECTED]> wrote:
>
> > Perhaps this is a horrible idea, but if so I think it is transitive and
> > the actual bad idea is having an expression language at all. Its
> > certainly true that with such power one has enough rope to hang oneself,
> > at least from the view point of what a 'view' should be able to do.
> > Thoughts?
>
> I've never used the whole power of OGNL during T4 days, always used it
> as a simple binding language.
> So by me there's no interest in having OGNL of any other scrpting
> language inside T5.
>
> Just my .02 EURO.
>
> --
> Massimo
> http://meridio.blogspot.com
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: T5: expression language

2007-11-16 Thread Massimo Lusetti
On Nov 16, 2007 1:53 PM, Chris Lewis <[EMAIL PROTECTED]> wrote:

> Perhaps this is a horrible idea, but if so I think it is transitive and
> the actual bad idea is having an expression language at all. Its
> certainly true that with such power one has enough rope to hang oneself,
> at least from the view point of what a 'view' should be able to do.
> Thoughts?

I've never used the whole power of OGNL during T4 days, always used it
as a simple binding language.
So by me there's no interest in having OGNL of any other scrpting
language inside T5.

Just my .02 EURO.

-- 
Massimo
http://meridio.blogspot.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]