Java Reference
In-Depth Information
<title>Object to JSON With the JSON-P Object Model API</title>
<h:panelGrid columns="2">
<h:outputLabel for="firstName" value="First Name"/>
<h:inputText id="firstName" value="#{person.
<h:outputLabel for="middleName" value="Middle Name"/>
<h:inputText id="middleName"
<h:outputLabel for="lastName" value="Last Name"/>
<h:inputText id="lastName" value="#{person.
<h:outputLabel for="gender" value="Gender"/>
<h:inputText id="gender" value="#{person.gender}"/>
<h:outputLabel for="age" value="Age"/>
<h:inputText id="age" value="#{person.age}"/>
<h:commandButton value="Submit"
As we can see, the preceding markup is very simple. It consists of a form with
several input text fields bound to properties in the Person CDI named bean. There is
also a command button that transfers control to the generateJson() method of the
JsonPModelApiBean class we discussed in the previous section.
Here is the source code for the Person bean:
package com.ensode.jsonpmodelapi;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
public class Person implements Serializable {
Search WWH ::

Custom Search