• Post Reply Bookmark Topic Watch Topic
  • New Topic

default value for EL functions arguments  RSS feed

 
Tomm Green
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a possibility to have default values for EL functions arguments (e.g., optional arguments)?
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming you are the one writing the function right. If so, yes. Just create the function and provide the default values for the arguments, just like you would for any other function.
 
Tomm Green
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure - should I supply the default value in the Java implementation of the function, or in the .tld file, in the function declaration?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no concept of default values. You can detect null values being passed in and use default values in the function body, but there's no formal notions of default values.
 
Tomm Green
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can detect null values being passed in and use default values in the function body


Inaccurate. I can do this in java, but not in EL functions, as the function call must match exactly the function signature in the .tld file. This means I must supply the exact number of parameters. Since there's no overloading in EL, seems like this is not a feasible way to have default values for EL functions.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did not say missing, i said null.
 
Tomm Green
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a cumbersome way to have default parameters - you must supply zillions of nulls each time you use the function...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would any function takes zillions of parameters in the first place? And I didn't say that nulls were an elegant solution. All I'm saying is that the notion of default parameters does not exist.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!