Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Injection: Quickfix for Managed Bean with a non-static public field #209

Closed
KidoVin01 opened this issue Nov 11, 2021 · 2 comments
Assignees
Labels
diagnostic Diagnostic item

Comments

@KidoVin01
Copy link
Contributor

Managed Beans

If a managed bean has a non-static public field, it must have scope @dependent. If a managed bean with a non-static public field declares any scope other than @dependent, the container automatically detects the problem and treats it as a definition error.

Diagnostics already exists and is shown as an error on the field with the following error:

A managed bean with a non-static public field must not declare any scope other than @dependent

Quickfixes

  • Suggest changing/adding @Dependent scope to the class
  • Suggest removing public and/or adding static modifier to the field

Example

The following is a faulty example code snippet:

@ApplicationScoped
public class Greeting{

       // Illegal field 
	public String name;
	
	public String greet(String name) {
        return "GreetingA, " + name;
    }
}

Related to #153

@KidoVin01
Copy link
Contributor Author

I am working on this.

@KidoVin01
Copy link
Contributor Author

Was already implemented, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic Diagnostic item
Projects
None yet
Development

No branches or pull requests

2 participants