Solved

Constructor in desc file?

Posted on 1997-06-04
3
235 Views
Last Modified: 2010-04-16

I'm using Visual Cafe Pro.

In my applet, I'm including a class, that needs to get the
applet object, or appletContext, in order to call showStatus,
 I can do this by sending the applet in the class's constructor - MyClass myClass1 = new MyClass(this);
However I want the class I'm including to be a Visual Cafe
component, and I want the 'new' statement to be added automatically, when I include the class.
This isn't a problem, however: Visual Cafe Pro adds the
class using a default constructor:
MyClass MyClass1 = new MyClass();
And I need it to send the applet ( add a 'this' in the parentheses ).
I think that this needs a special change to the classe's
desc file.
Something simmilar to: "%name% = new %class%(this);"
But this, by itself doesn't work.

What can I do?

Oded.

oded@gsit.co.il
0
Comment
Question by:odo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Expert Comment

by:keegi
ID: 1221216
Do I understand you correctly, that you want to create new instance of class, given class name, and using non-default constructor?

If so, you need to use JDK 1.1, because in JDK 1.0.2 you can only use:

String name = "A";
Class classToInstantiate = Class.forName(name);
Object instance = classToInstantiate.newInstance();

which invokes default constructor, and there is no way to change this.

You need to either: re-structure your program to be able to use default constructror and then pass the information later
or: move to JDK 1.1

0
 

Author Comment

by:odo
ID: 1221217
Edited text of question
0
 

Accepted Solution

by:
keegi earned 50 total points
ID: 1221218
Well.. it seems my previous comment came out totally off...

I studied this problem and came to the conclusion, that this thing is most likely the thing you cannot do that way. Visual Cafe Pro component description files don't allow you to specify anything non-standard about code generation.

The standard toolbar items in VCafePro, some of them do have such non-default constructors, but information about that is coded in very different way, and stored in VPOJAVA.DLL. I took a look at the DLL, and the only thing about the DLL I can say, is that it has very different methods to describe the component - and the code it generates. The DLL contains even fragments of  somewhat different description language.

So, my suggestion would still be:
Create default constructor in your class, and set the values to some dummy ones.
Initialize the instance later.

P.S. There seems to be one undocumented keyword in .DESC file:
FLAGS=
but I have no idea about how it works or what it does, or even about the syntax it has
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb mdb examples 1 38
Cisco ASA: Java web start no go, asdm launcher no go 3 88
dao vs facade design patterns 2 69
IBM TS2900 (3572) Tape Autoloader Java? 12 106
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question