Parent function calling a child function with arguments
Can anyone give examples of a parent function which has at least 1 parameter, and is invoked from the Form Behavior, which in turn , depending on data, invokes 2 or more child functions passing to these functions the same parameter that was passed in to it.
I am getting 'Object required' and do not know what I am doing wrong. Please let me know if you've done it, and how you've referenced it , if they are BOTH functions. Thank you!
The best way to do this is probably using delegates, but to do it directly you have to solve the circular dependency problem (as you have discovered). See
http://en.wikipedia.org/wiki/Circular_dependency
In case it is not clear to you how the Wikipedia article relates to your case, your files should look something like this:
// Form1.h
#include "Watch.h"
ref class Form1: public Form
public:
void SomeMethod()
// implementation
private:
void SomeHandler()
Watch watchForm(this);
watchForm.ShowDialog();
// Watch.h
ref class Form1; // declaration only
ref class Watch: public Form
public:
Watch(Form1^ f1);
private:
Form1^ form1;
void SomeMethod();
// Watch.cpp
#include "Watch.h"
#include "Form1.h"
Watch::Watch(Form1^ f1)
form1 = f1;
void Watch::SomeMethod()
form1->SomeMethod();
David Wilkinson | Visual C++ MVP
Similar Messages
-
Call function with arguments in AS3
Hello!
I`m a new in Flex developing, and cannot understand same code
convention, im Java programmer.
How I can write correct function call in ActionScript, my
call: var goodsWnd:CreateGoodsWindow =
PopUpManager.createPopUp(this,
CreateGoodsWindow, true) as CreateGoodsWindow;
I wish call function above with argument, how I do that?
Where my class: public class CreateGoodsWindow extends
extends TitleWindow
public CreateGoodsWindow(data:Object)
}Use PopUpManager.addPopUp() instead of createPopUp().
addPopUp takes an object that has already been instantiated:
var createGoodsWindow:CreateGoodsWindow = new
CreateGoodsWindow(data);
PopUpManager.addPopUp(createGoodsWindow); -
How to invoke a function with arguments in JSTL expressions
Hi ,
I want to know how to send arguments in the JSTL expression.
I have a scenario like this
for (int i=0; i<nicList.size(); i++)
NavigationItemControl nic = nicList.get(i);
ni = nic.getNavigationItem();
//scr
if (nic.isAvailable(Mask.SYSTEM))
{ %>
<option value="<%=ni.getInternalHandle()%>" <% if(pi.getNavigationItemHandle().equals(ni.getInternalHandle())) {%>selected<%}%> ><%=nic.getLabel()%></option>
<%
} I was changed these code into JSTL ,the new one is
<c:forEach var="nic" items="${nicList}">
<c:set var="ni" value="${nic.navigationItem}"/>
<c:set var="nicAvailableMaskSystem" value="${*nic.available*}"/>
<c:set var="navigationItemHandle" value="true" />
<c:if test="${nicAvailableMaskSystem}">
<option <c:if test="${pi.navigationItemHandle==ni.internalHandle}"> selected </c:if> value="${ni.internalHandle}" >
${nic.label}
</option>
</c:if>
</c:forEach>in the above code I have problem with nic.isAvailable(Mask.SYSTEM),
Can any one help me on this how can I invoke a function in JSTL with arguments.
-BhaskarJSTL can only handle getter/setter methods. You can't pass parameters to the methods.
There are a couple of ways around this
1 - set up "mask" as a seperate attribute of the NavigationItemControl bean.
ie getMask() setMask()
and then have your isAvailable method as
public boolean isAvailable(){
return internalIsAvailable(getMask());
}Another solution is to define a static function and invoke it as a function.
public static boolean navigationAvailable(NavigationItemControl, Mask);
What does the isAvailable() method do? How complicated is it?
Hope this helps,
evnafets -
(JavaScript, CS3) calling functions with arguments on click?
Hi all,
this is getting tricky:
I want to call a function when the user clicks on a button in my scripted application (a javascript window dialog).
Unfortunately, I need to pass several arguments to the function.
According to the scripting documentation, ".onClick" functions won't take arguments.
I would (somewhat reluctantly) work with (global) variables but the function itself is limited to variables within its own scope - blocking all variables set in main()
How should I approach this?
The basic idea is to have people set some settings in the UI and then do some things after they click ok.
The actual work is pretty complicated (replacing colors etc) and needs to be done to a lot of objects so it would make sense to do it in a function.
I'm pretty confused right now and don't know how to proceed.
Any hints are appreciated.
Many thanks,
MikeIt took some tinkering but I got it to work.
But I still don't see how I can access the whole DOM from within the onClick functions:
I can get to the dialog properties (this.parent.parent) but nevertheless don't have any way to access app.documents and such.
I was able to manage my way around by making the whole window a dialog instead of a window - thereby getting a return value from the OK button and being able to run the code from within main().
Still strange, though...
Cheers,
Mike -
Calling a stored procedure with argument as column name
hi
i am calling a stored procedure mapping_audit_errors_inserts
whose definition is as follows
PROCEDURE mapping_audit_errors_inserts (
in_ma_seq_id IN ETL_MAPPING_AUDIT_ERRORS.ma_seq_id%TYPE,
in_etl_stage IN ETL_MAPPING_AUDIT_ERRORS.etl_stage%TYPE,
in_sqlerrcode IN ETL_MAPPING_AUDIT_ERRORS.sqlerrcode%TYPE
IS
BEGIN
mapping_audit_ora_errors (in_ma_seq_id,
in_etl_stage,
in_sqlerrcode,
get_error_message (in_sqlerrcode)
END;
now i need to call this procedure as
mapping_audit_errors_inserts(MA_SEQ_ID.currval,1,v_error_code)
[ v_error_code:=SQLCODE;]
it is giving error as
PLS-00201: identifier 'MA_SEQ_ID.CURRVAL' must be declared
can anyone calrify me on this.
ThanksAnwar is likely correct about the reason for your error. The other possibility is that the owner of the procedure calling mapping_audit_errors_inserts does not have SELECT on the sequence granted directly to them.
However, even after creating the sequence, if the session calling the procedure has not got a value from the sequence prior to trying to use CURRVAL, you will get:
SQL> CREATE PROCEDURE p(p_id IN NUMBER) AS
2 BEGIN
3 DBMS_OUTPUT.Put_Line('ID is '||p_id);
4 END;
5 /
Procedure created.
SQL> DECLARE
2 l_no NUMBER;
3 BEGIN
4 SELECT ma_seq_id.CURRVAL INTO l_no
5 FROM dual;
6 p(l_no);
7 END;
8 /
DECLARE
ERROR at line 1:
ORA-08002: sequence MA_SEQ_ID.CURRVAL is not yet defined in this session
ORA-06512: at line 4And, just to reinforce Anwar's point about selecting it into a variable, if you try to pass CURRVAL to a procedure, you will get:
SQL> DECLARE
2 l_no NUMBER;
3 BEGIN
4 SELECT ma_seq_id.NEXTVAL INTO l_no
5 FROM dual;
6 p(ma_seq_id.CURRVAL);
7 END;
8 /
p(ma_seq_id.CURRVAL);
ERROR at line 6:
ORA-06550: line 6, column 16:
PLS-00357: Table,View Or Sequence reference 'MA_SEQ_ID.CURRVAL' not allowed in
this context
ORA-06550: line 6, column 4:
PL/SQL: Statement ignoredTTFN
John -
Inheritance problem with parent class calling child class
I have a problem with inheritance with a parent class calling a child class method. Below is the example pseudocode code and my problem:
public abstract class A {
protected void function1 ( ) { }
protected void function2 () {
//calls function1();
function1();
public abstract class B extends A {
protected void function1 () {
// do stuff
public class C extends B {
protected void function1 () {
// do stuff
super.function1 ();
}I have an object instance of class C created and its function2() is invoked.
My problem is, while in function2(), which belongs to abstract class A and the method call to function 1() is called, the call invokes the function1() of class B. Shouldn't the call invoke function 1() of class C instead? And then function1() of class B will be called after due to the super.function1(). It's not behaving like I thought it would.
Edited by: crono77 on Jan 10, 2008 8:13 PMNevermind, i found my error :)
-
HTML5 Canvas: Calling a parent function
Hey guys
I'm currently banging my head against a brick wall trying to call a parent function with the HTML5 Canvas.
I have the following code on the stage:
function fromStage()
console.log("This is on the stage");
fromStage();
This correctly outputs that message to the console in the browser.
However, I have a button within a movie clip that I want to call this function from, my code in that movie clip is as follows:
this.theButton.addEventListener("click", fl_MouseClickHandler.bind(this));
this.theButton.name = "theButton";
function fl_MouseClickHandler(e)
this.parent.fromStage();
However, this doesn't appear to be working, any ideas?
Thanksuse:
on the stage:
this.fromStage=function()
console.log("This is on the stage");
this.fromStage();
code in that movie clip is as follows:
this.theButton.addEventListener("click", fl_MouseClickHandler.bind(this));
this.theButton.name = "theButton";
function fl_MouseClickHandler(e)
this.parent.fromStage(); -
Listener calls Function plus Arguments??
Hi guys,
Not sure if there's an easy way to do this, I'd like a
listener to call a function with arguments when triggered.
Currently, what I have looks like this:
object.addEventListener(errorTrigger, functionToCall);
public function functionToCall():void {
...you get my idea...
And, I'd really like to add some arguments to the function. I
realize that if I use:
object.addEventListener(errorTrigger,
functionToCall(myArgument));
then it will want
functionToCall to
return a
function name to be used. Hopefully, you're still with me on
this...
The reason I want to add the arguments, is because I have
three different listeners.
And I'd rather not have three different functions to deal
with them, I'd rather consolidate it into one function and use the
argument to distinguish the difference.
Rather than:
object.listener(error1, function1);
object.listener(error2, function2);
object.listener(error3, function3);
function1 ():void {}
function1 ():void {}
function1 ():void {}
I'd prefer something like:
object.listener(error1, function(1));
object.listener(error2, function(2));
object.listener(error3, function(3));
function(num):void {}
Hopefully, that all makes sense. Sorry, I'd post the code,
but it's way to long, and I'd rather not confuse anyone with
something else contained within it.
More than happy to try and cut it down if someone needs to
see the code though.
Cheers
OzThanks for your efforts, I don't quite know whether it's what
I'm looking for though.
The events I am using are predefined by Flex's upload
function. So, this may help:
fileUpload.addEventListener(HTTPStatusEvent.HTTP_STATUS,
uploadError);
fileUpload.addEventListener(IOErrorEvent.IO_ERROR,
uploadError);
fileUpload.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
uploadError);
And I'd really like to add the parameters to the end, like
so:
fileUpload.addEventListener(HTTPStatusEvent.HTTP_STATUS,
uploadError(param));
fileUpload.addEventListener(IOErrorEvent.IO_ERROR,
uploadError(param));
fileUpload.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
uploadError(param));
Is this something that I have to cast to / extend apon the
existing events using your technique above? In essence, creating a
duplicate of this event?
Thanks
Oz. -
Parent swf call function in Child swf not working
Hi all,
I'm having a problem with this and I just can't figure it out
:( (I've been trying different things and staring at it for hours
and I'm losing my mind...)
So I have a Parent swf that loads a Child swf (this goes
without any problems), but I want the Parent to call a function in
the child, now this is where it goes wrong...
The function the Parent has to call is named "lookupcar" and
needs to give the value "wagen" with it. The problem I think is
that the Parent wants to call the function but it still needs to
load (correct me if I'm wrong). Is there a way to check if the
Child swf is loaded completely before trying to call the function?
Could you give me an example of this please? Or any other
suggestions on what goes wrong?
Code in the Parent
root.inhoud.createEmptyMovieClip("thetext", "thetext",
this.getNextHighestDepth());
root.inhoud.thetext.loadMovie("uitrusting-wagenpark.swf");
root.inhoud.thetext.lookupcar(wagen);
Code in the Child
(the function lookupcar)
_global.lookupcar = function(carnr:String){
trace("LOOKUPCAR, with car nr: " + carnr);
Thanks in advance for all the help.Perfect....just to make sure i m taking care of it in a nice practical way....here is how i learned to access a file located in Child (researching other posts)
is this the way you recommend it?
(LoaderName.content as MovieClip).functionName(new Event("whatever"))
and in Child File we have
function functionName(e:Event)
i have seen other ways of calling a function in Child Swf , like using EmbedSWF and etc. wanna make sure which one is a better practice. Thanks -
Is it possible to call a function in a parent component from a child component in Flex 3?
This is probably a very basic question but have been wondering this for a while.
I need to call a function located in a parent component and make the call from its child component in Flex 3. Is there a way to access functions in a parent component from the child component? I know I can dispatch an event in the child and add a listener in the parent to call the function, but just wanted to know if could also directly call a parent function from a child (similar to how you can call a function in the main mxml file using Application.application). ThanksThere are no performance issues, but it is ok if you are using the child component in only one class. Suppose if you want to use the same component as a child to some bunch of parents then i would do like the following
public interface IParentImplementation{
function callParentMethod();
and the parent class should implement this 'IParentImplementation'
usually like the following line
public class parentClass extends Canvas implements IParentImplementation{
public function callParentMethod():void{
//code
in the child you should do something like this.
(this.parent as IParentImplementation).callParentMethod();
Here using the Interfaces, we re decoupling the parent and the child
If this post answers your question or helps, please mark it as such. -
Calling a Function in the Parent Window from the Child Window
QUESTION: How do I call a function resident in the parent
window from a child window?
BACKGROUND
I have a JavaScript function resident in the parent window
that reformats information obtained from the Date object and writes
the result to the parent window using the document.write( ) method.
I would like to call this function from the child window and have
it write to the child window instead. Is this possible? If not,
must I rewrite the entire function and nest it in the below code?
If so, what is the proper form of nesting?
CODE: The code that creates and fills the child window is
provided below. The highlighted area indicates where I would like
to enter the information from the function resident in the parent
window. I have tried every imaginable permutation of code that I
can imagine and nearly destroyed my parent document in the process.
I am very happy that I had a back-up copy!
function openCitationWindow() {
ciDow = window.open("", "", "width=450, height=175, top=300,
left=300");
ciDow.document.write("A proper way to cite a passage of text
on this page:<br /><br />Stegemann, R. A. 2000.
<cite>Imagine: Bridging a Historical Gap</cite>. " +
document.title + ". [<a href='" + location.href + "'
target='_blank'>online book</a>] <" + location.href
+ "> (");
MISSING CODE;
ciDow.document.write(").<br /><br /><input
type='button' value='Close Window' onclick='window.close()'>");
ciDow.focus();Never mind - I was doing something very stupid and wasn't
calling the function as a method of a movie clip. I was simply
calling checkTarget(event) rather than
event.currentTarget.checkTarget(event); which seems to work. -
How to call a function with pl/sql
How does one call a function with pl/sql that uses a function?
Hi,
How does one call a function with pl/sql that uses a
function?I'm not sure what you mean.
In PL/SQL function can be used just about anywhere where an expression (with the same data type that the function returns). Arpit gave a very common example.
Here's another example, where all the functions take a single NUMBER argument and return a NUMBER, so they can all be used in places where NUMBERs are used:
IF fun_a (fun_b (0)) < fun_c (1)
THEN
UPDATE table_x
SET column_y = fun_d (2)
WHERE column_z = fun_e (ROUND ((fun_f (3), fun_g (4)));You call a function simply by using its name, followed by its argument list, if any.
If the function is in a package, you must call it with the package name, like "pk_foo.bar (1, 2, 3)", unless the call comes from within the same package.
If the function is owned by someone else, you must give the owner name, like "scott.bar (SYSDATE)" or "scott.pk_foo.bar (1, 2, 3)". You can create synonyms to avoid having to name the owner. -
How to call a function with event
How do I call a function with a event inside it?
function showTopTen(e:Event):void
highscoreData = new XML(e.target.data);
trace("Hiscores: " + highscoreData.item[0].name.text() + " - " + highscoreData.item[0].score.text())
//showTopTen(); ..??Could you indicate why you would want to?
The eventhandler you show here uses the properties of the event object passed as an argument.
The way I read it it is data retrieved from a server so your app won't know anything about is untill it is loaded from the server which should be done with an URLLoader object which in it's turn calls your eventHandler when the Event.COMPLETE is triggered.
something like:
var urlLoader = new URLLoader();
urlLoader.addEventListener( Event.COMPLETE, showTopTen )
urlLoader.load( new URLRequest( "http:// etc." ) );
to me would seem the proper method to have the function execute. -
IFRAME in portlet question - possible to call parent function from iframe?
From the iframe I tried to call the parent function by doing this parent.myFunc(). I got a permission denied javascript message. Just curious if anyone has successfully done this. If so please share your thoughts and comments.
Hi,
You will get "Persmission denied" error due to cross site scripting. Either you need to change browser settings to allow cross site scripting or you need to make sure both the URLs fall under same parent domain like both URLs ending with "*.abc.com".
Thanks -
Call outside function with same name in a package
I created a function as follows:
create or replace function f1 return number
is
begin
return 1;
end;
This f1 is to be called in a package created below.
Then I create a package with a function in it, as follows:
create or replace package pack1 as
function f1 return number;
end;
Now I define the package body as follows:
create or replace package body pack1 as
function f1 return number as
-- I am trying to call the first function f1 defined above here
How do I resolve the name issues here?
In other words, I want to call a function with the same signature outside a package.
Thanks for your kind help.Hi,
Welcome to the forum!
Do you have a good reason for using the same name?
Refer to the stand-alone function with the owner name, even though it's your current schema.
That is, even if the package and the stand-alone function are owned by scott, in the package, say
x := scott.f1;
Maybe you are looking for
-
Apple Sync Notifies,exe.Entry point not found the procedure entry point sqlite3_wal_checkpoint could not be located in the dynamic link library SQLite3.dll I have uninstalled Itunes 10.4 shut down and installed Itunes 10.4 and still get this message
-
Need help setting up a shared /Library/Fonts folder for font sharing
Hi, I have a problem setting up a shared /Library/Fonts folder on my OSX 10.5.5 server that gets automounted on the OSX 10.5.x clients. While I managed to get the folder to show up automatically under /Network/Library/Fonts on the clients, the fonts
-
I changed mine ID and now i can't update the old apps anymore
I changed mine ID account, keep the pasword, now have a problem with updating my app they always ask mine old ID acount, but I can't get in anymore
-
Sess_sh - java.io.EOFException error
I'm trying to configure mod_ose for use in stateful plsql web applications. According to the OSE User's Guide, I need to publish the plsql servlet using sess_sh. I'm able to connect using the following syntax. sess_sh -s http:// webserver:portnumber
-
Has anyone ever tried Soylent (US) or Joylent (Europe)
My own opinion on meal replacement shakes is that essentailly, being liquids, your body will process them a lot quicker, than if you were to, for example, eat a chicken breast and some brocolli at lunch. Therefore, as your body processes the shake fa