Can I pass function name as a parameter to constructor?
Hi!
I want to create a class that extends JButton and executes some function, when released. The function for each button is different. I mean, can I write, for example:
public class MyButton extends JButton
public MyButton(...functionName...)
addMouseListener(new MouseAdapter()
public void mouseReleased(MouseEvent e)
...execute functionName...;
MyButton testButton = new MyButton(printTest);
void printTest()
System.out.println("The button executes OK");
(This code will not work, of cause).
If you understood me, please answer if there is any way to pass function as a parameter ?
Thank you in advance.
Using reflection would work, but there is a more straightforward way. Here's what I do when I want to pass a method to be called by another object: First I declare an interface named Callback:public interface Callback
public void run();
}Then your class would look like this:public class MyButton extends JButton {
private Callback doit;
public MyButton(Callback whatToDo) {
doit = whatToDo;
addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent e) {
whatToDo.run();
}and the code that creates a MyButton might look like this:Callback callMe = new Callback() {
public void run() {
System.exit(0);
MyButton closeButton = new MyButton(callMe);
closeButton.setText("Close");If you like, you can adapt this pattern to use variations of Callback that have parameters or return values.
Similar Messages
-
Pass table name as a parameter to function
Is there a way to pass table name as a parameter to functions? Then update the table in the function.
Thanks a lot.
JiaxinHi, Harm,
Thank you very much for your suggestion and example. But to get my program work, i need to realise code like follows:
CREATE OR REPLACE FUNCTION delstu_func(stuno char) RETURN NUMBER AS
BEGIN
EXECUTE IMMEDIATE 'DELETE FROM student s' ||
'WHERE' || 's.student_number' || '=' || stuno;
LOOP
DBMS_OUTPUT.PUT_LINE('record deleted');
END LOOP;
END;
SELECT delstu_func('s11') FROM STUDENT;
The intention is to check if such a function can perform operations such as update, delete and insert on occurence of certain values. When executing the above statement, the system returns an error message:
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at "SCMJD1.DELSTU_FUNC", line 3
Could you tell me where is wrong?
Jiaxin -
How can i pass the name of the file polled by the file adapter to next step
Hi XI guru's ,
How can i pass the name of the file polled by the file adapter to next step in a BPM..?
regards,Use Adapter-Specific Message Attributes and map that value in udf to the BPM message.
Also see this
/people/michal.krawczyk2/blog/2005/06/11/xi-how-to-retrieve-messageid-from-a-bpm
Regards,
Prateek -
How can I Create function with an out Parameter
how all
how can I Create function with an out Parameter
I try to create it it sucess but how can I CALL it , it give me error
please I want A simple example
thanks3rd post on same question by same user :
Re: how can I Create function with an out Parameter
how can I Create function with an out Parameter -
Script to stop running SQL Agent job without passing job name as a parameter
Looking for script to stop running job and don’t want to pass job name as a parameter, any job which is in running state I want that to be stop/disable.
I have script to disable all jobs however if any jobs are in running state my requirement is to stop that job immediately and gets disable.
RahulTry the below scripts and then apply script to disable all jobs.
execute xp_cmdshell 'net stop sqlserveragent'
execute xp_cmdshell 'net start sqlserveragent'
Regards, RSingh -
Pass Bean Name as a parameter?
Hi,
Is it possible to pass the bean name as a parameter to the method? In that case, we can pass the bean name as a String to the calling method?
Thanks
AishuYou can use f:param, f:attribute or f:setPropertyActionListener to pass "parameters" to the method.
Also see [http://balusc.blogspot.com/2006/06/communication-in-jsf.html]. -
Pass column-name as a parameter to reports
Hello,
the code below calls a report. But now I want to sort the rows in the report. For example I have a text-item in my form-modul. If I type a column-name and press the button then the rows should be sorted in the report. Is it possible tp pass column-names as parameter to reports?
DECLARE
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(20);
BEGIN
repid := find_report_object('STATIONSTOPOLOGIE');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_EXECUTION_MODE,RUNTIME);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_COMM_MODE,SYNCHRONOUS);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESTYPE,CACHE);
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'html');
SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,'rep_oracle-dev');
-- SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,'paramform=no pdeptno='||:dept.deptno);
v_rep := RUN_REPORT_OBJECT(repid);
rep_status := REPORT_OBJECT_STATUS(v_rep);
WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
LOOP
rep_status := report_object_status(v_rep);
END LOOP;
IF rep_status = 'FINISHED' THEN
WEB.SHOW_DOCUMENT('http://oracle-dev:8888/reports/rwservlet/getjobid'||
substr(v_rep,instr(v_rep,'_',-1)+1)||'?'||'server=rep_oracle-dev','_blank');
ELSE
message('Error when running report');
END IF;
END;Hi,
the work has been done in reports. You can use a lexical parameter in reports to add a condition for sorting to the query like:
select .. from .. where ... &p_order.
Then add another parameter to the report (for example p_param). Fill p_param via your interface in forms (SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER, ....) with the column name. Then build a report trigger like:
if :p_param is null
then
:p_order:= null;
else
:p_order:= 'order by '||:p_param;
end if;
But have a look, that p_param can only get correct values.
Rainer -
How to pass printer name as a parameter to Bursting control file
We are on 11.5.10.2 using XML Publisher 5.6.3. We ahve a requirement, where we need to print our invoices to different printers.
How do we pass the printer name as a parameter to Bursting control file. Can the bursting control file be created to use the printer parameter.
If it can, can you please provide some examples.
- Vasu -Hi.
I have created Formula column and it is coming in xml data.
Like this way
<CP_TAX_NO>CZ27813941</CP_TAX_NO>
<CP_CUST_TAX_REG>CZ680527617</CP_CUST_TAX_REG>
<CF_PRINTER_NAME>ABC_hp4250</CF_PRINTER_NAME>
<C_REQ_ID>12310217</C_REQ_ID>
</ISOPTWSHRDPAK>
But while i passed it bursting directory, it is not printing, if i hardcode over there then it is printing.
Bursting file code
<xapi:delivery>
<xapi:print id="printer1" printer="ipp://localhost:631/printers/${CF_PRINTER_NAME}" copies="1" />
</xapi:delivery>
In bursting program file It is display like :
[1]printer-uri:ipp://localhost:631/printers/null
If i pass hardcode value instead of cf_printer_name then it is working fine
[1]printer-uri:ipp://localhost:631/printers/ABC_hp4250
Pls suggest what to do? -
Passing function name into another function?
Hi
I have a movieclip prototype thats scales and moves any
movieclips depending
on the parameters passed in. I want to be able to pass in a
function name
that is executed when the main function has finished. The
problem is the
line of code that calls the main function executes the
function name that I
m trying to pass in as a parameter. Is there something I m
missing?
see my code below:
"mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
-100,
mcMainAnimation._xscale, -30, 50,moveToX());"
MovieClip.prototype.moveFadeTransform = function(t, oldY,
diffY, oldScale,
newScale, tTime, funcToCall) {
this.onEnterFrame = function() {
t++;
if (t<=tTime) {
this._y = easeIn(t, oldY, diffY, tTime);
this._xscale = easeIn(t, oldScale, newScale, tTime);
this._yscale = easeIn(t, oldScale, newScale, tTime);
} else {
t = 0;
funcToCall;
this.onEnterFrame = null;
moveToX = function () {
trace("called");
Thank in advance
ShaunHi!
Try to modify code to:
mcMainAnimation.moveFadeTransform(0, mcMainAnimation._y,
-100,
mcMainAnimation._xscale, -30, 50,moveToX);"
... so don't use () at end of function. That should do the
trick.
Also, you need to add the () to funcToCall, so that instead
of:
t = 0;
funcToCall;
this.onEnterFrame = null;
you should have
t = 0;
funcToCall();
this.onEnterFrame = null;
/Jensen/
"forums.macromedia.com" <[email protected]>
wrote in message
news:e6m428$qa0$[email protected]..
> Hi
>
> I have a movieclip prototype thats scales and moves any
movieclips
> depending on the parameters passed in. I want to be able
to pass in a
> function name that is executed when the main function
has finished. The
> problem is the line of code that calls the main function
executes the
> function name that I m trying to pass in as a parameter.
Is there
> something I m missing?
>
> see my code below:
>
> "mcMainAnimation.moveFadeTransform(0,
mcMainAnimation._y, -100,
> mcMainAnimation._xscale, -30, 50,moveToX());"
>
> MovieClip.prototype.moveFadeTransform = function(t,
oldY, diffY, oldScale,
> newScale, tTime, funcToCall) {
> this.onEnterFrame = function() {
> t++;
> if (t<=tTime) {
> this._y = easeIn(t, oldY, diffY, tTime);
> this._xscale = easeIn(t, oldScale, newScale, tTime);
> this._yscale = easeIn(t, oldScale, newScale, tTime);
> } else {
> t = 0;
> funcToCall;
> this.onEnterFrame = null;
> }
> };
> };
>
> moveToX = function () {
> trace("called");
> }
>
>
> Thank in advance
>
> Shaun
> -
How can i pass function return values in to varray
Hi
create procedure name(parameters list)
here ---i am calling a function
varname := function name
returns 4 values
My doudt is how can i pass these return values in to varray..
Type varray vname[5] date type
Begin
statements
end prodedure name;
pls clarify me its urgentThis may give u a start
sql>
create or replace package test_array_pack as
type ar1 is varray(10) of number;
end;
Package created.
sql>
create or replace function test_array return test_array_pack.ar1 is
v_ar1 test_array_pack.ar1;
begin
v_ar1 := test_array_pack.ar1(1,2,3,4);
return v_ar1;
end;
Function created.
sql>
declare
v_ar2 test_array_pack.ar1;
begin
v_ar2 := test_array;
end;
PL/SQL procedure successfully completed
Message was edited by:
jeneesh -
How can I pass empty value in URL Parameter
Hi,
I am passing different URL parameters to one page, to filter
the recordset on that page. How can I pass an empty value in the
URL parameter so that the recordset in unfiltered?
The URL parameter is based on one field of the database:
ContentType. So, the link would be to
default.asp?ContentType=Event
and then all records that have the ContentType field in the
DB as Event are displayed. Is it possible to use this system to
pass an empty parameter so that all records are displayed?
Thanks
Ian?ContentType=All
<% if (ContentType == "All")
Build recordset w/o filtering
ASP is rusty, but those are the basics.
"iandobie" <[email protected]> wrote in
message
news:e8im80$q7m$[email protected]..
> Hi,
> I am passing different URL parameters to one page, to
filter the recordset
> on
> that page. How can I pass an empty value in the URL
parameter so that the
> recordset in unfiltered?
> The URL parameter is based on one field of the database:
ContentType. So,
> the
> link would be to
> default.asp?ContentType=Event
> and then all records that have the ContentType field in
the DB as Event
> are
> displayed. Is it possible to use this system to pass an
empty parameter so
> that
> all records are displayed?
> Thanks
> Ian
> -
How to pass sicf name as a parameter frm webdynpro
Hi All,
I have created a properties file in which i hv provided the following path: servername:port n path to open the SAP R/3 easy access but i want to pass sicf name so it directly opens it in portal. Please provide me some assistance. Thankyou.
Regards,
Jaspreet Kaur
Edited by: Jaspreet Kaur on Dec 29, 2008 11:56 AMHi Jaspreet,
You can create an IAC iview with your service.
Hope this helps,
Ivá -
Pass function name as parameter in SSRS expression
I have a function (GetColumnFieldName) which returns string datatype
Now I want to use this function in below SSRS expression
=Code.GetDisplay("FirstName",Parameters!SelectedCols.Value,Parameters!DisplayCols.Value)
At the above expression I want to replace "FirstName" with function GetColumnFieldName which returns the same "FirstName".
Please suggest.Hi Jajatibabu,
If I understand correctly, you want to use GetColumnFieldName function which returns a field name to replace the “FirstName” in the expression you post.
If in this scenario, we can directly use Code.GetColumnFieldName(parameters) to replace the “FirstName” like below:
=Code.GetDisplay(Code.GetColumnFieldName(parameters),Parameters!SelectedCols.Value,Parameters!DisplayCols.Value)
Note that we should type the correct parameters in the GetColumnFieldName function.
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
If you have any feedback on our support, please click
here.
Katherine Xiong
TechNet Community Support -
Passing table name as a parameter
Hi:
I have a question regarding passing part of a table name to crystal. I have table getting created everyday and the dynamic part being Table_<date in yymmdd format>, for e.g. - Table_20140225 for table created on 02/25/2014
I have written query like "select * form Table_{@DT}". This used to work in Crystal 11.5.8.826. but recently we upgraded to 12.2.0.290. In this version of Crystal it is not working and giving me error "com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: Missing parameter values.---- Error code:-2147217394 Error code name:missingParameterValueError".
Can you please suggest to get around this problem. Running a stored procedure with REFCURSOR is not an option.
i tried another solution, where i just wrote a stored procedure to do a insert into a table handling the dynamic table in stored procedure. but to my surprise, the stored procedure doesn't execute all the time.
Any help on this is much appreciated...Please see if SP 6 helps. You are on SP 2 at this time.
https://share.sap.com/a:328ro3/MyAttachments/521c18ac-d7fd-4a58-a2dc-9d40d1951975/
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter -
Passing sylesheet name as a parameter to xsql file
The way that I can have
<page xmlns:xsql="urn:oracle-xsql" connection="{@conn}">
where conn is the connection!
Could I have someting like
<?xml-stylesheet type="text/xsl" href="{@style}" >
where style would be the style sheet that the user chooses in the URLEric,
You can pass the stylesheet in the query string of the XSQL request, like in
http://akeu.coucou/page.xsql?xsl=alternatestylesheet.xsl
This would overwrite the stylesheet set in the XSQL Script.
- Olivier
Maybe you are looking for
-
Problem with reminder after upgrading to ios5
Hi, My name is Henri and I'm from France. Excuse me first if the question had been asked, I didn't found any answer to my research. I upgraded my iphone 4 to ios 5 yesterday and since there I couldn't use my reminder, because the plus signe didn't ap
-
Migrate EAR to weblogic 10.3
I want to migrate an application from weblogic 8.1.6 to weblogic 10.3. I have the EAR(containing web services & ejb) file which is running in weblogic 8.1.6,but unfortunately no source is available.Please let me know if I can upgrade this EAR in webl
-
Can't open patch package to uninstall Acrobat Reader
I need to uninstall the current version to troubleshoot why my pdf files aren't (suddenly) printing to a printer that works otherwise. Am getting the message about this patch package. What can I do?
-
Is it possible to recover an apple i web site
Is it possible to recover an iweb site that has disappeared in conversion to i cloud?
-
11 pm modem mysteriously dialing, connecting, exchanging data
I've been trying to figure out why my PowerBook has been waking up at 11pm, dialing, making network connection and exchanging data with a remote server. I suspect that it's looking for a software update but have no assurance that it's not something m