Skip to content

Commit

Permalink
Scanned through the tutorial for all bean scopes, found one bean where
Browse files Browse the repository at this point in the history
Serializable is completely unnecessary and clarified the bean scopes in
faces context #58
  • Loading branch information
BalusC committed Dec 9, 2023
1 parent 46c066a commit 0da8ec6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The bean uses the `@Model` annotation, a shortcut for `@Named` and `@RequestScop
[source,java]
----
@Model
public class PrimeBean implements Serializable {
public class PrimeBean {
...
@Size(min=1, max=45)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ You can specify one of the following scopes for a bean class.

* Application (`jakarta.enterprise.context.ApplicationScoped`): Application scope persists across all users' interactions with a web application.

* Session (`jakarta.enterprise.context.SessionScoped`): Session scope persists across multiple HTTP requests in a web application.
* Session (`jakarta.enterprise.context.SessionScoped`): Session scope persists across multiple HTTP requests during a single HTTP session in a web application.

* Flow (`jakarta.faces.flows.FlowScoped`): Flow scope persists during a user's interaction with a specific flow of a web application.
* Flow (`jakarta.faces.flow.FlowScoped`): Flow scope persists during a user's interaction with a specific flow during a single HTTP session in a web application.
See xref:faces-configure/faces-configure.adoc#_using_faces_flows[Using Faces Flows] for more information.

* View (`jakarta.faces.view.ViewScoped`): View scope persists across multiple HTTP postbacks on a single view during a single HTTP session in a web application.

* Request (`jakarta.enterprise.context.RequestScoped`): Request scope persists during a single HTTP request in a web application.

* Dependent (`jakarta.enterprise.context.Dependent`): Indicates that the bean depends on some other bean.
* Dependent (`jakarta.enterprise.context.Dependent`): Indicates that the bean scope depends on the other bean where it's injected.

You may want to use `@Dependent` when a managed bean references another managed bean.
The second bean should not be in a scope (`@Dependent`) if it is supposed to be created only when it is referenced.
Expand Down

0 comments on commit 0da8ec6

Please sign in to comment.