Re: Adding @InjectComponent(optional = true) to complement @DisableStrictChecks

"Thiago H. de Paula Figueiredo" <[email protected]>
Newsgroups gmane.comp.jakarta.tapestry.devel
Message-ID <CAE_88GYi6vxpfBTSfYfJ-kwOvpMDo30bprO8equ+TbUY2rVLZw@mail.gmail.com>
On Sat, May 28, 2022 at 11:40 AM Ben Weidig <[email protected]> wrote:

> Hello!

Hi!

> As discussed in a previous thread, I've created an issue for adding
> "boolean optional() default false" to @InjectComponent to complement
> @DisableStrictChecks.
>
> https://issues.apache.org/jira/projects/TAP5/issues/TAP5-2727
>
> The ticket contains a patch with an attempt to implement the required
> behavior, plus some tests.
> If optional() == true, the InjectComponentWorker just ignores the
> UnknownValueException and the embedded component will be null.
> That was the easiest way to implement it.

After reading your message above and the patch, it gets a +1 from me.
By the way, feel free to create branches for new features like this.
It has one very nice bonus: Travis CI automatically runs tests on any
branches: https://app.travis-ci.com/github/apache/tapestry-5/branches.
This way, you can be sure you won't break anything before merging to
master while still being able to have Git to store and version your
changes.

> Another option would be creating a proxy in case of an optional and missing
> component, which reacts with an appropriate Exception if used.
> Or do you think that's overkill?

I believe it is overkill. In addition, you can just check for null
instead of having to have a try/catch in order to know whether the
injected component exists or not.

Thank you for suggesting and implementing this! I really, really love
all the activity we're having on Tapestry's repository lately. :)

Also, I'd like to cut 5.8.3 soon to get CORS and everything else out
there. Thoughts?

Cheers!

-- 
Thiago
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.