Reputation: 1
h:datatable question here i have table with "isApprove" field..how to display its value. true or false? i want to display "corect" of "incorect" image according to the true or false value. how to do that? any 1 can help me?
<f:facet name="header">
<h:outputText value="Company List" />
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{company.appCompanyName}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="isApproved"/>
</f:facet>
<h:outputText value="#{company.isAppIsApproved}"></h:outputText>
</p:column>
</p:dataTable>
</h:form>
And ManagedBean code is
...
public Boolean getIsApproved() {
return isApproved;
}
public void setIsApproved(Boolean isApproved) {
this.isApproved = isApproved;
}
public CompanyListManagedBean() {
}
public Collection<Tblcompany> GetCompanyList() {
return showAllCompany();
}
private java.util.List<webservice.Tblcompany> showAllCompany() {
webservice.AdminWebService port = service.getAdminWebServicePort();
return port.showAllCompany();
}
...
Upvotes: 0
Views: 1311
Reputation: 660
Try it this way, add a checkbox and using the <a4j:support>
action we can change the images as desired in the bean's method or use Graphic Image
<h:selectBooleanCheckbox value="#{Bean.isAppIsApproved}">
<a4j:support event="onchange" action="#{Bean.approvedCheck}" reRender="tableId" />
</h:selectBooleanCheckbox>
Upvotes: 0
Reputation: 27536
<h:graphicImage rendered="#{company.isAppIsApproved}" ... /> //correct image
<h:graphicImage rendered="#{not company.isAppIsApproved}" ... /> //incorrect image
I think it's pretty obvious from the code how it's work:-)Note that you can use it for almost all elements like <h:table>
, <h:panelGrid>
, <h:form>
and so on.
Upvotes: 1
Reputation: 5409
<h:graphicImage id="correctImage" value="./myCorrectImage.png" rendered="#{company.isAppIsApproved}"/>
<h:graphicImage id="notCorrectImage" value="./myIncorrectImage.png" rendered="#{not company.isAppIsApproved}"/>
Upvotes: 1