Java Reference
In-Depth Information
package org.javaee7.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
/**
*
* @author Juneau
*/
@Entity
@DiscriminatorValue("A")
public class WidgetA extends Product implements Serializable {
@Column(name="COLOR")
private String color;
public WidgetA(){
}
/**
* @return the color
*/
public String getColor() {
return color;
}
/**
* @param color the color to set
*/
public void setColor(String color) {
this.color = color;
}
}
The following JSF view excerpt demonstrates how to display the results of the downcast. The
dataTable
references
productBean.productType()
for the value, which initiates the invocation of the
obtainProduct
method
within the
ProductSession
EJB.
...
<h:dataTable var="product" border="1" value="#{productBean.productType()}">
<h:column>
<f:facet name="header">
Product Name
</f:facet>
<h:outputText value="#{product.name}"/>
</h:column>