Using a Managed Bean in a Facelets Page (original) (raw)

To use the managed bean in a Facelets page, you typically create a form that uses user interface elements to call its methods and display their results. This example provides a button that asks the user to type a name, retrieves the salutation, and then displays the text in a paragraph below the button:

<h:form id="greetme">

<h:outputLabel value="Enter your name: " for="name"/> <h:inputText id="name" value="#{printer.name}"/>

<h:commandButton value="Say Hello" action="#{printer.createSalutation}"/>

<h:outputText value="#{printer.salutation}"/>

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices