Variable reuse
Good evening all,
I would just like to find out how and why the following code is possible. By my thought process I would have thought that using the counter variable assigned to the two different attributes would lead to the same result in each but I can also see that each one is instantiated separately.
Counter counter = new Counter();
context.setAttribute("hitCounter",counter);
counter = new Counter();
context.setAttribute("orderCounter",counter);would this be the same as saying:
context.setAttribute("hitCounter", new Counter());
Good evening all,
I would just like to find out how and why the
following code is possible. By my thought process I
would have thought that using the counter variable
assigned to the two different attributes would lead
to the same result in each but I can also see that
each one is instantiated separately.
Counter counter = new Counter();
context.setAttribute("hitCounter",counter);
counter = new Counter();
context.setAttribute("orderCounter",counter);would this be the same as saying:
context.setAttribute("hitCounter", new
Counter());
I have a child, I name him fred. Time goes on.
I have a second child, I also name him fred.
How many children do I have ?
New makes a new object.
Note hopefully this explanation helps. If not I am sure there are others that will correct this.
Similar Messages
-
Variable reuse with different sql clauses
Hi There,
Is it possible to reuse the same variable with different sql queries in packages....
Example:
i have a variable say
1)variable name: filename
2)query in variable: select 'emp.txt' from dual
so using this variable name in data store, i am passing file name dynamically, but i need to change the file name emp.txt to dept.txt if emp.txt feed is missing.
One solution from my side is using one dump table having file name. any more without using db tables
please share views
Cheers,
SuryaHi Bhabani,
Thanks for your prompt reply, it was really helpful....
for suppose in i have feed name like dept.20110325, consider as sysdate.
so i need to pass feed name like above format...
As of my understanding from your reply, in third step we can give only string like 'emp1.txt', is not possible to write query like in assign mode: select 'dept'||to_char(sysdate,'yyyymmdd') from dual
Cheers,
Surya -
Bind Variable reuse in GROUP BY queries
We have several queries that are rather large (in are opinion, that is) and they each have 10 '?' place holders for binding JDBC parameters. These queries also use bind variables in the WHERE and GROUP BY clauses. Eventhough there are 10 bind variable place holders ('?'), there are only 3 distinct values needed.
So...in TOAD or SQL*Plus, we run the queries and "reuse" the same three bind variables and the query works fine. If we use 10 different bind variables, filled with the 3 values, we get a an error, "not a GROUP BY expression."
We would like to make these calls as JDBC PreparedStatements and bind the parameters at run time, so that we could take advantage of the statement cache and increase performance. But...since JDBC parameter binding seems to be positional, we seem to be getting 10 different bind variables at runtime in the PreparedStatement call. Is there a way to "reuse" the bind variables that JDBC is binding at runtime?
Regards,Yep...that is what we are doing. We have a work around that is to manually replace the ? with string data and then pass the query in complete. It will work fine for us. I was just checking the alternatives. The query is large, but the offending code is:
...( select distinct T3.ptcpt_cd,trunc(new_time(T1.start_dt_gmt, 'GMT', ?)) trade_date,
sum(decode(T1.sttl_item_num, 10, T1.sttl_item_qnty, 0)) DA_CHARGE_MW,
sum(decode(T1.sttl_item_num, 10, T1.sttl_item_amt, 0)) DA_CHARGE_AMT,
sum(decode(T1.sttl_item_num, 30, T1.sttl_item_qnty, 0)) BAL_CHARGE_MW,
sum(decode(T1.sttl_item_num, 30, T1.sttl_item_amt, 0)) BAL_CHARGE_AMT,
sum(decode(T1.sttl_item_num, 20, T1.sttl_item_qnty, 0)) DA_CREDIT_MW,
sum(decode(T1.sttl_item_num, 20, T1.sttl_item_amt, 0)) DA_CREDIT_AMT,
sum(decode(T1.sttl_item_num, 40, T1.sttl_item_qnty, 0)) BAL_CREDIT_MW,
sum(decode(T1.sttl_item_num, 40, T1.sttl_item_amt, 0)) BAL_CREDIT_AMT,
T3.source_cd Source
from nm_sttl_item_dtl T1, nm_settlement T2, nm_sttl_statement T3
where trunc(new_time(T1.start_dt_gmt, 'GMT', ?)) between to_date(?,'mm/dd/rrrr') and to_date(?,'mm/dd/rrrr')
and sttl_item_num in (10, 20, 30, 40)
and (sttl_item_qnty <> 0 and sttl_item_amt <> 0)
and T1.sttl_id = T2.sttl_id
and T2.statement_id = T3.statement_id
and T3.ptcpt_cd = 'FAC'
and T3.source_cd = AREA'
group by T3.ptcpt_cd,trunc(new_time(T1.start_dt_gmt, 'GMT', ?)), T3.source_cd)... -
Can an Advanced Action Launch another Advanced Action (or more than one)?
Hi Everyone,
I was wondering if an Advanced action could launch another Advanced Action? I have a custom quiz results page and I want several different Advanced Actions to run when the learner enters the page. Is this possible?
paul...Of course Rick, but that is not really calling another action from an action, since you need to use another event.
As Rod points out, preparing carefully advanced actions by choosing the right events, variables (reusing them) and the proper sequence for statements and decisions in advanced actions can solve a lot of situations. I have been trying to explain that in several blog posts. That was also the reason why I asked about more details concerning the user's situation. It is about an On Enter action. Until now I rarely had to use a workaround by navigating to a dummy slide to execute an advanced action over there using its slide events. All depends on planning and preparing.
Lieve -
Our FMS2 stopped responding to incoming requests today.
Looking in all the edge.*.log files, they are flooded with this
line:
Assert failed in /util/TCProcess.cpp line 609
any ideas what this is about? I had to restart FMS to get it
to accept connections again.
Linux: 2.6.17-1.2142_FC4smpIt happens sometimes on our FMS too. So it's certainly not
some specific error in your application(s). Some ppl recommended to
set the application variable "reuse" from true to false (check your
xml configfiles) but in our case it didn't help us a bit.
Some suggested that the amount of tcp-connections / sockets
on the server would be "full" but that would need about 60.000+
connections and guess what ; netstat didn't show more than 200 at a
time (in our case).
Does you app use a lot of external scripting (e.g. calling
external xml-files or scripts?) Do you clear those outgoing objects
? You can by issuing "obj = null;" and then "delete obj;" but be
warned for circular references (closures) ; in those cases you
think you deleted an object but in fact it's still in memory and
-maybe- reserving an tcp-slot so in the end the FMS might run out
of free sockets. This is however more a conspiracy-plot-theory than
scientific based reverse-engineering :) -
Hi,
I am trying to get UCCX to contact a SOAP web service so that I can make routing decisions based on the SOAP response. But as I have virtually no experience with SOAP/XML I am struggling a bit.
below is the SOAP command that I am trying to send to the web service to query if an ANI has called recently
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<FindInteraction xmlns="http://www.something.com/v4">
<data>
<Tenant>Test</Tenant>
<Options>
<Contact>000000000</Contact>
<DataValues />
</Options>
</data>
</FindInteraction>
</soap12:Body>
</soap12:Envelope>
the response should be something like the below, the "Code" value is what I will base my routing on.
<Response>
<Header>
<ClientID></ClientID>
<Id>038793f2-5b11-4ead-a05b-aa77ff76430f</Id>
<Status>
<Code>109021</Code>
<Description>The contact that you submitted does not exist.</Description>
<ErrorMessage></ErrorMessage>
<Result>ContactNotFound</Result>
</Status>
</Header>
<Data>
</Data>
</Response>
I have had a look at https://supportforums.cisco.com/docs/DOC-23899 but I am still struggling to understand SOAP.
is the above simple to do, or do I need to find a "programming friend"
any help appreciated.
DarrenHi,
I have written and tested a code fragment.
Let's do this with the "template" way.
First, we create a simple XML template:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:plat="http://www.virtualhold.com/Toolkit/Platform-v4">
<soapenv:Header/>
<soapenv:Body>
<plat:FindInteraction>
<plat:data>
<plat:Tenant>__TENANT__</plat:Tenant>
<plat:Options>
<plat:Contact>__CONTACT__</plat:Contact>
<plat:DataValues />
</plat:Options>
</plat:data>
</plat:FindInteraction>
</soapenv:Body>
</soapenv:Envelope>
Notice the __TENANT__ and __CODE__ strings. We will replace them with something useful within the script.
Save this as vht_request.xml and upload it to the Document Management page to your UCCX.
Next, add the following five new variables to your script:
code - type String, initial value: "" - this variable will hold the "Code" sent by our SOAP server;
doc - type Document, initial value: DOC[] - this is just a utility variable, reused many times as we will see;
soapResponseString - type String, initial value: "" - another utility variable, for storing the response sent by the SOAP server;
soapServerURL - type String, initial value: well, this is the endpoint URL of your SOAP server. The WSDL file you sent me the other day already contains a reference to it, "http://172.16.202.59/VHTPlatformWS-v4/VHTPlatformWS.asmx" but you might want to double check with the person administering this SOAP server. My mock SOAP server was available at "http://10.232.128.68:8090/mockIVHTPlatformWS", I am using it in my script;
xpathResultSelectCode - type String, initial value: this is the XPath expression to filter out the value of the Code XML element encapsulated within other elements. You probably want to use this: "//*[local-name()='FindInteractionResult']/*[local-name()='Header']/*[local-name()='Status']/*[local-name()='Code']"
Next, we are going to use the following steps:
1. doc = Keyword Transform Document.
The Keyword Template: DOC[vht_request.xml] - this essentially tells UCCX to take the XML file we uploaded previously, convert it to a Document type variable.
Keywords: this is where the magic happens. I mapped "__TENANT__" to "Test" and "__CONTACT__" to "5556363". You will probably want to map these to something legal, like the ANI of the caller.
Document: doc. This just assigns the document we transformed at this step to this variable.
2. Create XML Document. Source Document: doc. Document: doc. Do not write anything into the Source ID box. This step tells UCCX to look at the transformed document as an XML document.
3. Set. The Variable would be soapResponseString, and the Value - well, this code block:
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
String content = doc;
int readTimeout = 5000;
try {
java.net.URL url = new java.net.URL(soapServerURL);
java.net.HttpURLConnection urlCon = (java.net.HttpURLConnection) url.openConnection();
urlCon.setFixedLengthStreamingMode(content.length());
urlCon.setReadTimeout(readTimeout);
urlCon.setDoInput (true);
urlCon.setDoOutput (true);
urlCon.setUseCaches (false);
urlCon.setRequestMethod("POST");
urlCon.setRequestProperty("Content-Type","text/xml;charset=UTF-8");
java.io.DataOutputStream output = new java.io.DataOutputStream(urlCon.getOutputStream());
output.writeBytes(content);
output.flush();
output.close();
java.io.DataInputStream input = new java.io.DataInputStream(urlCon.getInputStream());
int bufSize = 4096; // buffer size, bytes
byte[] bytesRead = new byte[bufSize];
int bytesReadLength = 0;
while(( bytesReadLength = input.read( bytesRead )) > 0 ) {
baos.write(bytesRead,0,bytesReadLength);
input.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
return null;
return baos.toString();
I took this from my other document, https://supportforums.cisco.com/document/97736/uccx-8x-really-simple-soap-client-no-custom-jar
Again, if anything bad happens, this code block would return null. Nothing. Nada. Nil. Semmit. If everything goes fine, this code block issues a SOAP HTTP request and the response would appear as a String as the value of the soapResponseString variable.
4. doc = Create XML Document. Source Document: (Document) soapResponseString. Document: doc. This tells UCCX to cast the value of the soapResponseString into a Document type variable, and, create an XML document out of it.
5. code = Get XML Document Data. Document: doc. XML path: xpathResultSelectCode. Result Data: code. This is where the other magic happens, the system would filter out the value of the Code element and assign this value to the code variable.
I will try and upload screenshots after I posted this.
G. -
Problem in reusing the declader slider variable in VBox
There is a slider variable {color:#0000ff}specexpontLevel{color}. This variable is used 2 times in VBox content as per my requirement. But the VBox contents are not visble @ the runtime. If I call the variable only once in VBox then the contents are displayed. Without using VBox, if I reuse in the contents of scene also it is not displaying.
The NetBeans IDE is displaying the below runtime error
java.lang.IllegalArgumentException: illegal assignment of group.content: group=Group node=Slider
{color:#0000ff}*Does this mean the variable cannot be resued in the content? If so the concept of reusability is defeated. If it is intensionally included what is the justification behind it?*{color}
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.scene.control.Slider;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.layout.VBox;
var diffusespecconstLevel: Slider = Slider{
max: 2.0
min:0.0
value:0.7
width : 70
layoutInfo: LayoutInfo{ width: 70 minWidth: 70}
var {color:#0000ff}specexpontLevel{color} : Slider = Slider{
max: 20.0
min:0.0
value:5.0
width : 70
layoutInfo: LayoutInfo{ width: 70 minWidth: 70}
var surfaceLevel: Slider = Slider{
max: 2.5
min:0.0
value:1.0
width : 70
layoutInfo: LayoutInfo{ width: 70 minWidth: 70}
Stage {
title: "Hello World"
width: 250
height: 500
scene: Scene {
content: [
Text {
content: "Hello World! My First JavaFX program!"
x:0
y:12
font: Font {
name: "Arial"
size: 12
VBox {translateY : 20 content : [<font color="#0000ff">specexpontLevel</font>,diffusespecconstLevel,surfaceLevel, <font color="#0000ff">specexpontLevel</font>]}Hello!
could you elaborate your answer please?
I have the same kind of problem in an application I am working on for now.
I have the application' scene content inside which I have a node whose id I set to "applicationContent" (this node is a group).
Upon clicking on menu buttons, I will remove the node having the "applicationContent" id from my application content and will insert another one having the same id.
The inserted node is generated on the fly upon clicking on the button.
Method below is executed only once and adds menu buttons to the left of my application.
Notice the action:function() method that calls the setContent(Node) method when the button is clicked.
function insertMenuItems(): Void
var elementCounter: Number = 0;
var firstY: Number = 160;
for(currentItem in menu)
var currentButton:MenuButton = MenuButton
text: currentItem.title;
layoutX: 8;
width: 182;
layoutY: firstY + elementCounter * 40;
action: function()
this.title = currentItem.title;
setContent(currentItem.getContent());
insert currentButton into content;
elementCounter++;
}The setContent method is provided here below.
As you see, it removes the node having the "applicationContent" id and adds the one passed in parameter ("the new application content").
* Sets the main content of the application.
* <p>
* Each time a menu button gets clicked, the main content of the application
* will be replaced by the one attached to the <code>MenuButton</code>
* </p>
function setContent(applicationContent:Node):Void
for(currentNode in content)
if(currentNode.id.equals("ApplicationContent"))
delete currentNode from content;
break;
applicationContent.layoutX = 300;
applicationContent.layoutY = 500;
insert applicationContent into content;
}the "{code}insert applicationContent into content;{code}" line is the one producing the exception, even though, in the end, my content is correctly updated on screen.
exception happening at this specific line is the following:
Exception in trigger:
java.lang.IllegalArgumentException: illegal assignment of group.content: group=Group node=ApplicationContent [id=ApplicationContent]
at javafx.scene.Group$_SBECL.onChange(Group.fx:209)
at com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:157)
at com.sun.javafx.runtime.location.SequenceVariable.setAsSequence(SequenceVariable.java:259)
at com.sun.javafx.runtime.location.SequenceVariable.set(SequenceVariable.java:222)
at com.sun.javafx.runtime.location.SequenceVariable.set(SequenceVariable.java:39)
at com.sun.javafx.runtime.location.Bindings$BijectiveBinding$2.onChange(Bindings.java:156)
at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:220)
at com.sun.javafx.runtime.location.AbstractLocation$1.onAction(AbstractLocation.java:217)
at com.sun.javafx.runtime.location.AbstractLocation.iterateChildren(AbstractLocation.java:182)
at com.sun.javafx.runtime.location.AbstractLocation.invalidateDependencies(AbstractLocation.java:254)
at com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:150)
at com.sun.javafx.runtime.location.SequenceVariable.replaceSlice(SequenceVariable.java:324)
at com.sun.javafx.runtime.location.SequenceVariable.insert(SequenceVariable.java:442)
at javafxapplication3.FixedRootScene.setContent(FixedRootScene.fx:139)
at javafxapplication3.FixedRootScene.setContent(FixedRootScene.fx:139)
at javafxapplication3.FixedRootScene$1.lambda(FixedRootScene.fx:109)
at javafxapplication3.FixedRootScene$1.lambda(FixedRootScene.fx:109)
at javafxapplication3.FixedRootScene$1.invoke(FixedRootScene.fx:106)
at javafxapplication3.FixedRootScene$1.invoke(FixedRootScene.fx:106)
at javafxapplication3.FixedRootScene$1.invoke(FixedRootScene.fx:106)
at javafxapplication3.FixedRootScene$1.invoke(FixedRootScene.fx:106)
at javafx.scene.control.Button.fire(Button.fx:50)
at com.sun.javafx.scene.control.ButtonBaseBehavior.mouseRelease(ButtonBaseBehavior.fx:78)
at com.sun.javafx.scene.control.caspian.AbstractButtonSkin$4.lambda(AbstractButtonSkin.fx:68)
at com.sun.javafx.scene.control.caspian.AbstractButtonSkin$4.invoke(AbstractButtonSkin.fx:68)
at com.sun.javafx.scene.control.caspian.AbstractButtonSkin$4.invoke(AbstractButtonSkin.fx:68)
at javafx.scene.Node.impl_processMouseEvent(Node.fx:1679)
at javafx.scene.Node.preprocessMouseEvent(Node.fx:1705)
at javafx.scene.Scene$MouseHandler.process(Scene.fx:665)
at javafx.scene.Scene$MouseHandler.process(Scene.fx:550)
at javafx.scene.Scene.impl_processMouseEvent(Scene.fx:368)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.fx:496)
at com.sun.javafx.tk.swing.SwingScene$SwingScenePanel.doMouseEvent(SwingScene.java:388)
at com.sun.javafx.tk.swing.SwingScene$SwingScenePanel.mouseReleased(SwingScene.java:408)
at java.awt.Component.processMouseEvent(Component.java:6134)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5899)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
at java.awt.Container.dispatchEventImpl(Container.java:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
If yo ucould explain me why the exception fires, i'd be very happy ^^
Thank you very much in advance for your help!
Edited by: jerome_jadoulle on Jul 14, 2009 2:00 AM -
Query property "Save and reuse variable value" doesn't work in BW EHP1
We have a workbook which contain 4 queries, every different worksheet is a different query.
All the queries are on the Same InfoCube and all the queries use the same variables.
In the properties of the query n.2 we set the parameter "Save and reuse variable values" then we refresh the 1st query and all work fine (the system asks the variable values) but when we refresh the 2nd query the system doesn't use the same variable values that we have inserted for the query n.1
We don't have the same problem in 7.0.
Any help is appreciated.
LucaHi,
I suppose, you need to set the 'Save and reuse variable values' for each query individually in the workbook. I am not sure however there is a option where you can specify to apply the settings of one query to all queries in the work book.
Please check and hope it helps.
Regards,
Adarsh Mhatre -
I have a scenario where I need to reuse the variable in several packages without refreshing it. For example I have package 1, 2 and 3. I have defined a variable var_timestamp with latest value and declare this variable in package 3, I have generated scenario of package 1 and 2 and insert it in package 3. I refresh the variable as first step and reuse the variable in package 1 and 2 without refreshing it but var_timestamp value is not recognized in package 1 and 2.I didn't declare these variable in package 1 and 2 as I dont want it to be refresh again. I have tried Not Persistant variable as well but it didn't work. Any clue how can we reuse the variable without refreshing it in different packages.
Thanks
KashWhen you use a variable in a package it is important to declare it
Use the variable as Latest Value
Dont use the Historize or Persistent
If you have declared and refreshed it in package 3.......there might be 2 steps right?
1st step as declare and another step as refresh
In your packages 1 & 2, you should make a step as declare variable only, where you should drag your variable in the package and make it a declare variable step
And re-generate the scenario to be able to get the effect of this change in your scenario
Let me know in case you face any difficulties -
How can i reuse same variables that i create using c:set var="index" /
hi all,
please some one helpme!!!!!!
how can i reuse same variable that i create using
<c:set var="index" value="${0}"/>
cause later in the program i use index to do some condition and based on that i increment ...
so for example if i say...
<c:if test="${index==0}">
<c:set var="index" value="${index+1}"/>
</c:if>
will it be like
if(index==0)
index++;
can i do like i did be4. if not what do i need to do to reuse. cause i use the variable atleast 5 time and its keep changing on diff condition level.Have you tried it?
It should work, provided you are on the same page.
The c:set tag creates the variable in pageScope by default.
If you forward to another JSP you need to set the scope to be "request" so that it is still available. -
Reusing a variable used for font
So I had
Font f = new Font("SansSerif",Font.PLAIN,12);
g.setFont(f);How can I reuse 'f' so I can change the font and then set f as the font again? I don't want to have to make a new variable every time I want to change the font.. and trying f=new Font(...) again creates an error; it says that it's already been declared.Font f = new Font(..);You should, after the above statement, be able to say:
f = new Font(..);To create a new font and assign it to f. -
Reusing a variable from a new object instance
I'm developing a stock list array for an assignment I'm currently working on. I've got most of it done, and it seems to be working for the most part, but I'm having trouble getting an array to accept individual variable entries created by new object instances in TestQ3.java.
I think problem is because the variable itemCode in CraftItem.java is being overwritten by the creation of a new object instance in the TestQ3.java file. I've tested it and believe this to be true.
I can add a String of my own choosing by using testArray.addCraftItemToStock(itemCode); line but I want to get the program to reuse the itemCode values that have already been created by the four new object instances in TestQ3.java. For example, I want to be able to add more instances of them to the testArray.
As I'm still relatively new to Java programming, I'm wondering how to do this. I've tried several solutions but I'm not getting anywhere. I'd appreciate it if anyone has any ideas?
Here's my code:
TestQ3.java
public class TestQ3 {
public static void main(String args[]) {
// creating a new StockItem array
CraftStock testArray = new CraftStock(CraftStock.initialStockCapacity);
// creating new object instance for Glue
Glue gluePVA = new Glue("PVA Glue",250,"789012",2.50);
// adds gluePVA item code to the testArray list
// testArray.addCraftItemToStock(gluePVA.getItemCode());
// creating new object instance for Card
Card colouredCard = new Card ("Coloured Card","A3","654321",1.25);
// adds coloured card item code to the testArray list
// testArray.addCraftItemToStock(colouredCard.getItemCode());
// creating new object instance for Glue
Glue superGlue = new Glue ("Super Glue",25,"210987",1.50);
// adds superGlue item code to the testArray list
// testArray.addCraftItemToStock(superGlue.getItemCode());
// creating new object instance for Card
Card whiteCard = new Card ("White Card","A4","123456",0.50);
// adds superGlue item code to the testArray list
// testArray.addCraftItemToStock(whiteCard.getItemCode());
// display complete stocklist
testArray.displayCraftStockList();
// this adds the itemCode from gluePVA to the array but
// it comes out as the last itemCode entry 123456 rather than 789012
// when I run the code. The problem may lie with variable itemCode
testArray.addCraftItemToStock(gluePVA.getItemCode());
// display complete stocklist
testArray.displayCraftStockList();
CraftItem.java
public class CraftItem {
// instance variables
public static String itemCode;
private double price;
//private int stockCount;
// constructor
public CraftItem(String itemCodeValue, double itemPriceValue){
itemCode = itemCodeValue;
price = itemPriceValue;
//CraftStock.addCraftItemToStock(itemCode);
//stockCount++;
// getter for itemCode
public String getItemCode() {
return itemCode;
// getter for price
public double getPrice() {
return price;
// setter for itemCode
public void setItemCode(String itemCodeValue) {
itemCode = itemCodeValue;
// setter for price
public void setPrice(double itemPriceValue) {
price = itemPriceValue;
// toString() value
public String toString() {
return "Item code is " + itemCode + " and costs " + price + " pounds.";
Glue.java
public class Glue extends CraftItem{
// Instance variables
private String glueType;
private double glueVolume;
// Constructor
public Glue(String glueType, double glueVolume,
String itemCodeValue, double itemPriceValue) {
super(itemCodeValue, itemPriceValue);
glueType = glueType;
glueVolume = glueVolume;
// getter
public String getGlueType() {
return glueType;
// getter
public double getGlueVolume() {
return glueVolume;
// setter
public void setGlueType(String glueTypeValue) {
glueType = glueTypeValue;
public void setGlueVolume(double glueVolumeValue) {
glueVolume = glueVolumeValue;
// toString
public String toString() {
return glueType + ", " + glueVolume + "ml, item code is "
+ super.getItemCode() + " and costs " + super.getPrice() + " pounds.";
Card.java
public class Card extends CraftItem{
// instance variables
private String cardType;
private String cardSize;
// Constructor
// added super(itemCodeValue, itemPriceValue) to call on CraftItem
public Card(String cardTypeValue, String cardSizeValue,
String itemCodeValue, double itemPriceValue) {
super(itemCodeValue, itemPriceValue);
cardType = cardTypeValue;
cardSize = cardSizeValue;
// getter
public String getCardType() {
return cardType;
// getter
public String getCardSize() {
return cardSize;
// setter
public void setCardType(String cardTypeValue) {
cardType = cardTypeValue;
// setter
public void setCardSize(String cardSizeValue) {
cardSize = cardSizeValue;
// toString
// using super. to call on methods from superclass CraftItem
public String toString() {
return cardType + ", size " + cardSize + ", item code is "
+ super.getItemCode() + " and costs " + super.getPrice() + " pounds.";
CraftStock.java
public class CraftStock {
public static int currentStockLevel;
public static String[] craftStock;
public static int initialStockCapacity = 10;
public CraftStock(int initialStockCapacity) {
currentStockLevel = 0;
craftStock = new String[initialStockCapacity];
public int currentStockLevel() {
return currentStockLevel;
public static void addCraftItemToStock(String itemCodeValue) {
if(currentStockLevel == 10){
System.out.println("Stock list full: cannot add new item code." +
"\nPlease remove an item if you want to add a new one.");
else{
craftStock[currentStockLevel] = itemCodeValue;
currentStockLevel++;
System.out.println("Item added");
public void removeCraftItemFromStock(String itemCode){
findStockItem(itemCode);
int i = -1;
do {
i++;
} while (!craftStock.equals(itemCode));
for (int j = i; j < currentStockLevel - 1; j++) {
craftStock[j] = craftStock[j + 1];
currentStockLevel--;
System.out.println("Item removed");
private int findStockItem(String itemCode){
int index = 0;
for(int i = 0; i < currentStockLevel; i++){
if(craftStock[i].equals(itemCode)){
index = i;
break;
else{
index = -1;
return index;
public void displayCraftStockList() {
if(currentStockLevel == 0){
System.out.println("There are no items in the stock list");
else{
for(int i = 0; i < currentStockLevel; i++){
System.out.println("Item at " + (i + 1) + " is " + craftStock[i]);
Message was edited by:
NikariusAn instance variable relates to an object. If you require a variable to be available across multiple objects of the same class then I suggest you declare a class variable using the static keyword in your declaration.
HTH -
Hi, please can someone help me with this as I have been
searching the forums for over an hour.
There is some indication that the code Dreamweaver creates
does not allow more than one recordset to use the same variable
parameter, ie a URL parameter in both recordset queries.
Can someone please help with how I can manually adjust the
code so that it works?
This is what I have so far for one recordset, which bit do I
change?
quote:
<%
Dim RSsepcsubdetail
Dim RSsepcsubdetail_cmd
Dim RSsepcsubdetail_numRows
Set RSsepcsubdetail_cmd = Server.CreateObject
("ADODB.Command")
RSsepcsubdetail_cmd.ActiveConnection =
MM_conn_vb_pureinfo_STRING
RSsepcsubdetail_cmd.CommandText = "SELECT * FROM specs_detail
WHERE prod_code = ?"
RSsepcsubdetail_cmd.Prepared = true
RSsepcsubdetail_cmd.Parameters.Append
RSsepcsubdetail_cmd.CreateParameter("param1", 200, 1, 255,
RSsepcsubdetail__MMColParam2) ' adVarChar
Set RSsepcsubdetail = RSsepcsubdetail_cmd.Execute
RSsepcsubdetail_numRows = 0
%>
As you can see, this recordset only has one parameter
variable, but my next recordset, on the same page, has the same
recordset variable.[email protected] wrote:
> Ok, but in my webpage, I have the url for the page,
ending in;
>
> admin_specs_2.asp?prod_code=LK-049
>
> I want the value, LK-049 to be available for more than 1
recordset on the
> page, it just wont work.
At the top of your page (code view) use this:
<%
Dim ParamProdCode
ParamProdCode = Request.QueryString("prod_code")
%>
Then in your recordset where it asks for value, just put
ParamProdCode.
Dooza
Posting Guidelines
http://www.adobe.com/support/forums/guidelines.html
How To Ask Smart Questions
http://www.catb.org/esr/faqs/smart-questions.html -
Capturing URL WITH VARIABLES for reuse?
Hi,
I have an application that authenticates users only if a
certain page is requested. Once they login, i'd like to send them
back to the page they came from, the one that required they log in.
BUT, I need to send them back to that page with some URL
variables intact (pageID, sometimes another one, it varies from
page to page).
I cannot for the life of me figure out how to do this...have
messed with GetTemplatePath and such, have looked at my Forta book,
have searched here and googled....this seems like it should be easy
but I can't figure out how to grab what I need.
Help?
Many thanks in advance....
LizThat was it!
I'll find one to answer now , many thanks :) -
Reuse a variable in OSB XPATH expression editor
I have a problem with replacing activity in Oracle Service Bus.
I created a variable with the follow content
<response>
<operationResponse name="OPERATION1" result=""/>
<operationResponse name="OPERATION2" result=""/>
<operationResponse name="OPERATION3" result=""/>
<operationResponse name="OPERATION4" result=""/>
</response>
For each operationResponse I call a businessProxy that invokes an external webservice. If this call is made with success, I replace `result=""` with `result="1"`.
I have created a replace activity like this:
<con3:replace contents-only="true" varName="responseElement"> <!-- var responseElement = <response>.*</response> -->
<con2:id>_ActionId-3886365367816551561--27a55993.13f0a38ab8f.-7c95</con2:id>
<con3:location>
<con2:xpathText>./operationResponse/@result</con2:xpathText>
</con3:location>
<con3:expr>
<con2:xqueryText>"1"</con2:xqueryText>
</con3:expr>
</con3:replace>
After running this program, all the attributes "results" are replaced by "1", if the businessService is called successfully.
The problems is that I need to replace the attribute "result" only for the element operationResponse that have the attribute "name" equal to the operationResponse that invokes the businessService.
I have created a variable called operationName that contains the current response/operationResponse. I used ./operationResponse[@name=$operationName]/@result.
The OSB XPATH expression editor is throwing the follow error:
Variable "$operationName" used but not declared for expression
Can anyone help with this?Hi, XPath and XQuery are conceptually different. XPath expression can not have variables while an XQuery expression can have a variable inside the XPath when the expression is bound to a variable.
To work around the issue, instead of using the condition in XPath expression inside replace you should write the XQuery expression of REplace in such a way that it results in what you need.
For ex. if I take the example above:
say the content of $body is as below:
<soap-env:Body>
<aaa>
<bbb>
<ccc>A</ccc>
<key>1</key>
</bbb>
<bbb>
<ccc>B</ccc>
<key>2</key>
</bbb>
</aaa>
</soap-env:Body>
and you wanted to replace values of ccc to X for any bbb elements which have key=1(and you have saved a variable called keyCheck with value '1' earlier in the flow), then you could do the following:
Replace contents of . in body with
<aaa>
for $bbb in $body/aaa/bbb
if ($bbb/key/text() = $keyCheck)
then
<bbb>
<ccc>X</ccc>
<key>{$bbb/key/text()}</key>
</bbb>
else
$bbb
</aaa>
Maybe you are looking for
-
Firefox crashes as soon as I click on the icon. Even in safe mode. I've tried all options of resolving this problem but nothing is working. I really hate using Safari and Chrome. Please help!
-
Video/Movie issues with multiple applications
I originally posted this question in the Quicktime Forum, but I realize it's not just a Quicktime issue, so I thought maybe I should check here? I have Quicktime Pro 7.6.2 and when I try to export a FLV to a MOV, there is no sound. I DO also have Per
-
Local logical standby and remote physical standby
Dear All, My database version is 10.2.0.1.0(production) and Operating System Linux x86-64 OS Version Red Hat Enterprise 4 Below is my configuration details: Rprimary Database:Two Nodes RAC StandBy Database LOCAL:Standalone database Standby Database R
-
How to export sap bi data in to oracle bi
Hi Experts, How to export sap bi data in to oracle bi. what is the connection used for this . Plz assist me, Thanks & Regards, P.Swaroop.
-
I can't skype and send my camera image, and when I launch Photo Booth it tells me that there is no connected camera