Best way to call a function in a generic class from a base class
Hi,
I have a generic class that works with subclasses of some other baseclass. When I construct the subclass, I call the constructor of the baseclass which I want to call a function in the generic class. e.g. suppose I have the following classes
public class List<T extends BaseClass>
newTCreated(T t)
}
Sorry, I pressed Tab and Enter last time when typing the code so I posted without meaning to
Hi,
I have a generic class that works with subclasses of some other baseclass. When I construct the subclass, I call the constructor of the baseclass which I want to call a function in the generic class. e.g. suppose I have the following classes
public class List<T extends BaseClass>
public void newTCreated(T t)
// add the t to some internal list
public T getT(int index)
// get the object from the internal list
public class BaseClass
public BaseClass(List<?> list)
list.newTCreated(this);
public class SubClass extends BaseClass
public SubClass(List<SubCass> list)
super(list);
}This doesn't compile because of the call to newTCreated in the BaseClass constructor because BaseClass is not necessarily of type T. Is there any way of checking when I call the newTCreated function that the BaseClass is actually of type SubClass? I could either add the call explicitly in each SubClass's constructor or have a function addToList in BaseClass that is called from the BaseClass constructor but overloaded in each subclass but both of those rely on future subclasses doing the same. Or I could change the newTCreated function to take an argument of type BaseClass and then cast it to type T but this doesn't give a compilation error, only a runtime exception.
It seems like there should be solution but having only recently started writing Generic classes I can't find it. Thanks in advance for any help,
Tom
Similar Messages
-
What is the best way to call a pageflow action from JavaScript?
What is the best way to call a pageflow action from JavaScript?
Thanks,
JohnJohn,
How would I do this from a grid??? Unfortunately there are no JavaScript attributes
on any of the grid tags that I can see.
Thanks,
John
"John H" <[email protected]> wrote:
>
Thanks John!
"John Rohrlich" <[email protected]> wrote:
John,
If you want to put up a confirm dialog before calling an action from
an
anchor it is done as follows.
Here is an example from code of mine that deletes a customer order,if
the
user confirms the delete. I pass the order id as a parameter.
- john
Here is the JavaScript -
function confirmDelete() {
if(confirm('Continue with order delete?'))
return true;
else
return false;
Here is a sample anchor tag -
<netui:anchor action="requestToDeleteOrder" onClick="return
confirmDelete(); return false;">
Delete
<netui:parameter name="orderId" value="{container.item.orderId}"/>
</netui:anchor>
"John H" <[email protected]> wrote in message
news:402138f5$[email protected]..
Thanks for the replies. I figured it was going to require buildingmy own
url
to call the action. I had hoped there was an easier way to do it.Rich,
the
reason I want to do this is because I want to call the JavaScript
function
confirm()
when a user clicks on a link (in a repeater/grid) to drop a record,I only
want
to call the drop action if the user confirms the drop. Maybe thereis a
better
way to do what I am trying to do??? I really appreciate any help
you
guys
can
give me on this, I am pretty new to this sort of stuff.
Thanks,
John
"Rich Kucera" <[email protected]> wrote:
"John H" <[email protected]> wrote:
What is the best way to call a pageflow action from JavaScript?
Thanks,
JohnTry figuring out the URL to the pageflow action, create a hidden
form
in the
page, then use JS to submit the form. Why would you want to though,
isn't
the server going to want to send you to the next page? -
Best way to call EJB - Servlet or Tag Library
Hi,
What is the best way to call an EJB from a JSP? We are using Weblogic 7.0(moving to 8.1 beta). WE have a form on a JSP that needs to get data from an EJB. Our flow goes from JSP --> Controller servlet or tag library -->EJB "Bean" Controller ---> EJB. The specfic EJB we need to populate drop downs and fields will be called by a bean controller. Is it better to call the bean controller using a tag library in the jsp or go to the controller servlet to get the data? If servlet is the answer, where do I lookup the EJB Home and call the create from within the servlet? Any help would be greatly appreciated!!
Thanks!IMO, if you are following some design patterns, like the MVC framework, the best thing is to populate the model(entities that contain the business data) and call the respective getXX methods from the model on the JSP page. The reason for doing so is to keep JSP pages away from any other work other than to just display the business data contained in the respective business entities.
The model can be populated in the servlet and either set in the request or session attribute as per the requirement.
The EJB can be looked up in the servlet as and when required. I would suggest to make use of the Service Locator Pattern to do a look up for the EJB Remote Interface and accordingly make the business calls.
Hopefully this answers some of your questions. -
What is the best way to call a report from within a report
What is the best way to call a report from within a report(master / Detail concept)
A type of drill down report
Oracle Database 10g
Forms 10.1.2.0.2
Report Builder 10.1.2.0.2Hi
Have a look in this link, certainly you will get fix, if not just post a comment on blog, will get reply soon
http://windows7bugs.wordpress.com/?s=oracle+10g+bug -
Is there a way to call a function with in the initializer of a ArrayCollection?
Is there a way to call a function with in the initializer of a ArrayCollection?
It won't let me do this:
var ac:ArrayCollection = new ArrayCollection([
{childName:'addTrade',index:addTradeIndex },
{childName:'tradeList',dealsCanvas.getChildIndex(tradeList) }The correct syntax is
var ac:ArrayCollection = new ArrayCollection([
{childName:'addTrade',index:addTradeIndex },
{childName:'tradeList',index:dealsCanvas.getChildIndex(tradeList) } -
which is the best way to call a scotland mobile phone from skype? i been using pay as u go credit and its 8 cents a min and was wondering if a monthly thing or a subscription is the way to go
Translation patterns are for internal use to manipulate a number and then a route pattern will be responsible for pushing it out the gateway or some other method. If this DID is still being sent to you you could either manipulate this at the CUBE and hairpin it backout or send it to CUCM and hairpin it back after it gets translated with a translation pattern out a route pattern. I would recommend doing everything at the gateway unless you want to keep some record that the number is in use which CUCM can do more effectively.
This DID being used for a fax is elsewhere offnet at this point I take it? Make sure you have the proper CSS's and partitions set for hair pinning if you do this on CUCM since by nature forwarding to external numbers is disabled by default (or at least it used to be as I recall). -
Best way to call oracle db from BPEL 2.0
Hi
Anybody knows which is the best way to call select or call store procedures from BPEL 2.0 ? Do I need to use JCD (java collaboration definition in repository-based projects -caps 5.x) and oracle eWAY to interact with oracle database?
Regards.You can also create a new WSDL with a concrete binding to DATABASE, as explained on http://wiki.open-esb.java.net/Wiki.jsp?page=CreatingAWSDLDocumentForTypeDATABASE
BRs
Kris -
What is the best way to call SSH commands through Java technologies
What is the best way to call SSH commands through Java technologies
I don't think you can specify the password at the prompt using ssh. Plink has the -pw command option for passwords. What I did was except ssh to ask me and write the password programmatically through the outputStream I obtained from my Process object. I looked for "password: ", and then wrote the password with a trailing newline.
Both plink and ssh will also ask if you trust the host if it is the first time you are connecting to it. So before just writing the password, check if the program wants verification from you: normally supplying "y" or "n". This should only have to happen the first time the client connects. It looks like thisPLINK:
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's key fingerprint is:
1024 f8:43:61:4c:a2:5b:77:be:5b:a7:bb:1f:f7:79:b3:b7
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)
SSH:
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is e1:02:13:c8:52:c2:23:41:9b:5b:58:2c:18:e6:59:af.
Are you sure you want to continue connecting (yes/no)?What I did was read character by character from the inputStream until I found things of interest ... like "password: ". You only need to search for this in your method which will launch the ssh or plink Process. Once you have verifyed yourself, you can just pass commands to the Process, which is an ssh connection.
My suggestion is to read() each byte from the Process's inputStream and write it to stdout. Look and see what you need to be looking for so you can interactive with the program correctly. You can't use readLine here becuase when the ssh asks for the password it does not print a newline. I do know for sure, that ssh will simply print, "passowrd: ". Plink will print this as well if the -pw option is not supplied. -
Calling a function in a flex app from a loaded SWF
How can I call a function in a flex application from a loaded
swf file?Two ways:
Application.application returns a reference to the top-level
application scope. You can access any public member, var, function,
component, etc through that reference.
Dispatch an event event form the loaded swf and use a event
handler in the main app. All the gurus advise this as best
practice, to ensure "loose coupling" It is also pretty easy,
especially if you use a bubbling event.
Tracy -
What is the best way to zero a 'custom voltage with excitation' sensor from the front panel?
What is the best way to zero a 'custom voltage with excitation' sensor from the front panel?
Thanks for any helpHi Donavan,
There are two options for zeroing with the NI-9237. You can perform offset nulling and shunt calibration with a strain task, or if you use custom excitation you can use software compensation.
See the Bridge Balancing, Offset Nulling section in the Load, Force, and Torque Measurements tutorial. Take a measurement before the strain is applied and subtract this from all subsequent measurements. See the above tutorial to consider the tradeoff in accuracy between these two options.
Hope this helps,
Jennifer O.
Applications Engineer
National Instruments -
Calling C Functions in existing DLL's from Java
Hi Guys ,
The tutorial in this site talks about creating ur own DLL's and then calling them from Java . I need to call C functions in existing DLL's from Java . How do I go about doing this ? . Any help on this would be much appreciated.
regards
muraliWhat you are interested in can be done with what's called "shared stubs", from the JNI book (http://java.sun.com/products/jdk/faq/jnifaq.html), although you don't need the book to do it (I didn't).
The example code will call functions with any number and kind of parameters, but doing that requires some assembly language. They supply working examples for Win32 (Intel architecture) and Solaris (Sparc).
If you can limit yourself to functions to a single function signature (number and types of parameters), or at least a small set that you know you'll call at compile time, you can modify the example so that the assembly language part isn't needed, just straight C code.
Then you'll have one C library that you compile and a set of Java classes and you can load arbitrary functions out of arbitrary dynamic libraries. In my case you don't even have to know what the libraries and functions are ahead of time, the user can set that up in a config file.
You mentioned doing this with Delphi. One thing to watch out for is C versus Pascal (Win32) function calling convention. A good rule of thumb; if it crashes hard, you probably picked the wrong one, try the other. :-) -
How to call a function in one .js file from another .js file
Hello Techies,
I am trying to call a function in two.js file from one.js file.
Here is my code
one.js
<script>
document.write("<script type='text/javascript' src='/htmls/js/two.js'> <\/script>");
function one()
var a;
two(a);
}two.js
function two(a)
alert("two");
}But the function two() is not working.
How can I do this one??
regards,
KrishI think there is a syntax error in line
document.write("<script type='text/javascript' src='/htmls/js/two.js'> <\/script>");
end tag <\/script> is wrong. -
whats the best way to transfer all my pic and vid files from Mac Air to back up drive to free up space on hard disk?
Get a third drive if needed, open the Time Machine pane of System Preferences, set it not to exclude that drive, and drag the files to it. If you're moving an iTunes or iPhoto library, launch the application with the Option key held down and choose the moved library.
(118789) -
What is the best way to use wi-fi to transfer pdf files from an ipad to a mac mini, not using an internet, just wi-fi?
If the Mac use Lion (10.7) you can use Airdrop for that.
With Mac's not using Lion you may set up a computer to computer (ad hoc) connection.
How to --> http://docs.info.apple.com/article.html?path=Mac/10.6/en/8339.html
Lupunus -
How to call a Java class from another java class ??
Hi ..... can somebody plz tell me
How to call a Java Class from another Java Class assuming both in the same Package??
I want to call the entire Java Class (not any specific method only........I want all the functionalities of that class)
Please provide me some slotuions!!
Waiting for some fast replies!!
Regards
Smita MohantyHi Smita,
you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
e.g.
you have developed A.java and B.java, both are in same package.
in implementaion of B.java
class B
A obj = new A();
//to access A's methods
A.method();
// to access A's variable
//either
A.variable= value.
//or
A.setvariable() or A.getvariable()
Maybe you are looking for
-
Using export slide show from iphoto, I am trying to create a DVD of photos and vid clips in large format. The vid clips do not work using burn software. Any idea?
-
Oracle 8.1.7 setup fails
When I try to start the Oracle 8.1.7 install (On an NT4 platform), I get a Java error in jrew.RPT as follows: Exception code: C0000005 ACCESS_VIOLATION Is this an Oracle issue?
-
10g XE + Windows Server 2008
Hi!!! I have a problem with oracle 10g Express Edition. My customer has Windows Server 2008 and oracle runs on this Os. But every day oracle stops run and i get this type of error. In alert_xe.log: 1. Tue Nov 17 09:53:55 2009 Warning: skgmdetach - Un
-
Completed Task cannot be launched again from the UWL.
Here is the situation. The identified agent clicked the task in the UWL. Task was launched in a new window and opened an ABAP webdynpro application correctly. Agent then approved the task using the approve button in the application. Task was thus com
-
Just bought a Pavilion touch screen & don't know how to rip CDs to library This question was solved. View Solution.