Nesting table rowgroups
Hi,
Is there a way to nest tablerowgroups in a table? I saw a tutorial has two table row groups but there display one after other. Say, I have a person list, l'd like to group the person based on the last name, and the table will look like this:
Last name First NameAddresssome other stuff
grp One:Doe
grp Two Joe123 main st.
grp Two Smith 1234 main st.
grp One:XXXX
grp Two Joe 2
grp Two Smith2.
Thanks
Jimmy
# 5
Jimmy,
I post below the code that I am using which is for listing the pair of projects/department ( the outside table ) and their corresponding update status ( inside table ). One pair of project/dep may have multiple lines of status.
The main idea is to hook the code to get currentRow values to update the '? paramters' of the 2nd sql. To do so, I extends the classes CachedRowSetXImpl and CachedRowSetDataProvider to be able to put my code in.
Because of using the extended classes, I have to modify the class types of the rowSet variables in Session1.java also.
Sorry for my ugly code. If I have time, I will create a sample project with clearer code/comments tonight.
Vu
-- class WrappedCachedRowSetDataProvider -
package webcontractor.bean;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.data.provider.RowKey;
import javax.sql.rowset.CachedRowSet;
import com.sun.data.provider.FieldKey;
public class WrappedCachedRowSetDataProvider extends CachedRowSetDataProvider{
/** Creates a new instance of WrappedCachedRowSetDataProvider */
private String cachedName;
private int hooked = 0;
public WrappedCachedRowSetDataProvider() {
}
public CachedRowSet getCachedRowSet() {
//System.out.println("*** getCachedRowSet" + ": " + getCachedName());
CachedRowSet crs = super.getCachedRowSet();
if( crs instanceof WrappedCachedRowSetXImpl )
((WrappedCachedRowSetXImpl)crs).setHooked(hooked);
return super.getCachedRowSet();
}
public String getCachedName() {
return cachedName;
}
public void setCachedName(String cachedName) {
this.cachedName = cachedName;
}
public int getHooked() {
return hooked;
}
public void setHooked(int hooked) {
this.hooked = hooked;
}
}
- class WrappedCachedRowSetXimpl.java
package webcontractor.bean;
import java.sql.SQLException;
import javax.sql.rowset.CachedRowSet;
import com.sun.sql.rowset.CachedRowSetXImpl;
import oracle.net.ano.SupervisorService;
import com.sun.rowset.internal.BaseRow;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
public class WrappedCachedRowSetXImpl extends CachedRowSetXImpl{
private int wrapped = 0;
private int hooked = 0;
private CachedRowSet crs;
private CachedRowSetDataProvider crsdp;
/** Creates a new instance of WrappedRowSet */
public WrappedCachedRowSetXImpl() {
}
public BaseRow getCurrentRow() throws SQLException {
if( getHooked() == 1 ) { // using the hooked version to update the 2nd sql command with currentRow values of the first sql
if( wrapped == 0) { // to prevent stack overlofwed
wrapped = 1;
String command = super.getCommand();
//String projkey = super.getString(1);
String projectkey = super.getString("PRJ_PROJKEY");
String deppk = super.getString("DEP_PK");
System.out.println("\r\n- -\r\ngetCurrentRow cmd=" + command +", projectkey=" + projectkey + ", deppk = "+ deppk);
if( getCrs() != null) {
command = crs.getCommand();
getCrs().setObject(1, projectkey);
getCrs().setObject(2, deppk);
System.out.println("The hooked crs is for " + command);
crsdp.refresh();
}
wrapped = 0;
}
}
return super.getCurrentRow();
}
public int getHooked() {
return hooked;
}
public void setHooked(int hooked) {
this.hooked = hooked;
}
public CachedRowSet getCrs() {
return crs;
}
public void setCrs(CachedRowSet crs) {
this.crs = crs;
}
public CachedRowSetDataProvider getCrsdp() {
return crsdp;
}
public void setCrsdp(CachedRowSetDataProvider crsdp) {
this.crsdp = crsdp;
}
}
-- code that are used in SessionBean1.java
private void _init() throws Exception {
...
notifiedprojectRowSet.setCrs(projectupdateRowSet);
notifiedprojectRowSet.setHooked(1);
}
private WrappedCachedRowSetXImpl projectupdateRowSet = new WrappedCachedRowSetXImpl();
public CachedRowSetXImpl getProjectupdateRowSet() {
return projectupdateRowSet;
}
public void setProjectupdateRowSet(WrappedCachedRowSetXImpl crsxi) {
this.projectupdateRowSet = crsxi;
}
private WrappedCachedRowSetXImpl notifiedprojectRowSet = new WrappedCachedRowSetXImpl();
public CachedRowSetXImpl getNotifiedprojectRowSet() {
return notifiedprojectRowSet;
}
public void setNotifiedprojectRowSet(WrappedCachedRowSetXImpl crsxi) {
this.notifiedprojectRowSet = crsxi;
}
notifiedprojectRowSet is the rowSet for the outer table
and projectupdateRowSet is for the innter table