Components and sub-components
Components and sub-components
- Subject: Components and sub-components
- From: David Griffith <email@hidden>
- Date: Wed, 05 Nov 2003 19:59:13 +0100
HI all,
I will try and describe this as clearly as possible, if anyone could please
tell me if this is the correct approach or if I am missing something...
I have a component ShowPhoto - it contains a header jpg, a menu bar, a table
with photo and details from a database and a search box at the bottom.
There is a lot of code in the ShowPhoto component relating to the current
photo, getting info from the database etc.
I also have a MenuBar component which I have inserted into the ShowPhoto
page as a custom WebObject. It is not a subclass of ShowPhoto and it works
well.
The search box at the bottom again is the same, it9s inserted as a custom
WebObject and is not a subclass of ShowPhoto.
Now, I wanted to have two templates which would display the photo and text
in a different way, but would leave everything else on the page as is.
There are also buttons on the page to move the next photo and previous, and
these generally work the same on every ShowPhoto page and use methods from
ShowPhoto.
I created two components templHoriz and templVert. These are set to extend
ShowPhoto (as subclasses) as I want them to have access to the methods and
variables of ShowPhoto. (I assume this is what I should do, tell me if
not!). Then I have conditionally inserted the templates into ShowPhoto
based on a boolean. Ie. There are two custom WebObjects on ShowPhoto, which
will display depending on the boolean.
This all works lovely except that I am finding some very weird behaviour
with variables. I assumed from this setup that the templates would be able
to use and modify all the variables of ShowPhoto.
The photos are displayed based on an array which is currently a session
variable. I have a WOPopUpButton which allows the user to select a value.
This bit is a little tricky and after hours last night I finally discovered
that the selection9 binding is only set when the form is submitted. So I
wrapped the button in a form and set the onChange9 binding to submit it.
The submit does a method in ShowPhoto called refreshPage9. Simply, it sets
a boolean in ShowPhoto which will indicate whether or not to include some
javascript in the header the next time the page loads.
The anomale I have encountered is that when this value is set in ShowPhoto,
it does not appear to maintain this value when the page is refreshed. I.e.
The refreshPage method sets it to YES (for example) and I have confirmed
that at that point it is YES. Then it returns null to refresh the page but
the results indicate that the value was NO. However in the template
(subclass of ShowPhoto) the value appears to be correct as another item on
that page DOES display as a result of the YES (which is what I expected).
So how can the value have two different values at different stages when
there is nothing to change it in between? The only reason I can think of is
SCOPE, although I can9t see how. So, I moved that boolean value into the
session class instead and it works fine. But there are others that don9t
(because I haven9t moved them to the Session class and I don9t see why they
should be there).
Can anyone (if you can make sense of this) see what the problem is here? I
would be happy to go into a bit more detail directly if necessary as I am
concerned there might be a core flaw in my design and I don9t want to
continue working that way if it9s incorrect.
Please help!
Dave.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.