Solved

Constructor in desc file?

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat startup error 5 104
Java: How do I open the default windows program for a given file type 3 39
Running JavaFX on JDeveloper 12C 1 55
Java syntax, or is it Selenium 6 30
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

829 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