Solved

Constructor in desc file?

Posted on 1997-06-04
3
230 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
numbers ascending pyramid 101 236
How do I remove an object from a 3 51
login form jsp example 2 50
Why doesn't this text field show up on my Applet frame? 2 28
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 second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This video teaches viewers about errors in exception handling.

740 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