jsf - Why is the bean constructor called twice? -
Why 'UserBean' is created twice? This is when I first visit the page. Next time the bean creates a default constructor with the system in it. So why does this happen?
& lt; H: body & gt; & Lt; H3 & gt; # {UserBean.requestParametr} & lt; / H3 & gt; & Lt; H: form id = "form" & gt; & Lt; P: panel id = "panel" & gt; & Lt; H: Panel Grid Column = "3" & gt; & Lt; H: output = for label = "email" value = "email:" /> & Lt; P: Input text id = "email" value = "# {userbayan.email}" required = "true" label = "e-mail" & gt; & Lt; / P: inputText> & Lt; H: for outputLabel = "password" value = "# {msg ['_ password']}:" /> & lt; P: inputText type = "password" id = "password" value = "# {userBean.password}" label = "# {msg ['_ password']}" required = "true" & gt; & Lt; / P: inputText> & Lt; / H: panelGrid & gt; & Lt; P: commandButton id = "btn" value = "# {msg ['_ enter']}" update = "panel" verb = "# {userBean.login}" /> & lt; / P: Panel & gt; & Lt; / H: form & gt; & Lt; / H: Body & gt;
has a default constructor with the system
This will happen when you are using the Bean Management Framework which uses a proxy, such as CDI (like Been to @ Named ), It is also confirmed by looking at it). Make this an example to inspect the example before making a proxy for the first time. All is done immediately through the immediate proxy class.
You do not want to do anything at least in the Bean Constructor, instead, if you intend to hook up the Managed Bean Initialization then annotated with @PostConstruct Use the method and, if you intend to hook the managed bean vandalism, then use a method with @PreDestroy .
@public class Bean {@PostConstruct Public Zero Init ()} // ...} @PreDestroy Public Null Destroy () {// ...}}< / Pre>The method names are free for your choice only above are canonical names, which have been taken from several existing APIs, such as servlets and filters, thereby improving the self-documentation of the code.
Comments
Post a Comment