OOOOOPS!

Vinny,
don't ever think about using member variables this way.
Yo can't be sure that ND will retreive the same instance of a class for a
same user between two different request.
That's User Session Object are used for. (and in this case, Page Session
Object could also be used)
Even worst: with what you did, another user could retreive this member
variable and so data could be mixed between users.

Serge

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday 7 May 1999 16:16
To: [EMAIL PROTECTED]
Subject: [ND] Is member variable value maintained when load a new page?





Hi,
I have a "Select" button.  When clicked, it will set a value into a member
variable called
"numberOfElems", and also it will reload the same page with the populating
fields intact.

I hava a second button called "Insert".  I would like to retrieve the value
in
the member variable
called "numberOfElems".  But the value is never there.

It seems like the value of the member variable get reset to 0 when I reload
the
page in the "Select"
button.  Can someone confirm that is the case? and also is there any other
way
beside maintaining the
member variable to be able to keep the value when the "Insert" button is
clicked.

The following is the code segment.

really appreciated for any help on this.

Vinny


public class MasterPage extends spider.visual.CSpPage
//]]SPIDER_CLASS END
{
     public int numberOfElems = 0;
     public CSpString mode = new CSpString();
     public CSpVector resultSetVector = new CSpVector();
     public CSpVector resultSetVector2 = new CSpVector();
     //[[SPIDER_EVENTS BEGIN

     //[[SPIDER_EVENT<Insert_onWebEvent>
     public int Insert_onWebEvent(CSpWebEvent event)
     {
          numberOfElems = resultSetVector.size();

          int command = PROCEED;
          CSpInsert AddDocuments = (CSpInsert)
CSpider.getDataObject("N2Documents");
          CSpInsert AddApplDocs = (CSpInsert)
CSpider.getDataObject("N2ApplDocs");
          CSpCheckBox checkbox = (CSpCheckBox)
getDisplayField("*CheckBox1");
          CSpValue value = checkbox.getValue();
          CSpVector values;
          CSpVector results = new CSpVector();

          if (value instanceof CSpVector)
          {    values = (CSpVector)value;}
          else
          {    values = new CSpVector();
               values.put(value);
          }

          for (int i = 0; i < numberOfElems;i++)
          {
               value = resultSetVector.get(i);
               if (values.get(i).stringValue().equals("T"))
               {
                    AddApplDocs.setValue("DOC_ID",
getDisplayFieldValue("DOC_ID"));
                         AddApplDocs.setValue("MCN",
resultSetVector.get(i));
                    AddApplDocs.setValue("SRCITEMNO",
resultSetVector2.get(i));
                         AddApplDocs.setValue("NOTE",
getDisplayFieldValue("DOC_ID"));

                         command = AddApplDocs.execute();
               }
          }

          return(command);
     }
     //]]SPIDER_EVENT<Insert_onWebEvent>


     //[[SPIDER_EVENT<Select_onWebEvent>
     public int Select_onWebEvent(CSpWebEvent event)
     {

          resultSetVector = new CSpVector();
          resultSetVector2 = new CSpVector();

          mode.put("checkbox");
          CSpTextBox mcn = (CSpTextBox) getDisplayField("MCN");
          CSpRepeated RCheckBoxes = (CSpRepeated)
getCommonRepeated("RepeatedCheckBoxes");
          CSpSelect dobgetMcnList = (CSpSelect)
CSpider.getDataObject("N2AppSrc");

          dobgetMcnList.clearDynamicCriteria();

          if (!mcn.getValue().equals(""))
          {
               dobgetMcnList.addDynamicCriterion("MCN",

CSpCriteriaSQLObject.BEGINS_WITH_STR_OPERATOR,
                                   mcn.getValue());
          }
          dobgetMcnList.execute();
          if (dobgetMcnList.succeeded())
          {
               setMaxDisplayRows(dobgetMcnList.getNumOfRows());
               for (int i = 0; i < dobgetMcnList.getNumOfRows(); i++)
               {
                    resultSetVector.put(dobgetMcnList.getValue(i,"MCN"));
 
resultSetVector2.put(dobgetMcnList.getValue(i,"SRCITEMNO"));
               }
          }
          else
          {
               resultSetVector = null;
               resultSetVector2 = null;
          }
          dobgetMcnList.clearDynamicCriteria();

          numberOfElems = resultSetVector.size();
          return(load(false));
     }
     //]]SPIDER_EVENT<Select_onWebEvent>
}


_________________________________________________________________________

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