Passing hard coded array to a method
how to passing hard coded array to a method
like method1("eee","eoe","eee",.....)
which should populate a array of strings (say arr[]) for the method
what can be done??
or if you're using Java 5.0 declare the method aspublic void method(String... array) {
}
Similar Messages
-
Passing a whole array through a method
I need some quick help on how to pass a whole array through the method addCoins(). Here is the code:
public class Purse {
private Coin[] coins;
private int lastIdx;
public Purse() {
coins = new Coin[100];
lastIdx = 0;
public boolean addCoin(Coin b) {
if (lastIdx < coins.length) {
lastIdx++;
coins[lastIdx] = b;
return true;
else {
return false;
public boolean addCoins(Coin[] b) {
if (lastIdx < coins.length) {
for (b=0; b<99; b++) {
coins[b] = b;
else {
return false;
}I figured passing the whole array would be "Coin[] b" but apparently Eclipse says that it can't convert from int to Coin[]. I have no idea what that means. Thanks in advance.I need to create 3 classes, Coin, Purse, and TestPurse.
Coin code:
public class Coin {
private String typeOfCoin;
private double value;
public Coin(String t, double v) {
typeOfCoin = t;
value = v;
public String toString() {
return typeOfCoin + value;
}Purse code:
public class Purse {
private Coin[] coins;
private int lastIdx;
public Purse() {
coins = new Coin[100];
lastIdx = 0;
public boolean addCoin(Coin b) {
if (lastIdx < coins.length) {
lastIdx++;
coins[lastIdx] = b;
return true;
else {
return false;
public boolean addCoins(Coin[] b) {
if (lastIdx < coins.length) {
for (int i=0; i<coins.length; i++) {
coins[i] = b;
else {
return false;
public Coin getReverse() {
coins = new Coin[0];
lastIdx = 100;
}In the Purse class, I need methods addCoin and addCoins that need to return boolean. addCoin is supposed to add the argument coin as an element of the coins array if there is space. addCoins neds to add all the coins in the input argument as elements of the coins array if there is space. I then have to create two methods, getReverse and getValue that take no argument and getReverse that returns an array of type Coin while getValue returns a double. In getReverse, I create an array simlar to coins but this new array is reverse. I started on this method but I first need to worry about the addCoin and addCoins method. For the record, getValue needs to add up the values of all the coins in the purse and return it, which I have no idea how to do that. That's my next question.
Edited by: quagmire87 on Dec 1, 2009 4:35 PM
fixed method addCoins -
Modify hard coded array to database pull
Hello all,
I'm new to the array stuff, and am having problems finding a tutorial or instructions on how to modify a hard coded array to something pulled from a database. I can only find tutorials on how to do it hardcoded. They keep saying it is possible, but never say how to do it. The original tutorial that I'm trying to learn which brought up this question can be found at: http://www.brandspankingnew.net/archive/2007/02/ajax_auto_suggest_v2.html
So as an example, if I've got the database connection already established as:
$con = mysql_connect("localhost", "root", "") or die('Could not connect to server');
mysql_select_db("my_database", $con) or die('Could not connect to database');
With fields as my_database_names, my_database_ratings, and my_database_images; how do I modify the below code to use the database information instead of using the hardcoded array? Any suggestions (or letting me know of where a good tutorial is) would be appreciated.
<?php
note:
this is just a static test version using a hard-coded countries array.
normally you would be populating the array out of a database
the returned xml has the following structure
<results>
<rs>foo</rs>
<rs>bar</rs>
</results>
$aUsers = array(
"Adams, Egbert",
"Altman, Alisha",
"Archibald, Janna",
"Auman, Cody",
"Bagley, Sheree",
"Ballou, Wilmot",
"Bard, Cassian",
"Bash, Latanya",
"Beail, May",
"Black, Lux",
"Bloise, India",
"Blyant, Nora",
"Bollinger, Carter",
"Burns, Jaycob",
"Carden, Preston",
"Carter, Merrilyn",
"Christner, Addie",
"Churchill, Mirabelle",
"Conkle, Erin",
"Countryman, Abner",
"Courtney, Edgar",
"Cowher, Antony",
"Craig, Charlie",
"Cram, Zacharias",
"Cressman, Ted",
"Crissman, Annie",
"Davis, Palmer",
"Downing, Casimir",
"Earl, Missie",
"Eckert, Janele",
"Eisenman, Briar",
"Fitzgerald, Love",
"Fleming, Sidney",
"Fuchs, Bridger",
"Fulton, Rosalynne",
"Fye, Webster",
"Geyer, Rylan",
"Greene, Charis",
"Greif, Jem",
"Guest, Sarahjeanne",
"Harper, Phyllida",
"Hildyard, Erskine",
"Hoenshell, Eulalia",
"Isaman, Lalo",
"James, Diamond",
"Jenkins, Merrill",
"Jube, Bennett",
"Kava, Marianne",
"Kern, Linda",
"Klockman, Jenifer",
"Lacon, Quincy",
"Laurenzi, Leland",
"Leichter, Jeane",
"Leslie, Kerrie",
"Lester, Noah",
"Llora, Roxana",
"Lombardi, Polly",
"Lowstetter, Louisa",
"Mays, Emery",
"Mccullough, Bernadine",
"Mckinnon, Kristie",
"Meyers, Hector",
"Monahan, Penelope",
"Mull, Kaelea",
"Newbiggin, Osmond",
"Nickolson, Alfreda",
"Pawle, Jacki",
"Paynter, Nerissa",
"Pinney, Wilkie",
"Pratt, Ricky",
"Putnam, Stephanie",
"Ream, Terrence",
"Rumbaugh, Noelle",
"Ryals, Titania",
"Saylor, Lenora",
"Schofield, Denice",
"Schuck, John",
"Scott, Clover",
"Smith, Estella",
"Smothers, Matthew",
"Stainforth, Maurene",
"Stephenson, Phillipa",
"Stewart, Hyram",
"Stough, Gussie",
"Strickland, Temple",
"Sullivan, Gertie",
"Swink, Stefanie",
"Tavoularis, Terance",
"Taylor, Kizzy",
"Thigpen, Alwyn",
"Treeby, Jim",
"Trevithick, Jayme",
"Waldron, Ashley",
"Wheeler, Bysshe",
"Whishaw, Dodie",
"Whitehead, Jericho",
"Wilks, Debby",
"Wire, Tallulah",
"Woodworth, Alexandria",
"Zaun, Jillie"
$aInfo = array(
"Bedfordshire",
"Buckinghamshire",
"Cambridgeshire",
"Cheshire",
"Cornwall",
"Cumbria",
"Derbyshire",
"Devon",
"Dorset",
"Durham",
"East Sussex",
"Essex",
"Gloucestershire",
"Hampshire",
"Hertfordshire",
"Kent",
"Lancashire",
"Leicestershire",
"Lincolnshire",
"Norfolk",
"Northamptonshire",
"Northumberland",
"North Yorkshire",
"Nottinghamshire",
"Oxfordshire",
"Shropshire",
"Somerset",
"Staffordshire",
"Suffolk",
"Surrey",
"Warwickshire",
"West Sussex",
"Wiltshire",
"Worcestershire",
"Durham",
"East Sussex",
"Essex",
"Gloucestershire",
"Hampshire",
"Hertfordshire",
"Kent",
"Lancashire",
"Leicestershire",
"Lincolnshire",
"Norfolk",
"Northamptonshire",
"Northumberland",
"North Yorkshire",
"Nottinghamshire",
"Oxfordshire",
"Shropshire",
"Somerset",
"Staffordshire",
"Suffolk",
"Surrey",
"Warwickshire",
"West Sussex",
"Wiltshire",
"Worcestershire",
"Durham",
"East Sussex",
"Essex",
"Gloucestershire",
"Hampshire",
"Hertfordshire",
"Kent",
"Lancashire",
"Leicestershire",
"Lincolnshire",
"Norfolk",
"Northamptonshire",
"Northumberland",
"North Yorkshire",
"Nottinghamshire",
"Oxfordshire",
"Shropshire",
"Somerset",
"Staffordshire",
"Suffolk",
"Surrey",
"Warwickshire",
"West Sussex",
"Wiltshire",
"Worcestershire",
"Durham",
"East Sussex",
"Essex",
"Gloucestershire",
"Hampshire",
"Hertfordshire",
"Kent",
"Lancashire",
"Leicestershire",
"Lincolnshire",
"Norfolk",
"Northamptonshire",
"Northumberland",
"North Yorkshire",
"Nottinghamshire"
$input = strtolower( $_GET['input'] );
$len = strlen($input);
$limit = isset($_GET['limit']) ? (int) $_GET['limit'] : 0;
$aResults = array();
$count = 0;
if ($len)
for ($i=0;$i<count($aUsers);$i++)
// had to use utf_decode, here
// not necessary if the results are coming from mysql
if (strtolower(substr(utf8_decode($aUsers[$i]),0,$len)) == $input)
$count++;
$aResults[] = array( "id"=>($i+1) ,"value"=>htmlspecialchars($aUsers[$i]), "info"=>htmlspecialchars($aInfo[$i]) );
if ($limit && $count==$limit)
break;
if (isset($_REQUEST['json']))
header("Content-Type: application/json");
echo "{\"results\": [";
$arr = array();
for ($i=0;$i<count($aResults);$i++)
$arr[] = "{\"id\": \"".$aResults[$i]['id']."\", \"value\": \"".$aResults[$i]['value']."\", \"info\": \"\"}";
echo implode(", ", $arr);
echo "]}";
else
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?><results>";
for ($i=0;$i<count($aResults);$i++)
echo "<rs id=\"".$aResults[$i]['id']."\" info=\"".$aResults[$i]['info']."\">".$aResults[$i]['value']."</rs>";
echo "</results>";
?>Thank you so much. I was planning on hand coding it because my objective is to learn, not to have dreamweaver do it for me, so I will check out the link :
http://docs.php.net/manual/en/mysqli.query.php.
LOL, I thought I was just starting to understand MySQL, and now I've got to start learning MySQLi. I hope there is not too much different between the two. Thanks again. -
Passing hard-coded string parameters into a FUNCTION
I created a Function that accepts two INT and two VARCHAR2 parameters. I want to access it in a SELECT statement and manually pass in parameters to it.
For example,
SELECT FN_MYFUNC(10, 20, 'string1', 'string2') FROM DUAL;
However, when I do this the hard-coded strings don't seem to be recognized by the Function. But, if I were to pass in a Fieldname from a TABLE then the above function works. Is there something extra I need to do to pass in hard-coded strings into a function?I have pasted the function where this problem is occuring below. If I use it in a SELECT, for example....
SELECT fn_GetRegValueFromRegData(3, 3, 'REG', '119') FROM DUAL;
.....it returns blank everytime when it should return a numeric value. However, this only occurs if I hard-code the parameter values (like above). However, if I pass in fieldnames from a TABLE, for example.....
SELECT fn_GetRegValueFromRegData(RegLink, EeLink, ChqType, RegCode) FROM RegData;
......then I get data back! Any idea why data is returned when I pass in fieldnames but not when I pass in hard-coded parameter values?
=================================================
CREATE OR REPLACE FUNCTION fn_GetRegValueFromRegData
(p_RegLink INT,
p_EELink INT,
p_ChequeType VARCHAR2,
p_RegCode1 VARCHAR2,
p_RegCode2 VARCHAR2 := '-1')
RETURN NUMBER
AS
v_regvalue NUMBER(14,5);
BEGIN
BEGIN
--retrieve data using the REGCODE1 value
SELECT a.regvalue INTO v_regvalue
FROM regdata a
WHERE a.RegCode = p_RegCode1
AND a.RegLink = p_RegLink
AND a.eeLink = p_EELink
AND a.ChqType = p_ChequeType
AND a.EndDate IS NULL;
EXCEPTION
WHEN OTHERS
THEN
--retrieve data using the REGCODE2 value
SELECT a.regvalue INTO v_regvalue
FROM regdata a
WHERE a.RegCode = p_RegCode2
AND a.RegLink = p_RegLink
AND a.eeLink = p_EELink
AND a.ChqType = p_ChequeType
AND a.EndDate IS NULL;
END;
RETURN v_regvalue;
END;
/ -
Passing object reference array to a method
Hi everyone,
I'm new to the java programming language. I want to create create a array of 50 objects and pass them in to a method in other class.
Can anyone help me on this problem........................
Chathu.Object[] objectArray = new Object[50];
objectArray[0] = "Hello World";
objectArray[1] = new Integer(42);
myClass.myMethod(objectArray); -
NEED HELP! passing an object array to a method
Hi, i need to make a method called public Server[] getServers() and i need to be able to see if specific server is available for use.
I have this so far:
public abstract class AbstractServer
protected String serverName;
protected String serverLocation;
public AbstractServer(String name,String location)
this.serverName=name;
this.serverLocation=location;
public abstract class Server extends AbstractServer
public Server(String name,String location)
super(name,location);
public class CreateServers
Server server[];
public CreateServers()
public Server create()
for(int i=0; i<10; i++)
server=new Server(" ", " "); //i was going to fill in something here
return server;
OK NOW HERE IS THE PROBLEM
i have another class that is supposed to manage all these servers, and i dont understand how to do the public Server[] getServers(), this is what i have tried so far
public class ServerManager()
public Server[] getServers(Server[] AbstractServer)
Server server=null; //ok im also confused about what to do here
return server;
in the end i need this because i have a thread class that runs the servers that has a call this like:
ServerManager.getServers("serverName", null);
Im just really confused because i need to get a specific server by name but i have to go through AbstractServer class to get it
Any help?ok, right
since i have to call this method in the thread class saying
ServerManger.getServer(AbstractServer[]) //to see if i have all the servers i need to proceed
im confused about how it should be declared in the actual ServerManager
should it be like
public Server[] getServers(AbstractServer[]) ???? and then have it return all the servers it has
thats the part i dont get, because instead of saying ServerManager.getServer(string, string) i want it to go and find out if i have all the servers i need to continue
does that make sense? sort of? -
How to pass a file into a java method
I am trying to pass a file into a java method so I can read the file from inside the method. How can I do this? I am confident passing int, char, arrays etc into methods as I know how to identify them in a methods signature but I have no idea how to decalre a file in a mthods signature. Any ideas please ?
ThanksHi,
Just go thru the URL,
http://www6.software.ibm.com/devtools/news1001/art24.htm#toc2
I hope you will get a fair understanding of 'what is pass by reference/value'.
You can pass Object reference as an argument.
What Pablo Lucien had written is right. But the ideal situation is if you are not modifying the
file in the calling method, then you can pass the String (file name) as an argument to the called method.
Sudha -
Where do you store Hard coding values?
Hi All,
We have a requirement to call a 3rd party web service from SAP for which there are 12 - 13 attributes which are constant values and are not going to change. These can be hard coded inside the implementation methods but I do not want to do it. Say after 3 months there is a additional attribute that need to be added then in that case I need not touch the code back.
We can store it Z tables which is one option. I would like to get ideas from experts here in the forum what would you do in this type of a scenario instead of hard coding?
Please post in your feedback from the maintenance perspective across landscapes.
Thanks,
Nagarajan.Hello Nagarajan,
you can create the constants in the Assistance class or create a separate interface for storing the constant values.
If there is any change in the constant value, then you have to change the class/interface. this can't be avoided.
BR, Saravanan -
How do I pass an array to a method?
Hopefully you guys don't mind answering one of my stupid questions :o(
I have problem passing an array to a method.
//Here is the code that calls to the method:
String[] Folder = new String[19];
int cnt;
for(cnt=0; cnt<20; cnt++){
Folder[cnt] = request.getParameter("searchfolder_name" + (cnt + 1));
ProcessNotify(Folder[cnt]);
//================================================================
//Here the the method that is supposed to take in the array
private void ProcessNotify(String FolderName[]){
FolderName = new String[19];
int cnt;
for(cnt=0; cnt<20; cnt++){
System.out.println("Folder Name: " + FolderName[cnt]);
I got an error that says java.lang.String[] can not be applied to java.lang.String
I thought "String FolderName[]" is an array? Anyway... I'm confused. If you know the answer, plz let me know :o) big thx
lilProcessNotify(Folder[cnt]);
Are you trying to pass the whole array or just one piece from it? What you coded, tried to pass just one piece by specifying a subscript. BTW variable cnt is a subscript out of range.
If you meant to pass the whole array, just use it's name with no subscript. -
Passing Array to Another Method
Hello, I created a program with an array in one of the methods. I have been trying to figure out how to correctly pass the array to another method in the same class. I know my problem is in my method delcaration statements. Could someone please show me what I am doing wrong? Please let me know if you have any questions. Thanks for your help.
import javax.swing.*;
import java.util.*;
class Bank1 {
public static void main(String[] args) {
Bank1 bank = new Bank1();
bank.menu();
//Main Menu that initializes other methods
public void menu( ) {
Scanner scanner = new Scanner(System.in);
System.out.println("Welcome to the bank. Please choose from the following options:");
System.out.println("O - Open new account");
System.out.println("T - Perform transaction on an account");
System.out.println("Q - Quit program");
String initial = scanner.next();
char uInitial = initial.toUpperCase().charAt(0);
while (uInitial != 'O' && uInitial != 'T' && uInitial != 'Q') {
System.out.println("That was an invalid input. Please try again.");
System.out.println();
initial = scanner.next();
uInitial = initial.toUpperCase().charAt(0);
if (uInitial == 'O') newAccount();
if (uInitial == 'T') transaction();
//Method that creates new bank account
public Person[] newAccount( ) {
Person[] userData = new Person[1];
for (int i = 0; i < userData.length; i++) {
Scanner scanner1 = new Scanner(System.in);
System.out.println("Enter your first and last name:");
String name = scanner1.next();
Scanner scanner2 = new Scanner(System.in);
System.out.println("Enter your address:");
String address = scanner2.next();
Scanner scanner3 = new Scanner(System.in);
System.out.println("Enter your telephone number:");
int telephone = scanner3.nextInt();
Scanner scanner4 = new Scanner(System.in);
System.out.println("Enter an initial balance:");
int balance = scanner4.nextInt();
int account = i + 578;
userData[i] = new Person( );
userData.setName ( name );
userData[i].setAddress ( address );
userData[i].setTelephone ( telephone );
userData[i].setBalance ( balance );
userData[i].setAccount ( account );
System.out.println();
System.out.println("Your bank account number is: " + userData[i].getAccount());
return userData;
menu();
//Method that gives transaction options
public void transaction(Person userData[] ) {
System.out.println(userData[0].getBalance());Thank you jverd, I was able to get that to work for me.
I have another basic question about arrarys now. In all of the arrary examples I have seen, the array is populated all at once using a for statement like in my program.
userData = new Person[50];
for (int i = 0; i < userData.length; i++) In my program though, I want it to only fill the first array parameter and then go up to the main menu. If the user chooses to add another account, the next spot in the array will be used. Can someone point me in the right direction for doing this? -
This is probably a really simple question - but I'm new to java!
Object (is that the right word?) Car consists of some information about a car - registration number, engine size etc.
I have defined an array of objects of type car, and I want to pass the whole thing to a method.
Specifically...
I want to pass an inputted search term - the registration number, to a search method to return the number of the element of the array in which that record is stored. Presumably I need to pass the whole array?
I think what might be causing the problem is the definition of the method:
private int searchCar(String regNumber, int records, Car carArray[]Also, I don't know how to refer to regNumber as stored in carArray. I'm guessing it's carArray[number].regNumber or something like that.
Do I need to initialise the whole array before I use it?
Thanks for any help - I'm clueless!You should provide in your class Car ,methods to get (and set if necessary) each of the instance variables associated with a Car object. For example your car class should look something like this:
public class Car
private String make, model, colour, regNumber;
public Car(String a, String b, String c, String d)
make = a;
model =b;
colour = c;
regNumber = d;
public String getModel()
return model;
public String getMake()
{ return make;
public string getColour()
return colour;
public string getRegNumber()
return regNumber;
public string to String()
return getMake() + " " + getModel() + " " + getColour() + " " + getRegNumber;
}in your main method
// create your Array of Car objects and the mthod as below.
public int searchCar(Car [ ] cars, String reg)
int found =-1;
for (int counter = 0; counter < cars.length; ++ counter)
if (cars[counter].getRegNumber.equals(reg))
found = counter;
break;
return found;
}// end searchCarCall this method with something like:
int index = carSearch(carArray, "SM51 KJL");
if(index != -1)
System.out.println("This full details of the requested car are : " + carArray[index].toString());
else
System.out.println("This car has not been recorded on our System");
Haven't compiled this so aplogies for any typing errors. -
Hi Experts
we have a requirement, Users is created in OIM through trusted Recon. For all the users created through recon, certain attributes need to be hard coded (these attributes are not present in Trusted source) and LDAP sync is also enabled in our environment. so these attributes should be updated with user creation only.
I want to know various options of achieving this requirement
Any help appreciated.
Regards
A AbhinayThanks for reply
We need to pass this values to OID through LDAP sync for recon users only.
We tried with post process event handler
[2012-03-30T12:02:24.058+02:00] [wls_oim1] [ERROR] [IAM-3010003] [oracle.iam.ldapsync.impl.eventhandlers.user] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 15dcd4762ac88ff7:-76b53ee5:1365f45a05d:-8000-0000000000000002,0] [APP: oim#11.1.1.3.0] Failed to execute the handler.[[
oracle.iam.platform.kernel.EventFailedException: Modification failed because user TESTUSER125 is not synchronized to the LDAP directory.
at oracle.iam.ldapsync.impl.eventhandlers.user.UserModifyLDAPPreProcessHandler.modifyUser(UserModifyLDAPPreProcessHandler.java:162)
at oracle.iam.ldapsync.impl.eventhandlers.user.UserModifyLDAPHandler.execute(UserModifyLDAPHandler.java:119)
at oracle.iam.platform.kernel.impl.OrchProcessData.runPreProcessEvents(OrchProcessData.java:898)
at oracle.iam.platform.kernel.impl.OrchProcessData.runEvents(OrchProcessData.java:634)
at oracle.iam.platform.kernel.impl.OrchProcessData.executeEvents(OrchProcessData.java:227)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:665)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.process(OrchestrationEngineImpl.java:435)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:381)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:334)
at oracle.iam.identity.usermgmt.impl.UserManagerImpl.modify(UserManagerImpl.java:896)
at oracle.iam.identity.usermgmt.api.UserManagerEJB.modifyx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy358.modifyx(Unknown Source)
at oracle.iam.identity.usermgmt.api.UserManager_nimav7_UserManagerRemoteImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at oracle.iam.identity.usermgmt.api.UserManager_nimav7_UserManagerRemoteImpl.modifyx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
at $Proxy199.modifyx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy323.modifyx(Unknown Source)
at oracle.iam.identity.usermgmt.api.UserManagerDelegate.modify(Unknown Source)
at com.doha.customeventhandler.DohaEDWAttributePostProcessEventHandler.execute(DohaEDWAttributePostProcessEventHandler.java:133)
at oracle.iam.platform.kernel.impl.OrchProcessData.runPostProcessEvents(OrchProcessData.java:1166)
at oracle.iam.platform.kernel.impl.OrchProcessData.runEvents(OrchProcessData.java:710)
at oracle.iam.platform.kernel.impl.OrchProcessData.executeEvents(OrchProcessData.java:227)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:675)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:705)
at oracle.iam.platform.kernel.impl.OrhestrationAsyncTask.execute(OrhestrationAsyncTask.java:108)
at oracle.iam.platform.async.impl.TaskExecutor.executeUnmanagedTask(TaskExecutor.java:100)
at oracle.iam.platform.async.impl.TaskExecutor.execute(TaskExecutor.java:70)
at oracle.iam.platform.async.messaging.MessageReceiver.onMessage(MessageReceiver.java:68)
at sun.reflect.GeneratedMethodAccessor3380.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy347.onMessage(Unknown Source)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:574)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:477)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:380)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4659)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:4345)
at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3822)
at weblogic.jms.client.JMSSession.access$000(JMSSession.java:115)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5170)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
[2012-03-30T12:02:24.059+02:00] [wls_oim1] [NOTIFICATION] [IAM-0080006] [oracle.iam.platform.kernel.impl] [tid: [ACTIVE].ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: oiminternal] [ecid: 15dcd4762ac88ff7:-76b53ee5:1365f45a05d:-8000-0000000000000002,0] [APP: oim#11.1.1.3.0] Orchestration process moved to failed stage, and the corresponding error is - {0}[[
oracle.iam.platform.kernel.EventFailedException: Modification failed because user TESTUSER125 is not synchronized to the LDAP directory.
at oracle.iam.ldapsync.impl.eventhandlers.user.UserModifyLDAPHandler.execute(UserModifyLDAPHandler.java:140)
at oracle.iam.platform.kernel.impl.OrchProcessData.runPreProcessEvents(OrchProcessData.java:898)
at oracle.iam.platform.kernel.impl.OrchProcessData.runEvents(OrchProcessData.java:634)
at oracle.iam.platform.kernel.impl.OrchProcessData.executeEvents(OrchProcessData.java:227)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:665)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.process(OrchestrationEngineImpl.java:435)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:381)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.orchestrate(OrchestrationEngineImpl.java:334)
at oracle.iam.identity.usermgmt.impl.UserManagerImpl.modify(UserManagerImpl.java:896)
at oracle.iam.identity.usermgmt.api.UserManagerEJB.modifyx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.jee.spi.MethodInvocationVisitorImpl.visit(MethodInvocationVisitorImpl.java:37)
at weblogic.ejb.container.injection.EnvironmentInterceptorCallbackImpl.callback(EnvironmentInterceptorCallbackImpl.java:54)
at com.bea.core.repackaged.springframework.jee.spi.EnvironmentInterceptor.invoke(EnvironmentInterceptor.java:50)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy358.modifyx(Unknown Source)
at oracle.iam.identity.usermgmt.api.UserManager_nimav7_UserManagerRemoteImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
at oracle.iam.identity.usermgmt.api.UserManager_nimav7_UserManagerRemoteImpl.modifyx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
at $Proxy199.modifyx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy323.modifyx(Unknown Source)
at oracle.iam.identity.usermgmt.api.UserManagerDelegate.modify(Unknown Source)
at com.doha.customeventhandler.DohaEDWAttributePostProcessEventHandler.execute(DohaEDWAttributePostProcessEventHandler.java:133)
at oracle.iam.platform.kernel.impl.OrchProcessData.runPostProcessEvents(OrchProcessData.java:1166)
at oracle.iam.platform.kernel.impl.OrchProcessData.runEvents(OrchProcessData.java:710)
at oracle.iam.platform.kernel.impl.OrchProcessData.executeEvents(OrchProcessData.java:227)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:675)
at oracle.iam.platform.kernel.impl.OrchestrationEngineImpl.resumeProcess(OrchestrationEngineImpl.java:705)
at oracle.iam.platform.kernel.impl.OrhestrationAsyncTask.execute(OrhestrationAsyncTask.java:108)
at oracle.iam.platform.async.impl.TaskExecutor.executeUnmanagedTask(TaskExecutor.java:100)
at oracle.iam.platform.async.impl.TaskExecutor.execute(TaskExecutor.java:70)
at oracle.iam.platform.async.messaging.MessageReceiver.onMessage(MessageReceiver.java:68)
at sun.reflect.GeneratedMethodAccessor3380.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at com.bea.core.repackaged.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy347.onMessage(Unknown Source)
at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:574)
at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:477)
at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:380)
at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4659)
at weblogic.jms.client.JMSSession.execute(JMSSession.java:4345)
at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3822)
at weblogic.jms.client.JMSSession.access$000(JMSSession.java:115)
at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5170)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Caused by: oracle.iam.platform.kernel.EventFailedException: Modification failed because user TESTUSER125 is not synchronized to the LDAP directory.
at oracle.iam.ldapsync.impl.eventhandlers.user.UserModifyLDAPPreProcessHandler.modifyUser(UserModifyLDAPPreProcessHandler.java:162)
at oracle.iam.ldapsync.impl.eventhandlers.user.UserModifyLDAPHandler.execute(UserModifyLDAPHandler.java:119)
... 81 more
Regards
A Abhinay -
How to get the table name in the trigger definition without hard coding.
CREATE TRIGGER db.mytablename
AFTER UPDATE,INSERT
AS
INSERT INTO table1(col1)
SELECT InsRec.col1
FROM
INSERTED Ins
--Below i am calling one sp for which i have to pass the table name
EXEC myspname 'tablename'
In the above trigger,presently i am hard coding the tablename
but is it possible to get the table name dynamically on which the trigger is defined in order to avoid hard coding the table nameI really liked your audit table concept. You inspired me to modify it so that, the entire recordset gets captured and added a couple of other fields. Wanted to share my end result.
USE [YourDB]
GO
/****** Object: Trigger [dbo].[iudt_AutoAuditChanges] Script Date: 10/18/2013 12:49:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[iudt_AutoAuditChanges]
ON [dbo].[YourTable]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
SET NOCOUNT ON;
Declare @v_AuditID bigint
IF OBJECT_ID('dbo.AutoAudit','U') IS NULL BEGIN
CREATE TABLE [dbo].[AutoAudit]
( [AuditID] bigint identity,
[AuditDate] DateTime,
[AuditUserName] varchar(128),
[TableName] varchar(128) NULL,
[OldContent] XML NULL,
[NewContent] XML NULL
ALTER TABLE dbo.AutoAudit ADD CONSTRAINT
PK_AutoAudit PRIMARY KEY CLUSTERED
[AuditID]
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
CREATE NONCLUSTERED INDEX [idx_AutoAudit_TableName_AuditDate] ON [dbo].[AutoAudit]
( [TableName] ASC,
[AuditDate] ASC
)WITH (STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END
Select * Into #AuditDeleted from deleted
Select * Into #AuditInserted from inserted
While (Select COUNT(*) from #AuditDeleted) > 0 OR (Select COUNT(*) from #AuditInserted) > 0
Begin
INSERT INTO [dbo].[AutoAudit]
( [AuditDate], [AuditUserName], [TableName], [OldContent], [NewContent])
SELECT
GETDATE(),
SUSER_NAME(),
[TableName]=object_name([parent_obj]),
[OldContent]=CAST((SELECT TOP 1 * FROM #AuditDeleted D FOR XML RAW) AS XML),
[NewContent]=CAST((SELECT TOP 1 * FROM #AuditInserted I FOR XML RAW) AS XML)
FROM sysobjects
WHERE
[xtype] = 'tr'
and [name] = OBJECT_NAME(@@PROCID)
Set @v_AuditID = SCOPE_IDENTITY()
Delete from AutoAudit
Where AuditID = @v_AuditID
AND Convert(varchar(max),oldContent) = Convert(varchar(max),NewContent)
Delete top(1) from #AuditDeleted
Delete top(1) from #AuditInserted
End
END -
Passing values from HTML to JSP method,
Hello:
I am starting to wonder if what I am doing will ever work...
Ok, I am trying to avoid javascript. I have a drop-down list named "year" and I wish to call a JSP method that is defined/declared in the same JSP.
First, I want to pass the chosen option to the method and then store the name/value in a global variable.
Second, depending on what the user selects, I will get values from an array defined/initialized on page load AND display those values in another drop-down list.
As a test, and until now, I have done this. I am not passing anything yet, I just wanted to test this "fuzzy logic" I am having:
<%!
String currentYear;
private void showDaysInDDList()
currentYear = request.getparameter("year");
%>
Then on the HTML part of the page I have a drop-down list:
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="ffffcc">
<form method="POST" name="form1" action="left.jsp">
<select name="year" onchange="<%=showDaysInDDList()%>">
<option></option>
</select>
I am getting the following errors:
An error occurred at line: 105 in the jsp file: /p1/left.jsp
request cannot be resolved
....and regarding to the onchange="<%=showDaysInDDList()%>"> part I am getting the following:
An error occurred at line: 204 in the jsp file: /p1/left.jsp
The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
In the action="left.jsp", left.jsp is the same page where the drop-down list and the method is. I am not sure if that is another error.
I will continue here with my coffee ... any help will be extremely appreciated !!..
I'll have to shut down my "asp.net mind" for a while..
I'll reply later,
MMSOk, this is a bit messy here. I don't know how much you've read up on JSP but you seem confused about some fundamentals to me. However, you mention that you've worked with ASP .net so I'm going to assume you do have some notion of how thing should work in general.
1. JSP is on the server-side and events like onchange that you've used take place on the client-side after the JSP/ servlet code has run and produced the HTML page. So calling your showDaysInDDList() will not work.
2. Are you sure you know how the declaration tags ( <%! %> ) work? When you normally write JSP code without these tags, all that code gets compiled into the service method of the corresponding servlet that the JSP gets turned into. But, you can declare your own methods and variables outside the service method by using these tags.
So what you're effectively doing is declaring
private String/ void showDaysInDDList()
}and followed by your usual _jspService()
public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
}Now it may be clear, that the request object is not available in the showDaysInDDList() method by default; you'll either have to declare it ( not sure if it's good programming practice or not ) or pass the required parameters in the call.
3. Like you seem to have realized, that error about the printing of booleans was related to the return type of your method because <%= %> translates to out.println(); and since the argument was the method call, the return value was to be printed which here was a void ( not sure why it says boolean though :D ).
Read up on this introduction to JSPs http://java.sun.com/developer/onlineTraining/JSPIntro/contents.html, seems to be pretty good and covers everything in quick, short chunks.
Hope this helps. -
Trying to pass and object variable to a method
I have yet another question. I'm trying to display my output in succession using a next button. The button works and I get what I want using test results, however what I really want to do is pass it a variable instead of using a set number.
I want to be able to pass the object variables myProduct, myOfficeSupplies, and maxNumber to method actionPerformed so they can be in-turn passed to the displayResults method which is called in the actionPerformed method. Since there is no direct call to actionPerformed because it is called within one of the built in methods, I can't tell it to receive and pass those variables. Is there a way to do it without having to pass them through the built-in methods?
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import java.net.URL;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Panel extends JPanel implements ActionListener
protected JTextArea myTextArea;
protected String newline = "\n";
static final private String FIRST = "first";
static final private String PREVIOUS = "previous";
static final private String NEXT = "next";
public Panel( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
super(new BorderLayout());
int counter = 0;
//Create the toolbar.
JToolBar myToolBar = new JToolBar( "Still draggable" );
addButtons( myToolBar );
//Create the text area used for output.
myTextArea = new JTextArea( 450, 190 );
myTextArea.setEditable( false );
JScrollPane scrollPane = new JScrollPane( myTextArea );
//Lay out the main panel.
setPreferredSize(new Dimension( 450, 190 ));
add( myToolBar, BorderLayout.PAGE_START );
add( scrollPane, BorderLayout.CENTER );
myTextArea.setText( packageData( myProduct, myOfficeSupplies, counter ) );
setCounter( counter );
} // End Constructor
protected void addButtons( JToolBar myToolBar )
JButton myButton = null;
//first button
myButton = makeNavigationButton( FIRST, "Display first record", "First" );
myToolBar.add(myButton);
//second button
myButton = makeNavigationButton( PREVIOUS, "Display previous record", "Previous" );
myToolBar.add(myButton);
//third button
myButton = makeNavigationButton( NEXT, "Display next record", "Next" );
myToolBar.add(myButton);
} //End method addButtons
protected JButton makeNavigationButton( String actionCommand, String toolTipText, String altText )
//Create and initialize the button.
JButton myButton = new JButton();
myButton.setActionCommand( actionCommand );
myButton.setToolTipText( toolTipText );
myButton.addActionListener( this );
myButton.setText( altText );
return myButton;
} // End makeNavigationButton method
public void actionPerformed( ActionEvent e )
String cmd = e.getActionCommand();
// Handle each button.
if (FIRST.equals(cmd))
{ // first button clicked
int counter = 0;
setCounter( counter );
else if (PREVIOUS.equals(cmd))
{ // second button clicked
counter = getCounter();
if ( counter == 0 )
counter = 5; // 5 would be replaced with variable maxNumber
setCounter( counter );
else
counter = getCounter() - 1;
setCounter( counter );
else if (NEXT.equals(cmd))
{ // third button clicked
counter = getCounter();
if ( counter == 5 ) // 5 would be replaced with variable maxNumber
counter = 0;
setCounter( counter );
else
counter = getCounter() + 1;
setCounter( counter );
displayResult( counter );
} // End method actionPerformed
private int counter;
public void setCounter( int number ) // Declare setCounter method
counter = number; // stores the counter
} // End setCounter method
public int getCounter() // Declares getCounter method
return counter;
} // End method getCounter
protected void displayResult( int counter )
//Test statement
// myTextArea.setText( String.format( "%d", counter ) );
// How can I carry the myProduct and myOfficeSupplies variables into this method?
myTextArea.setText( packageData( product, officeSupplies, counter ) );
myTextArea.setCaretPosition(myTextArea.getDocument().getLength());
} // End method displayResult
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event dispatch thread.
public void createAndShowGUI( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
//Create and set up the window.
JFrame frame = new JFrame("Products");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add content to the window.
frame.add(new Panel( myProduct, myOfficeSupplies, maxNumber ));
//Display the window.
frame.pack();
frame.setVisible( true );
} // End method createAndShowGUI
public void displayData( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
JTextArea myTextArea = new JTextArea(); // textarea to display output
JFrame JFrame = new JFrame( "Products" );
// For loop to display data array in a single Window
for ( int counter = 0; counter < maxNumber; counter++ ) // Loop for displaying each product
myTextArea.append( packageData( myProduct, myOfficeSupplies, counter ) + "\n\n" );
JFrame.add( myTextArea ); // add textarea to JFrame
} // End For Loop
JScrollPane scrollPane = new JScrollPane( myTextArea ); //Creates the JScrollPane
JFrame.setPreferredSize(new Dimension(350, 170)); // Sets the pane size
JFrame.add(scrollPane, BorderLayout.CENTER); // adds scrollpane to JFrame
JFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // Sets program to exit on close
JFrame.setSize( 350, 170 ); // set frame size
JFrame.setVisible( true ); // display frame
} // End method displayData
public String packageData( Product myProduct, OfficeSupplies myOfficeSupplies, int counter ) // Method for formatting output
return String.format( "%s: %d\n%s: %s\n%s: %s\n%s: %s\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f",
"Product Number", myOfficeSupplies.getProductNumber( counter ),
"Product Name", myOfficeSupplies.getProductName( counter ),
"Product Brand",myProduct.getProductBrand( counter ),
"Number of Units in stock", myOfficeSupplies.getNumberUnits( counter ),
"Price per Unit", myOfficeSupplies.getUnitPrice( counter ),
"Total Value of Item in Stock is", myOfficeSupplies.getProductValue( counter ),
"Restock charge for this product is", myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ),
"Total Value of Inventory plus restocking fee", myOfficeSupplies.getProductValue( counter )+
myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ) );
} // end method packageData
} //End Class Panelmultarnc wrote:
My instructor has not been very forthcoming with assistance to her students leaving us to figure it out on our own.Aren't they all the same! Makes one wonder why they are called instructors. <sarcasm/>
Of course it's highly likely that enough information was imparted for any sincere, reasonably intelligent student to actually figure it out, and learn the subject in the process.
And if everything were spoonfed, how would one grade the performance of the students? Have them recite from memory
public class HelloWorld left-brace
indent public static void main left-parenthesis String left-bracket right-bracket args right-parenthesis left-brace
And everywhere that Mary went
The lamb was sure to go
db
Maybe you are looking for
-
VL10B - change Storage location for delivery
Hi all, I have a requirement wherin, for the deliveries created for purchase orders, the storage location needs to be defaulted from the production order. The configuration of picking has only one stloc for my plant, but we have the same amterial sto
-
Hi Gurus! In my present code it is able to handle the list price i.e showing '01''s. I would like to do something like this :- we can only have 1 item for the billing document #/item # combination otherwise the net values and quantities will be exagg
-
Recently when using a rather unreliable internet connection I'm often get dropped connections that prevent pages from loading. In the past this used to result in an "Unable to connect to server page" when the timeout happened, which was fine as I cou
-
Hi guys, I am joining on internship a company that's using Oracle EBS, and before allowing me to work on the real thing, they had me experiment with this one: http://r12vis.infosemantics.net/ which is based on Oracle EBS R12. I am facing the followi
-
Cisco LMS 3.1 / Java 1.6.0_05
Hello - The java on my LMS server was upgraded on accident and has since been removed. I was wondering if someone could point me in the right direction for downloading JRE 1.6.0_05??? Thank you!