It's time to leave the world of pointy-clicky, Janet!!!

Suggestion:
-- no DOs bound to page.
-- one CSpRepeated, no bound fields
-- Some naming convention that maps table name to DO (we use
"TransMultiSQL" plus table name).

-- onAfterInit processing, set up field references for faster session
processing: 

_fieldrefs = new CSpDisplayField[_column_field_bindings.length];
for (int i = 0; i<_fieldrefs.length; i++)
{
_fieldrefs[i] = getDisplayField("*".concat(_column_field_bindings[i][1]]));
}//for (int i = 0; i<_fieldrefs.length; i++)

-- page-level onBeforeDisplay processing, assuming you somehow know which
table you want:

//get reference to data object to be used now
_dataobject = CSpider.getDataObject("yourprefix".concat(tablename));
//naming convention not strictly necessary, could just  have if..else
if..else if processing

//set up column positions to save time processing each row
//concoct data object column name using data base owner name plus table
name plus column name.
for (int i = 0; i< _column_field_bindings.length; i++)
{
_colposarray[i]
=dataobject.getDataFieldPosition("DBONAME_".concat(tablename).concat("_").co
ncat(_column_field_bindings[i][0]));
}//for (int i = 0; i< _column_field_bindings.length; i++)

//execute data object
_dataobject.execute();
//in real life test succeeded() and throw exception if not

--repeated-level onBeforeDisplay processing:

CSpRepeated rpt = (CSpRepeated) event.getSource();
//set number of occurrences, based on result set
                int size = _dataobject.getNumOfRows();
                
                CSpRepeated rpt = (CSpRepeated) event.getSource();
                        rpt.setCurrFirstRow(0);
                        rpt.setCurrNumOfRows(size);
                        rpt.setMaxDisplayRows(size);

-- repeated-level onBeforeRowDisplay processing:

int rowindex = event.getRowIndex();

//load fields from current results set row:
for (int i = 0; i<_colposarray.length; i++)
{
_fieldrefs[i].setValue(_dataobject.getValue(rowindex, _colposarray[i]));
}//for (int i = 0; i<_colposarray.length; i++)

-- member variables:

private CSpDataObject _dataobject;      //to be set in onBeforeDisplay

private String[][] _column_field_bindings=
//will contain one array per column/field binding, first entry will be name
of column (w/o dbo or table names),
//second entry will be name of field
{
  {"NAME", "tbName"}
, {"ADDRESS", "tbAddress"}
, {"PROVINCE", "cbProvince"}
, {"POSTAL_CODE", "tbPostalCode"}
};//private String[][] column_field_bindings=

private CSpDisplayField[] _fieldrefs;   //will be loaded in onafterinit with
references to page field objects

private int[] _colposarray;  //will be loaded during display processing
with column positions of columns in _column_field_bindings

== Curt Springer, Team ND



At 10:04 PM 6/23/99 -0400, [EMAIL PROTECTED] wrote:
>
>
>
>I have a page with a Repeated where the Data Object bound to the Repeated,
has
>SQL something like:
>     SELECT col1, col2, col3, col4, col5
>     FROM tableX
>     WHERE X_id = xxxxx
>
>At runtime I'd like to be able to conditionally change the FROM and WHERE
clause
>to reference another table but selecting the exact same 5 column names.
>
>What would be the best way to do this? Some guesses:
>
>1. override the DO's SQL via code. If this is best solution, do you recommend
>full text override or partial? (I know the code snippet syntax for full text
>override, but not partial.)
>
>2. Put 2 Repeateds on the page (each bound a diff DO)  and in their
>_onDisplayEvent do the condition chk and return SKIP or PROCEED to only
show one
>of them. If I did that, will the Repeated being skipped still retrieve its
rows
>from the database even if I'm not displaying them?
>
>Thanks,
>Janet
>
>
>_________________________________________________________________________
>
>For help in using, subscribing, and unsubscribing to the discussion
>forums, please go to: http://www.netdynamics.com/support/visitdevfor.html
>
>For dire need help, email: [EMAIL PROTECTED]
> 
_________________________________________________________________________

For help in using, subscribing, and unsubscribing to the discussion
forums, please go to: http://www.netdynamics.com/support/visitdevfor.html

For dire need help, email: [EMAIL PROTECTED]

Reply via email to