Solved

Constructor in desc file?

Posted on 1997-06-04
3
218 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
  • 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
for i loop in grovy 1 32
Starting to learn JAVA, 7 47
Non-recursive backtracking, using a stack 1 48
Java DateChooser? 2 5
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now