General information
Title:
Problems with class inherritence
(See the end for the WebCollection_ Class)
Here is the problem:
I have a WebTable_ class with a WebCollection_ class stored in a propertie and also a _GetOutput method.
In this WebCollection class i add WebRow_ classes.
The WebRow_ class also has a WebCollection_ class stored in a propertie and has a _GetOutput method.
In this WebCollection class i add WebCell_ classes.
( In each class WebCollection_ class is stored with
CREATEOBJECT( 'WebCollection_' ) )
Example: i have 1 table with 3 rows and each row has 3 cells.
When i call the WebTable_:_GetOutput() this method builds a string and calls the WebCollection_:_GetOutput(). This method loops through the object array and calls for each WebRow_ class the WebRow_:_GetOutput(). This method builds a string and calls the WebCollection_:_GetOutput(). The method loops through the object array and calls for each WebCell_ class the WebCell_:_GetOutput().
This method builds a string and returns.
Finally i should get a full string containing a HTML Table with 3 rows and each row 3 cells.
But it's going wrong in the WebCollection_:_GetOutput method.
What i get is a table with 3 rows, the first row has 3 cells. But the next rows ( as many as you like ) have each 1 cell ( the last WebCell_ in the WebCollection class ).
When i call the _GetOutput method for each WebRow_ class in the WebCollection class of the WebTable seperate, it get the right string back.
When i subclass the WebCollection_ class twice and copy and paste the _GetOutput method from the WebCollection into these subclasses and than i use for the WebTable_ and the WebRow_ classes these different subclasses i get the right string.
am I doing something wrong? I can't see it.
I think when i use the WebCollection class multiple times in the same tree structure fox does something wrong with the object array-properties.
Does somebody know this 'problem' or know what to do?
***********************************************
Class WebCollection (based on the Custom class)
***********************************************
array-propertie: _objects[ ]
methods: _AddObject() and _GetOutput()
*****************************
WebCollection:_AddObject
*****************************
LPARAMETERS cpClassName, opObject
WITH This
IF NOT EMPTY( cpClassName ) OR TYPE( 'opObject' ) = 'O'
._ActiveObject = NULL
._ObjectCount = ._ObjectCount + 1
DIMENSION ._Objects[ ._ObjectCount ]
._Objects[ ._ObjectCount ] = IIF( TYPE( 'opObject' ) #;
'O', CREATEOBJECT( cpClassName ), opObject )
._ActiveObject = ._Objects[ ._ObjectCount ]
ENDIF
ENDWITH
RETURN ( This._ActiveObject )
*******************************
WebCollection:_GetOutput
*******************************
LOCAL cOutput, oObject
cOutput = ''
WITH This
IF ._ObjectCount > 0
._ActiveObject = NULL
FOR EACH oObject IN ._Objects
IF TYPE( 'oObject' ) = 'O'
cOutput = cOutput + oObject._GetOutput()
ENDIF
ENDFOR
._ActiveObject = ._Objects[ 1 ]
ENDIF
ENDWITH
RETURN ( cOutput )
Thanks for reading.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only