 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
steve_32168 Guest
|
Posted: Fri May 07, 2004 9:08 am Post subject: Designer problem with multiple DB DataModules |
|
|
Hello,
I'm, not sure in which forum to post: IDE or Database?
But the problem seems to be the IDE Designer...
Using JBuilder 9 (German edition), I 'm trying to write an application,
that has about 10 different GUI views (=> n Java frames/dialogs for just
as much Oracle tables/views).
To avoid one big DataModule with lots of column property declarations
(would be more than in AppDataModule.java from the MultiLingual sample),
I tried to use multiple DataModules (MyDataModule1..n), each for every
GUI view. Each DataModule should use the same Database object in MyDbModule:
public class MyDbModule
{
static MyDbModule theInst = null;
Database db = null;
public static getInstance()
{
if (theInst == null)
theInst = new MyDbMoule();
return theInst;
}
private MyDbModule()
{
db = new Database();
db.setConnection(new ConnectionDescriptor("...");
}
public Database getDb()
{
return db;
}
}
public class MyDataModule1 implements DataModule
{
static MyDataModule1 theInst = null;
QueryDataSet qds = new QueryDataSet();
... (singleton stuff)
private Database getDb()
{
return MyDbModule.getInstance().getDb();
}
private void jbInit()
{
qds.setTableName("tab_mytable");
qds.setQuery(new QueryDescriptor(getDb(), "SELECT ...";
}
}
The Application runs fine so far, but during design time, the JBuilder
Designer says: "qds: Connection property of database not set" (org.
message was in german) and shows no table columns for the QueryDataSet qds.
It seems, the Designer can't decode the getDb() call in the line:
qds.setQuery(new QueryDescriptor(getDb(), "SELECT...");
The only (dirty) workaround I found to make the Designer work, is to
'show' him an explicit database connection with a class member Database
object, here called tempDb.
To skip this explicit connection line during run time, this part is
'hidden' inside an 'if (false)' statement.
This works only in an separate method (here in a modified getDb()) and
not directly in jbInit().
So now it looks something like this:
public class MyDataModule1 implements DataModule
{
...
Database tempDb = null;
private Database getDb()
{
if (false) // Skip during runtime!
{
// Explicit connection for Designer: works even tempDb is null!
tempDb.setConnection(ConnectionDescriptor(...);
}
else // Runtime: assign 'real' Database to tempDb, used in jbInit()
{
tempDb = MyDbModule.getInstance().getDb();
}
return tempDb;
}
private void jbInit() throws Exception
{
qds.setTableName("tab_mytable");
getDb();
qds.setQuery(new QueryDescriptor(tempDb, "SELECT...");
}
Although it seems to work: Is there a better way to reach the original
goal: Multiple DataModules using one Database class - with a working
Designer?
Thanks
Steve
|
|
| Back to top |
|
 |
Lori M Olson (TeamB) Guest
|
Posted: Fri May 07, 2004 3:04 pm Post subject: Re: Designer problem with multiple DB DataModules |
|
|
steve_32168 wrote:
| Quote: |
Although it seems to work: Is there a better way to reach the original
goal: Multiple DataModules using one Database class - with a working
Designer?
Thanks
Steve
|
Well... a better work around is to properly detect that you are
designing as opposed to running.
I think the call is java.beans.Beans.isDesignTime().
--
Regards,
Lori Olson (TeamB)
------------
Save yourself, and everyone else, some time and search the
newsgroups and the FAQ-O-Matic before posting your next
question.
Google Advanced Newsgroup Search
http://www.google.ca/advanced_group_search
Other Newsgroup Searches:
http://www.borland.com/newsgroups/ngsearch.html
Joi Ellis's FAQ-O-Matic:
http://www.visi.com/~gyles19/fom-serve/cache/1.html
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|