Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF + RichFaces: pragmatic or unsafe?  RSS feed

 
Leonardo Shikida
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found this scary ;-) because looks like someone´s breaking a contract (or a very pragmatic approach)

Check my tree



Nothing new here, except



where MyAbstractNode does not implement or declare getA(), but for coincidence/luck every concrete class that extends MyAbstractNode does.

so it magically works, because everytime I am lucky and there is actually a way to retrieve "A" from each concrete class.

isn´t it scary?



TIA

Leo K.
 
Tim Holloway
Bartender
Posts: 18713
71
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is scary, yes. However, it's not magic. What's actually happening is that you're accessing the property through an runtime interpreted language instead of a compiled language, so you have forfeited the benefits of compile-time checking. The actual fetch/store of the named property is being done via dynamic access of the backing bean using the BeanUtils library (or something compatible).

In case anyone missed it, the runtime interpreted language is the Java Expession Language (EL), and although it looks like Java in a lot of ways, so does JavaScript.

I suppose that one could make EL safer if the page build process including precompiling the JSF Views, but it would slow down the overall build process and these days the drumbeat is "Git 'R' Dun!". Hence the popularity of the "instant gratification" languages such as JavaScript, Ruby, Python, and so forth.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!