Aby, Curt, Peter,
Thanks for your responses. I like the idea of creating a custom myPage class
in case I need to use it for other pages.
I discovered that getChildren() returns everything on the page including any
buttons and SPIDERSESSION stuff. I am checking for objects of type
CSpDisplayField and it lists everything on the page.
Of course I can add code to skip buttons,static text etc. or skip objects
where getBoundDataField() is Null but is it the normal behavior of
getChildren()?
Here's my small test:
--------------------------------
package MCSC;
import spider.*;
import spider.session.*;
import spider.visual.*;
import spider.html.*;
import spider.util.*;
import java.util.*;
public class myPage extends spider.visual.CSpPage
{
public void saveFieldValues() {
CSpVisualsList myPageChildrenList = getChildren();
for (Enumeration e = myPageChildrenList.elements();
e.hasMoreElements();)
{
Object nextValue = e.nextElement();
if (nextValue instanceof CSpDisplayField) {
CSpDisplayField theChild = (CSpDisplayField)
nextValue;
CSpHtml.sendMessage("Child is
CSpDisplayField "+ theChild.getName()+"<br>");
CSpDataFieldRef boundDataField =
theChild.getBoundDataField();
CSpHtml.sendMessage(" with data field="+
boundDataField+"<br>");
}
else {
CSpHtml.sendMessage("Child is
"+getClass()+"<br>");
}
}
}
} // end of myPage class
-----Original Message-----
From: Curt Springer [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 04, 1999 12:22 PM
To: Shamdasani Nimmi-ANS004
Cc: 'NetDynamics'
Subject: Re: [ND] Storing the Dataobject into a userSessionObject
At 10:34 AM 10/4/99 -0500, Shamdasani Nimmi-ANS004 wrote:
>Hi All,
>
>I have 2 questions:
>
>1. How do I get a list of all the display fields in a page and the
>corresponding dataobject column name that they are bound to.
getChildren() gives you everything one level below the page. It will
include the CSpPageSessionHidden object, and any CSpRepeateds.
To get all children at any level, start with the page and call recursively
on any CSpRepeateds you find along the way.
The children are returned as CSpVisuals. Data-bound fields are
CSpDisplayFields. You can call getBoundDataField() on these to get a
reference to the bound data object column.
>2. I have a page based on a dataobject. There is a button on the page which
>takes the user to next page. On the webEvent of the button, before
>proceeding to the next page, I want to store the name and value of all
>bound display fields(i.e., the whole DataObject) into a userSessionObject.
>The data in USO will be saved into the database at some later point.
>
>Is there a better way than creating a hash table to store the name&value
>pair of all data fields and then storing the hash table into the session
>object?
A hash table is a pretty good way to do this. If you went to the trouble
to build some sort of class for this, it would probably have a hash table
inside, anyway.
BTW, you've probably figured out that you should do the field--data column
lookups as part of init processing, not at runtime.
-- Curt Springer, Team ND
>Thanks.
>
>-Nimmi
>
>_________________________________________________________________________
>
>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]
_________________________________________________________________________
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]