Thank you for your response!
what i want is , suppose i have populated table through object array data provider, and i have duplicate entry for feild of paricular column, i want to leave the first one and just remove the rest of them. for example
column 1has 4 entry
A
B
B
C
and i want
A
B
blank(just want to hide the B)
C
Here is an example how to do it using the TRAVEL.HOTEL data source
1. Drop a table on a page.
2. Drop the Data Sources > Travel > Tables > HOTEL node on the table.
2.a In the Outline window, double-click SessionBean1 > hotelRowSet and set the Sort Type for HOTELNAME to Ascending. Close the query editor for the hotelRowSet
3. Add the following code to the bottom of the Java source for the page bean:
private String hideDuplicateHotelName;
public String getHideDuplicateHotelName() {
// assumes that the table is small (and thus uses an int)
// assumes that rowKey/rowId will return row position
// and not some other type of unique identifyer
// (the JavaDoc implies that rowKey can be otherwise).
RowKey rowKey=tableRowGroup1.getRowKey();
String hotelName = "";
try {
int rowNum=Integer.parseInt(rowKey.getRowId());
hotelName = (String) hotelDataProvider.getValue(
"HOTEL.HOTELNAME",
rowKey);
if (rowNum > 0) {
String prevRowNum = Integer.toString(rowNum - 1);
RowKey prevRowKey = hotelDataProvider.getRowKey(prevRowNum);
String prevHotelName = (String) hotelDataProvider.getValue(
"HOTEL.HOTELNAME",
prevRowKey);
if (hotelName.equals(prevHotelName))
hotelName="";
}
} catch(Exception e) {
log("exception in duplicate hotel property:" + e.getMessage());
}
return hotelName;
}
4. Go back to the Visual Designer and select one of the abc in the column for HOTELNAME so that the Properties window shows the properties for the Static Text component that is in the HOTELNAME column.
5. Click the ... button to the right of the text
property and click the Bind to an Object tab. In the Bind to an Object tab, select hideDuplicateHotelName.
6. Run the project. I hope the results are what you are looking for. The
Hi,
I have tried to follow your suggetion; however unable to work it out since
i am not dropping the table. my data is coming from array data provider(which will populate from item class). eg column 1 is from employee class , column 2 is coming from item class. for each employee has many items. when i try to bind the data with array data provider, it does give me data for both items and emplyee, but when try to hid bye using the method,, getting null propery for employee.
It seems to me that this should work as well with an array provider.
You have a field in a Table component column that is bound to a page property. That page property returns a value (blank or not) based on the data that is wrapped by the array data provider.
The property is not changing the underlying data. That is, it is not nulling out the employee id.
You should still be able to get to the employee id, regardless of what is displayed in the Table component's column using something like empId = (String) myArrayDataProvider.getValue(
"empId",
rowKey);
I am having trouble determining whether you are simply not being able to blank out the duplicate row values, or whether you are also having trouble using an array data provider to join data from two different data sources.
Thank you for the response!
I am new to JSC, but that is exactly what i am doing to remove the duplicate rows
empId = (String) myArrayDataProvider.getValue(
"empId",
rowKey);
but doesn't seems working since problem is from the top, an array data provider to join data from two different data sources.
Hi a_b,
I want to make sure. We are no longer dealing with how to prevent duplicate row values. We have moved onto "how to work with object array data providers". Is this true?
If so, I would like to propose that you post a new post to the forum that states the new problem. As much background that you can give would be nice.
You have some data coming from an employee data source and some data coming from an items data source. This can be joined somehow.
For some reason, you are choosing not to use the normal route of adding the employee and items data sources to the Servers window and working with a cached rowset data provider on a joined query. Why is that? I assume that your data is not in a database, or perhaps you are using Hibernate. It would be good to know.
So, I assume that you have an array of JavaBean objects, correct? Are you sure that the array is getting populated fully?
What are your JavaBean properties?
I have only worked with ObjectListDataProvider objects (see http://blogs.sun.com/roller/page/divas?entry=table_component_sample_project). However, they are very similar. Perhaps by posting as a new entry with Object Array Data Provider in the subject line, someone with OADP expertise will see it.
Chris