Displaying Flag in a table corresponding to a DB value ?!
Hi forum,
It's somehow a complicated problem !!
I don't know to start from where
I want to get a field value from each record in a table DataProvider
and according to each value I want to perform an action on the table
In more details I want to display a flag image instead of the value itself corresponding to the field record value returned
I used this code in the Page Bean to get each record value as follows:
publicvoid statusFlag()
{
// Set cursor to first row
search_vwDataProvider.cursorFirst();
while(true)
{
// Get StatusID from current row
search_vwDataProvider.refresh();
RowKey rowKey = search_vwDataProvider.getCursorRow();
Integer StatusID = (Integer)search_vwDataProvider.getValue("candidate_status_vw.employment_level_id", rowKey);
if (StatusID.equals(new Integer(1)))
getLoginSessionBean().setStatus_img("Flag-orange.jpg");
else
getLoginSessionBean().setStatus_img("Flag-grey.jpg");
// Check if current row is the last or not
if (search_vwDataProvider.cursorLast())
{
search_vwDataProvider.refresh();
break;
}
// Move the cursor to the next row
search_vwDataProvider.cursorNext();
}
}
ofcourse the above function is called in the prerender Function
and I added this code to the loginSessionBean (aka sessionBean)
to set & get the flag image url
private String status_img;
public String getStatus_img()
{
return ("/resources/" + this.status_img);
}
publicvoid setStatus_img(String status_img)
{
this.status_img = status_img;
}
Then binded the image url in the table field to getStatus_img() function as shown
<ui:image binding="#{searchResults.image1}" id="image1" url="#{LoginSessionBean.status_img}"/>
it appears from the returned image that the while loop above runs for the first row only causing all later images column be the same as the first row
Please advise is it possible to overcome that using a Java code
or should I use a JavaScript code in the page's JSP
Thanks in advance,
Amr Aman.

