• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EL functions

 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are the following statements true about EL functions and classes having them:
a. classes having EL functions can be public or private. and it must have a public non-arguemnt constructor.

b. EL ignores all instance methods. only static methods are used by EL.
 
Sharanya Sharma
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pallavi,

Before answering your questions let me say that I am also a learner and I am just putting my 2 cents.

coming to your questions.
1)Classes having EL functions should be public and they can not be private. Because the JSP's will not be able to access the functions. The function can/cannot have no-argument constructor as the functions that we are using in the EL are static and static functions do not need an instance of the class to be created and hence the presence of a constructor does not matter.

2) As EL cannot instantiate the class they can use only static functions.

I think if we try to access an instance method of a class from EL which is not instantiated, we get error. I am not sure of this part and someone has to confirm it. Let me check this (hands on ) and get back to you.

Thx,
Sharanya
 
Colin Fletcher
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pallavi,

From my understanding (I am working towards my WCD certification)

1) The class must have a public no-arg constructor. EL doesn't have a method to pass arguments to the constuctor.

2) Only public static functions can be accessed

My understanding of EL is that the intended used is for Display purposes... Not data manipulation (changing the value of a field).

Hope this helps.
-C
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok putting it all collectively,
1.Classes having EL functions should only be public
2.The function can/cannot have no-argument constructor but if it has an argument constructor(which is not needed or rare in the case) it should have non-argument
constructor also, cause compiler wont provided non-arg cons if it has arg cons.
3.Only public static functions can be accessed
4.EL can access only static function. But the class can have instance functions also, which if tried to access by EL leads to compiling error.

did i get it all ryt?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic