I have an editable datatable, containing column with Boolean type. When editing this column, the selectOneMenu is used to select the value "true", "false" or "null". When I enter the edit mode, the default selection is true if the value is null.
How could be solved this issue? Another question it a good approach to use Enity bean (the result of a database query), or I have to create a Managed bean?
Xhtml:
<p:column headerText="Active">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{member.active}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{member.active}" style="width:100%">
<f:selectItems value="#{memberManagementController.activeLabels}" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
Entity Bean:
@Entity
@NamedQueries({
@NamedQuery(...
})
@Table(name="Member")
public class Member implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private Boolean active;
public Boolean getActive() {
return this.active;
}
public void setActive(Boolean active) {
this.active = active;
}
...