Este contenido no está disponible en el idioma seleccionado.
10.2.7.2. Use Named Beans
Use the
@Named
annotation to assign a name to a bean.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The bean name itself is optional. If it is omitted, the bean is named after the class name, with the first letter decapitalized. In the example above, the default name would begreeterBean
.Use the named bean in a JSF view.
<h:form> <h:commandButton value="Welcome visitors" action="#{greeter.welcomeVisitors}"/> </h:form>
<h:form> <h:commandButton value="Welcome visitors" action="#{greeter.welcomeVisitors}"/> </h:form>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Result:
Your named bean is assigned as an action to the control in your JSF view, with a minimum of coding.