Solved

Constructor in desc file?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Eclipse Neon and jdk 1.8.0 11 138
Systems talking to each other 5 126
how do i compare an object based on two fields 6 49
Java JRE greater than 1.6 5 50
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

895 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

18 Experts available now in Live!

Get 1:1 Help Now