Java Reference
In-Depth Information
<h:outputText value="LastName:"/>
<h:inputText id="lastName"
value="#{anInstanceOfcom.ensode.jpaweb.
Customer.lastName}"
title="LastName" />
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>
Notice that NetBeans automatically inserts JSF complete with value binding
expressions mapping to our entity's properties. It uses a temporary placeholder
managed bean name to access our entity. In our example, the generated managed
bean name is anInstanceOfcom.ensode.jpaweb.Customer . In general, the
generated managed bean name will be the fully qualified name of the bean's class,
prefixed by anInstanceOf . Before this code can work, we need to make our JPA
entity a JSF managed bean following the same procedure we used for the DAO.
In order to be able to persist the user-entered data, we need to make a few
modifications to the generated markup in our JSP.
<h:form>
<h:panelGrid columns="2">
<h:outputText value="FirstName:"/>
<h:inputText id="firstName"
value="#{Customer.firstName}" title="FirstName" />
<h:outputText value="LastName:"/>
<h:inputText id="lastName" value="#{Customer.lastName}"
title="LastName" />
<h:panelGroup/>
<h:commandButton value="Submit"
action="#{Controller.saveCustomer}"/>
</h:panelGrid>
</h:form>
The first thing we need to do is modify the value binding expression of the
generated <h:inputText> elements to match the name we gave our JPA entity in
faces-config.xml ( Customer , in our case), then we need to add a command button
so that our page will be submitted.
 
Search WWH ::




Custom Search