Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about Unknown Attributes in EL

 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i have doubt in EL expressions like these :
${7<foo}. In the above expression, if foo is a unknown attribute, hence foo will take default value. In this case, whether container will provide default value for arithmethic expression or logical expression.
when this expression is run, result is false.
please tell me how container provide default value.

Thanks and Regards,
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here foo wll be given a default value of 0

Since its a logical expression involving numeric values..

So 7 < 0 gives result as false..
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean " Default value will be given by container based on the type of the other operand".
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you run this piece of code:



The output will be something like this



You can see that the unknown var "foo" is not set to 0 as default and "-1 < foo" still results in false. I think it rather has to do with the fact that the retrieval of the unknown foo attribute returns a null-value somewhere, and the EL expression evaluator returns false as a default if e.g. an integer is compared to an unknown / null value (but don't quote me on this ;-)
[ October 30, 2006: Message edited by: Johan Pelgrim ]
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your attempts.
But, in HFJS, it is mentioned that if a EL expression is having unknown variable, default value of false will be assigned to it if the expression is logical expression. If the expression is arithmetic expression, default value of 0 will be assigned to unknown variable.

is it really happening like this?

please put some lights on this concept.

Thanks and Regards,
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it should be read as "if an EL expression uses an unknown variable", then the expression results in "false" (if it's a logical expression), or "0" (if it's an arithmetic expression)?
[ October 30, 2006: Message edited by: Johan Pelgrim ]
 
KRK Gowda
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are right.
Thanks Johan.
 
Johan Pelgrim
Ranch Hand
Posts: 105
Android Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you maybe post the specific section from the HF book which is confusing? (Because I don't have that book)
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Even i replied on the basis of that book...

Sorry about the post..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic