Re: api variables
Re: api variables
- Subject: Re: api variables
- From: benoit cantin <email@hidden>
- Date: Tue, 05 Sep 2006 17:37:05 +0200
First of all, thank you for your answer.
I am working on the same project (a CMS).
Hi, Laetitia,
On Sep 4, 2006, at 5:45 PM, Laetitia Orsini wrote:
Hello,
I'm a newbie and after having developed my first "complex" webobjects
application I wonder if it was the right way to do it... The aim of the
application is to offer an interface to manage contents stocked in a
database. I have at the end many reusable web components with many api
variables. Within these api variables I send the edited objects and a
lot of booleans to deal with the layout with conditionals. Is it a
common way to do things in a web objects application ? Doesn't it look
like dirty javascript ?
It's not clear what you're asking here. However, it sounds like you may
be trying to do some things that WebObjects (WO) would do for you more
easily if you would let it.
Here is an example of what we are doing. An entity called "Artist"
references instances of an entity called "Album". We have 2 Web
components, one which let users customize Artist properties, let's call
it component1, and the other which let users customize Album properties
(component2). Both components are reusable ones. Main component defines
an instance of component1, and component1 defines an instance of
component2. A variable called "theEditedArtist" is passed from Main to
component1, and to component2 as an API variable. The reason is that we
must get modification on "theEditedArtist" made in component2 back to
Main. Identically, Boolean API variables are passed to component1 from
Main to enable/disable blocks visibility in component1. Other Boolean
API variables are passed from Main to component2 (which is attainable
from Main and component1). You guess that those Boolean variables are
passed from component1 to component2. These API variables must be in a
coherent state, since they control component1 and component2 display,
themselves displaying on the same screen area.
So the problem is to maintain Boolean coherency, otherwise :
-if all Booleans are set to false : no display.
-if all Booleans are set to true : multiple overlaying displayed components.
It might help to review an example. Take a look, for instance, at the
ThinkMovies example at:
/Developer/Examples/JavaWebObjects/ThinkMovies/
This application also uses the JavaBusinessLogic framework whose source
code you can find at:
/Developer/Examples/JavaWebObjects/Frameworks/JavaBusinessLogic/
In order to build and run the example, you will also need to start the
WOMovies OpenBase database, but you can review the code and WO
Components without doing that, if you don't wish to take the trouble to
build the application. If you do want to build the app, Apple recommends
that you copy the project to your own work area first, and not modify
the code in the Examples directory.
What are the differences between api variables and non synchronized
variables ?
Thank you for the tip. I think it doesn't simplify our design. If my
understanding is good, they define MovieComponent in order to share
movie variable declaration and other static variables definitions. But
it doesn't answer our synchronization need. Good ?
The api variables for a component may be synchronized or
non-synchronized. Synchronized, means that WO will push any variable
values through the api variable bindings from the parent to the child
component, then pull the values from the child component back to the
parent component both before and after each of the Request/Response loop
method calls (appendToResponse, takeValuesFromRequest and invokeAction).
That means that the values will be pushed downward and pulled upward
across the component/subcomponent interface six times for each page
rendering and user response to the page.
Though this approach is not particularly efficient, it tends to keep
people new to WO out of trouble. To make the value transfers more
efficient, you can override the synchronizesVariablesWithBindings method
in your subcomponent to return false, which will stop WO from doing the
six push/pulls for you. In that case, you will probably use the
WOComponent valueForBinding and setValueForBinding methods to push and
pull the values yourself. Although this is more efficient, it is also
more work on your part. For a small, local, low traffic, administrative
application (e.g. an app that will be used by fewer than 10 or 20 people
each day on the LAN), I probably would let WO synchronize the values.
So API variables sounds good in our case.
I also wonder if this kind of applications would be more quickly
implemented with Direct To Web. I've made some tests with Direct To Web
on my database model but it seams I'll still have a lot of work to
customize things if I want the same features as in my own application.
For example, if I have an entity Album that contains Singles, I would
like to be able to edit Singles just by clicking on a Single listed in
my edited Album.
This is doable in Direct To Web (D2W) without freezing the components.
I don't find any clue on how to do this. We found that to-many
relationships where listed in a D2WToManyRelationShipsFault (from what I
remember) which only displays Single instances, but doesn't let the user
navigate to an edit Single instance page.
It seams it's not easy to customize relationships with
Direct To Web. If I have to freeze each component to customize
everything will it still take less time than if I do the entire
application by myself ?
If your interest is simply providing a convenient administrative
application for a well structured database, you can't beat D2W for
convenience. If you get good at using D2W, you would probably be able to
build your administrative application faster with it, even if you're
customizing a few components. However, if you find yourself customizing
most, or all, of the components because you're more concerned about a
custom look and feel than simply administering the data, then you would
probably be better off not using D2W.
It's also true that if your database is not well laid out (for instance,
a badly structured legacy database that you can't change but are being
forced to use), then you would probably be better off developing a
custom app without D2W.
Is Direct To Web a common used tool to make
advanced interfaces to manage data or it is more for testing models ?
Those who are very good with D2W use it commonly to make advanced
interfaces to manage data. They also mix its use with custom component
development. However, in doing so, they are mixing two technologies and
to do that, you should be fairly adept at using each one individually.
It makes sense. Thank you for your advice.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden