Allow easy creation of a component using the static keyword.

Description

If I want a static constructor method right now I need to use the component name.

This works, but is not very flexible. Even adding basic inheritance breaks this down:

This will still return Foo since that is the component being created in the static create method.

You can override the static create method in Bar to return the right value:

But that isn't very flexible.

I propose being able to create a new instance of a component from a static method like so:

Using the static keyword as a constructor would create a new instance of the component and call that component's init method with any arguments passed. With this syntax, we could bring back our old Bar component:

And this code would execute as expected:

Activity

Michael Offner 19 March 2018 at 11:11

i was actually thinking about the same, but your suggestion has 1 problem:
existing components named "static" will no longer work, i searched my system i have 9!

also i think the keyword "static" is confusing in that case. This has not really something to do with "static", it is more like

what if we allow to call createObject function without any argument?

Pothys - MitrahSoft 13 March 2018 at 15:10

Hi ,

I think this feature enhancement ticket. Any way will confirm about this.

Details

Assignee

Reporter

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Priority

Created 5 March 2018 at 16:25
Updated 5 May 2023 at 09:42