Object & Array readability in AS 2
Hi,
I am having a problem with getting the data which I have put
in an Object and an Array.
I made a script which contains the object playField and the
Array tile.
The data in the array and object must be used to determine
the position of movieclips.
However in some functions the data in the array or in the
object cannot be read.
Please see the code I attached.
The things that do work:
- the object and array are created and work fine.
- the for loop works great and creates 24 movieclips
- in these 24 movieclips the movieclips named 1 to 24 are
placed correctly
- the button btn_scramble is placed correctly
This doesn't work:
- the placement of the gameWhite will work hover it will not
be placed on the X and Y position of playField.posX and
playField.posY;
- tracing the playField object ( trace(playField); ) in the
placeGameWhite() function will show: [object Object]
- However tracing the posX of the playField object in this
same function will show: undefined;
- The same happens with tracing tile and e.g. tile[4];
When I put the same traces in the this.btn_scramble.onRelease
function I get the same results.
I am using Flash 8, with Actionscript 2.
Can someone help me out?
I really do not understand why it is giving me such a hard
time.
Regards,
Bart-Jan
I am sorry but it doesn't work for me.
If you place a trace in the placeGameWhite function (to trace
the playField.posX) like this:
placeGameWhite = function() {
trace(playField.posX);
this.attachMovie("mc_spelWhite", "mc_spelWhite", saveDepth);
this.mc_spelWhite._y = playField.posY;
this.mc_spelWhite._x = playField.posX;
What do you see in your trace?
I will get an: undefined
though I expect a '150'
well basically thats my problem.
And thats not solved either...
I am getting frustrated because it worked fine and I do not
see why it suddenly changed ....
Similar Messages
-
I am unable to figure out the way in which I can return an object
array from a cpp file to java. Is there any obvious error which you can spot in
my CPP file?
When I try to return a single object in the native function,
it works fine but when I try to extend it and return an array of the object, it
throws an error.
Please find below the details
h1. Java Class
public class Flight {
public String ID;
public class InterfaceClass {
private native Flight[] GetFlights();
public static void main(String[] args)
Flight[] objFlight = new
InterfaceClass().GetFlights();
System.+out+.println(objFlight[0].ID);
static {
System.+loadLibrary+("main");
h1. CPP File
JNIEXPORT jobjectArray JNICALL Java_InterfaceClass_GetFlights(JNIEnv env, jobject obj)
//1. ACCESSING THE FLIGHT CLASS
jclass cls_Flight = env->FindClass("LFlight;");
//2. CONSTRUCTOR FOR FLIGHT CLASS
jmethodID mid_Flight = env->GetMethodID(cls_Flight,"<init>", "()V");
//3. CREATING AN OBJECT OF THE FLIGHT CLASS
jobject objFlight = env->NewObject(cls_Flight, mid_Flight);
//4. ACCESSING THE FLIGHT's "ID" FIELD
jfieldID fid_ID = env->GetFieldID(cls_Flight, "ID","Ljava/lang/String;");
//5. SETTING THE VALUE TO THE FLIGHT's "ID" FIELD
env->SetObjectField(objFlight,fid_ID, env->NewStringUTF("ABC"));
//6. ACCESSING THE FLIGHT ARRAY CLASS
jclass cls_Flight_Array = env->FindClass("[LFlight;");
if(cls_Flight_Array == NULL)
printf("Error-1");
//7. CREATING A NEW FLIGHT ARRAY OF SIZE 1 jobjectArray arrFlightArray = env->NewObjectArray(1,cls_Flight_Array,NULL);
if(arrFlightArray == NULL)
printf("Error-2");
//8. INSERTING A FLIGHT BJECT TO THE ARRAY
env->SetObjectArrayElement(arrFlightArray,0,objFlight);
return arrFlightArray;
h1. Error
# A fatal error has been detected by the Java Runtime Environment:
# EXCEPTION_ACCESS_VIOLATION
(0xc0000005) at pc=0x6d9068d8, pid=1804, tid=3836
# JRE version: 6.0_18-b07
# Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode, sharing
windows-x86
# Problematic frame:
# V [jvm.dll+0x1068d8]
# An error report file with more information is saved as:
# C:\Users\Amrish\Workspace\JNI Test\bin\hs_err_pid1804.log
# If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
C:\Users\Amrish\Workspace\JNI Test\bin>java -Djava.library.path=.
InterfaceClass
Exception in thread "main" java.lang.ArrayStoreException
at
InterfaceClass.GetFlights(Native Method)
at
InterfaceClass.main(InterfaceClass.java:6)
C:\Users\Amrish\Workspace\JNI Test\bin>java -Djava.library.path=.
InterfaceClass
Exception in thread "main" java.lang.ArrayStoreException
at
InterfaceClass.GetFlights(Native Method)
at
InterfaceClass.main(InterfaceClass.java:6)
Edited by: amrish_deep on Mar 18, 2010 7:40 PM
Edited by: amrish_deep on Mar 18, 2010 7:40 PM//6. ACCESSING THE FLIGHT ARRAY CLASS
jclass cls_Flight_Array = env->FindClass("[LFlight;");The argument to NewObjectArray is the +element+ class of the array you're about to create, not the +array+ class itself. -
Java Null Pointer Exception when assigning a value to an Object Array
I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. I get the following error: Exception during processing: java.lang.NullPointerException
Any assistance would be greatly appreciated.
Here's my class:
public class ComparatorBO implements Comparable {
private SingleOwnerRequestNodeDetail nodeDetailInfo;
private int orderNbr;
public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
return nodeDetailInfo;
public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
this.nodeDetailInfo = nodeDetailInfo;
public int getOrderNbr() {
return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
public void setOrderNbr (int orderNbr) {
this.orderNbr = orderNbr;
public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
if (!(anotherNodeDetailInfo instanceof ComparatorBO))
throw new ClassCastException ("An single owner request node detail object is expected");
int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
return this.orderNbr - anotherNodeDetailOrderNbr;
}Here's the code where I read in the objects and attempt to place them in the comparableBO[]
ComparatorBO[] comparatorBOArray = null;
comparatorBOArray = new ComparatorBO[requestInfo.length];
for (int i=0; i < requestInfo.length; i++)
SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
ComparatorBO comparatorBO = new ComparatorBO();
nodes.setSingleOwnerRequestNodeID(requestInfo.getSingleOwnerRequestNodeID());
nodes.setSingleOwnerRequestNodeType(requestInfo[i].getSingleOwnerRequestNodeType());
nodes.setSingleOwnerRequestOpCode(requestInfo[i].getSingleOwnerRequestOpCode());
nodes.setSingleOwnerRequestOrderNbr(requestInfo[i].getSingleOwnerRequestOrderNbr());
comparatorBO.setNodeDetailInfo(nodes);
*comparatorBOArray[i].setNodeDetailInfo(comparatorBO.getNodeDetailInfo());*
comparatorBOArray[i].setOrderNbr(Integer.parseInt(nodes.getSingleOwnerRequestOrderNbr()));imadeveloper wrote:
I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. I get the following error: Exception during processing: java.lang.NullPointerException
Any assistance would be greatly appreciated.
Here's my class:
public class ComparatorBO implements Comparable {
private SingleOwnerRequestNodeDetail nodeDetailInfo;
private int orderNbr;
public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
return nodeDetailInfo;
public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
this.nodeDetailInfo = nodeDetailInfo;
public int getOrderNbr() {
return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
public void setOrderNbr (int orderNbr) {
this.orderNbr = orderNbr;
public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
if (!(anotherNodeDetailInfo instanceof ComparatorBO))
throw new ClassCastException ("An single owner request node detail object is expected");
int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
return this.orderNbr - anotherNodeDetailOrderNbr;
}Here's the code where I read in the objects and attempt to place them in the comparableBO[]
ComparatorBO[] comparatorBOArray = null;
comparatorBOArray = new ComparatorBO[requestInfo.length];
for (int i=0; i < requestInfo.length; i++)
SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
ComparatorBO comparatorBO = new ComparatorBO();
nodes.setSingleOwnerRequestNodeID(requestInfo.getSingleOwnerRequestNodeID());
nodes.setSingleOwnerRequestNodeType(requestInfo[i].getSingleOwnerRequestNodeType());
nodes.setSingleOwnerRequestOpCode(requestInfo[i].getSingleOwnerRequestOpCode());
nodes.setSingleOwnerRequestOrderNbr(requestInfo[i].getSingleOwnerRequestOrderNbr());
comparatorBO.setNodeDetailInfo(nodes);
*comparatorBOArray[i].setNodeDetailInfo(comparatorBO.getNodeDetailInfo());*
comparatorBOArray[i].setOrderNbr(Integer.parseInt(nodes.getSingleOwnerRequestOrderNbr()));
Well normally when someone wont tell me what line the error occured in I copy paste their code into my compiler and find out. But you have other classes which you have not shown us so I cannot help you.
Incase you missed my point, please tell us where the error occured! -
Calling a method that returns an object Array
Hello.
During a JNICALL , I wish to call a method which returns an object array.
ie my java class has a method of the form
public MyObject[] getSomeObjects(String aString){
MyObject[] theObjects=new MyObject[10];
return theObjects
Is there an equivalent to (env)->CallObjectMethod(...
which returns a jobjectArray instead of a jobject, and if not could somebody suggest a way around this.
Thanks,
NeilI believe an array oj jobjects is also a jobject. You can then cast it to another class.
-
Object Array problem in Websphere WebServices
Hi,
Can someone help me out with a situation that I am stuck with in WebServices.
I have a WebService which returns a DTO which has a getter and setter for an array of another type of DTO object.
Sample:-
public class MyDTO extends AnotherDTO implements Serializable {
private InnerDTO qcDtoList[] = new InnerDTO[0];
public MyDTO() {
public InnerDTO[] getQcDtoList() {
return qcDtoList;
public void setQcDtoList(InnerDTO[] resEDXDTOs) {
qcDtoList = resEDXDTOs;
But when I generate the WSDL for the webservice using WSAD 5.1 that uses the above DTO, the server side generated skeleton file looks like:-
public class MyDTO extends AnotherDTO implements java.io.Serializable {
private InnerDTO[] qcDtoList;
public MyDTO() {
public InnerDTO[] getQcDtoList() {
return qcDtoList;
public void setQcDtoList(InnerDTO[] qcDtoList) {
this.qcDtoList = qcDtoList;
As you can see from above, my initialization info is not available in the generated skeleton. I also tried putting the initialization in the constructor, with no effect.
What could be the reason for this? And is it possible to initialize my InnerDTO without losing it in the generated skeleton?
I simply want to initialize the object array.
If I need to modify my WSDL, what additional annotations should I add on the WSDL to get the desired effect?
I use WSAD's (Websphere Studio App Developer) IBM Websphere Webservices protocol and the JDK version is 1.3.1 and WSAD version is 5.1.
I would really appreciate if you can throw light on this?
Thanx and Regds,
Prashanth.Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
v_categories IN ARCHIVE.integer_aat,
rs OUT RSType)
AS
/* PURPOSE: Return Search Results for the Category and Keyword Provided
VARIABLES:
v_categories = Document Categories array entered
v_term = Keyword entered
rs = Result Set
TYPE tbl_integer IS TABLE OF INTEGER;
tbl_cat tbl_integer;
BEGIN
FOR i IN 1 .. v_categories.COUNT
LOOP
tbl_cat.EXTEND(1);
tbl_cat(i) := v_categories(i);
END LOOP;
OPEN rs FOR
SELECT A.ID,
B.CATEGORY,
A.FILENAME,
A.DISPLAY_NAME,
A.COMMENTS
FROM TBL_ARCHIVE_DOCUMENTS A,
TBL_ARCHIVE_DOC_CAT B,
TBL_ARCHIVE_DOC_KEYWORDS C
WHERE A.ID = B.ID
AND A.ID = C.ID
AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
AND C.KEYWORD = v_term
ORDER BY A.ID;
END SEL_SEARCH_RESULTS; -
Trouble writing to object array
Hi I did a semester of java 2 years ago and I'm trying to remember what I knew so please bear with me...
I am extracting data from an xml file and then writing that information to an object array called files containing 4 string and 1 array. This files array is in turn an element in another object array containing 400 files arrays called records.
It appeared to be working but when I want it to print out which ever record I have selected it only prints out the last record! It seems to be overwriting each files array with the next?
Another problem I can only print out an element of the array not the entire thing?
Please help have spent weeks on this
Here is the code:
Object[] Records = new Object[400];
Object files[] = new Object[5];
NodeList records = doc.getElementsByTagName("record");
for( int i = 0; i < records.getLength();i++)
Element record = (Element) records.item(i);
NodeList headers = record.getElementsByTagName("header");
Element header = (Element) headers.item(0);
NodeList ids = header.getElementsByTagName("identifier");
for(int j = 0; j < ids.getLength(); j++){
Element id = (Element) ids.item(j);
String ID = getText(id);
files[0] = ID;
NodeList metadatas = record.getElementsByTagName("metadata");
Element metadata = (Element) metadatas.item(0);
NodeList citeseers = metadata.getElementsByTagName("oai_citeseer:oai_citeseer");
Element citeseer = (Element) citeseers.item(0);
NodeList titles = citeseer.getElementsByTagName("dc:title");
for(int k = 0; k < titles.getLength(); k++){
Element title = (Element) titles.item(k);
String TITLE = getText(title);
files[1] = TITLE;
NodeList subjects = citeseer.getElementsByTagName("dc:subject");
for(int m = 0; m < subjects.getLength(); m++){
Element subject = (Element) subjects.item(m);
String SUBJECT = getText(subject);
files[2] = SUBJECT;
NodeList descriptions = citeseer.getElementsByTagName("dc:description");
for(int n = 0; n < descriptions.getLength(); n++){
Element description = (Element) descriptions.item(n);
String DESCRIPTION = getText(description);
files[3] = DESCRIPTION;
String[] Names = new String[20];
NodeList authors = citeseer.getElementsByTagName("oai_citeseer:author");
for(int l = 0; l < authors.getLength(); l++){
Element author = (Element) authors.item(l);
Names[l] = author.getAttribute("name");
files[4] = Names;
System.out.println("The id is "+files[0]);
System.out.println("The title is "+ files[1]);
System.out.println("The Subject is "+ files[2]);
System.out.println("The Description is "+ files[3]);
for(int q=0; q < authors.getLength(); q++){
System.out.println("The Names are "+ ((String[])files[4])[q]);
//Records[i] = files;
System.out.println(((Object[])Records[0])[0]);I'm afraid I'm not going to make you a millionaire but I feel so relieved at the moment that if I had a million I'd give it to you!!Yeah, I know you won't make me a millionaire, but I can dream... :)
thanks for all your helpYou are welcome. Do you understand why you needed to move the creation of the "files" array. -
Hey Guys,
I am trying to append or add another set of data to my object array but with no success. What I need is later on in my code I want to add new data to the rows array.
Any advise would be gratefully appreciated. Here is my code:
Object[][] rows =
{ { "AOLX", new Integer(10), new Double(12.1), OrderLocation.BUY, OrderStatus.RECIEVED }, {
"ORCLX", new Integer(55), new Double(34.56), OrderLocation.BUY, OrderStatus.RECIEVED }, {
"CSCOX", new Integer(100), new Double(5.6), OrderLocation.SELL, OrderStatus.PROCESSING }, {
"NXTLX", new Integer(200), new Double(7.8), OrderLocation.BUY, OrderStatus.PROCESSING }, {
"DELLX", new Integer(30), new Double(9.11), OrderLocation.SELL, OrderStatus.CANCELLED }
};Edited by: onlynew4now on Aug 6, 2009 5:29 AMYou got a severe case of Object denial.
I'd start with writing a class like this:
public class Order {
private String name;
private int amount;
private BigDecimal cost;
private OrderLocation location;
private OrderStatus status;
public Order(String name, int amount, BigDecimal cost, OrderLocation location, OrderStatus status) {
this.name = name;
this.amount = amount;
this.cost = cost;
this.location = location;
this.status = status;
public Order(String name, int amount, String cost, OrderLocation location, OrderStatus status) {
this(name, amount, new BigDecimal(cost), location, status);
// add getters and if necessary setters
}Then your code can look like this:
Order[] rows = {
new Order("AOLX", 10, "12.1", OrderLocation.BUY, OrderStatus.RECIEVED),
new Order("ORCLX", 55, "34.56", OrderLocation.BUY, OrderStatus.RECIEVED),
new Order("CSCOX", 100, "5.6", OrderLocation.SELL, OrderStatus.PROCESSING),
new Order("NXTLX", 200, "7.8", OrderLocation.BUY, OrderStatus.PROCESSING),
new Order("DELLX", 30, "9.11", OrderLocation.SELL, OrderStatus.CANCELLED);
}; -
what do i have to do to create and object array in a class of other class. i tried to created an object of that class first and the create the array by the compiler complains that there is a problem. here is the code.
classJTBar---------------------------------------------------
ackage JTShapes;
import java.awt.*;
public class JTBar extends JTFilledRectangle{
int height=20; int length=0;//i will use the inheritated methods
public JTBar(){//contructor that will be called on creating object
setHeight(20);//method of class JTRectangle
setWidth(0);//method of class JTRectangle
public void setLengh (int x){
length = x;
public void incLengh(int y){
length = length+y;
}//end class
User class
port JTShapes.*;
import JTUtils.*;
import javax.swing.*;
public class User extends JTUser{
public void begin(){
JTBar jtbarobject= new JTBar();
JTBar[] arrayObj= new JTBar[8];
String[] weekDay= {"Monday", "Tuesday", "Wednesday", "Thuersday",
"Friday", "Saturday", "Sunday"};You don't have to do this:
String[] weekDay = new String[]{"Monday", "Tuesday", "Wednesday", "Thuersday", "Friday", "Saturday", "Sunday"};
This works fine:
String[] weekDay= {"Monday", "Tuesday", "Wednesday", "Thuersday", "Friday", "Saturday", "Sunday"};
What kind of Exception are you getting? I'm guessing you're getting a NullPointerException?
Looks like you're declaring your array correctly, but you are not initializing it:
JTBar[] arrayObj= new JTBar[8];
for (int i = 0; i < arrayObj.length; i++) {
arrayObj[i] = new JTBar();
} -
Is there any way to directly convert and object Array to a Collection object. Basically i need to create a ArrayList from Object Array. The ArrayList has a constructor and also provides a method addAll() that accept Collection as parameter. So the problem becomes , how to convert Object Array to collection. As per my understanding all arrays should be essentially Collection Interface subclass.
So why am i not able to cast?
What is wrong in calling Object Array a sub class of Collection?
// OrderLineItem[] is the object array that i wish to have as ArrayList
// This code generates error -
//"ErpOrder.java": Error #: 364 : cannot cast gal.ERP.OrderLineItem[] to java.util.Collection
public void setLineItems( OrderLineItem[] arrOrderLineItem ) {
m_arrLineItems = new ArrayList((Collection)arrOrderLineItem);
}Is there no way except iterating through the array and adding individual Objects to ArrayList?By "Object array" do you mean an Array class, or do you mean an Object[]? They are different. The Array class wraps an Object[] and provides useful methods to manipulate it.
There is no such thing as a Collection object, per say. "Collection" is an interface implemented by many objects such as LinkedList, Vector, ArrayList, HashSet, and TreeSet.
The Collection interface is designed to be an interface to any object that can keep a mutable list of other Objects, check to see if an Object is in that list, and iterate through all Objects in the list.
As far as resources go, I suggest the API reference at http://java.sun.com/j2se/1.4.1/docs/api/index.html. -
Object Array Data Provider Refresh Possible bug
Hello
I am having a problem with Object Array Data Provider in terms that the table's data is not changed corectly after a request as expected, but after two requests.
Steps to reproduce the bug:
0. Create a new Visual Web project, call it 'test'.
Set 'Bundled Tomcat ' or 'Sun 9' as deploy target server.
Edit 'Page1' of the project.
1. Create an Entity class, simple class that has only getters and setters with a few fields (lets say 'id' and 'name').
2. In the SessionBean1 that is generated by the framework create an array of Entity class named 'entityArr', and getters and setters for this field.
3. Add a new Array Object Data Provider on the page and set in its properties as array the array created in the previous step 'entityArr (SessionBean1)'.
4. Add a new table component, and set as data provider the provider created in step 3.
In the Table's Layout map the fields from the Entity class, and set whatever compnents you desire for each component's type or leave the default ones (Static Text).
5. Add a 'property change trigger component' on the page. I called it like this because I tried the following :
5.1 A text field and a button to submit the text value
5.2 A Calendar component with autosubmit
5.3 A DropDown with autosubmit.
6. On the property change trigger component created at step 5 set a value_changed method that changes the the array that should be displayed by the table.
For Example, for a DropDown component, you will have a method like this :
public void dropDown1_processValueChange(ValueChangeEvent event) {
String idStr = (String) event.getNewValue();
System.out.println("Entity id :"+idStr);
if(idStr .equals("item1")) {
fillSessionBean1(true);
else {
fillSessionBean1(false);
getSessionBean1().setItemName(idStr);
private void fillSessionBean1(boolean fillValues) {
Entity[] values ;
if(fillValues) {
values = new Entity[4];
for ( int i=0;i<values.length; i++) {
Entity entity = new Entity();
entity.setDescription("Description "+i);
entity.setName("Name "+i);
entity.setId(i) ;
values[i] = entity;
else {
//values = new Entity[0];
values = null;
getSessionBean1().setEntityArr(values);
7. When running the program, if the selected is Item1, the table does not show the array set if on this branch.
I am using :
Netbeans 5.5 build 20061017100,
Visual Web Pack 070104_2,
Ent.Pack 20061212
jdk 1.6.0
Operating Systems : Both Linux Suse10 and Windows.
If anyone has a solution for this please let me know.OK
While no one responded, I had to think for myself.
There is a bug in the code generated by netbeans or there is nowhere specified that if you attach an array to a data provider you will have to notify by hand the data provider that the array has changed.
You will have to put this line that is generated in init function in your valuechanged functions :
objectArrayDataProvider1.setArray((java.lang.Object[])getValue("#{SessionBean1.entityArr}"));
I think this aproach is a little bit wrong, even it works.
I believe the data provider should be notified the array has been changed.
There could be a much more simple aproaches :
1. In the code generated by netbeans, if you attach an array to a data provider the data provider will be notified after any set(Object[])
2. The data provider could have a function so you will ne anle to attach to the data provider an Object (the session bean, in my case) and the name of the function that retrieves the array (in my case, 'getEntityArr') .
The code generated by netbeans could add this function easily.
Maybe there are any other better aproaches, and I might be wrong.
It's good that it works. -
Problem when using object array as parameter of server-side event
Hi Friends,
I had defined an event in component interface of Component A, with object array as its parameter. but when I define event-handler for this event in Component B, the type of parameter in generated event-handler method is just the class itself instead of an array.
It's a bug or array parameter is not support by server-side event in WD4J?
Thanks in advanced.I think you are trying to do the editing of parameter from the java editor.
Do it via the controller editer. Go the methods tab. Select the actionhandler.
In the parameter section edit the paramter. Change the dimensions here.
Regards,
Ashwani Kr Sharma -
Retrieved data from database assignd to object array
Hi all,
Im new to java. I creat class it has item_name,item_qty,item_price as properties.then i need to create object array type of that class.now i need to assign values to properties in each element of object array from the database.in my database has ITEM table it has data according to that properties of class.how i do this.please tel me .
thanks in Advanced,Harsha_Lasith wrote:
yes I knew connect to the database using JDBC.but i have not clear understand about instantiate an object of a class using a constructor.please give me some example for those.
thanks in advance.If you don't know how to use constructors you really should not be trying to use the JDBC. Learn Java first. -
Sort and Object array of Arrays
Hi,
I have an object array that contains a String[] and an int[].
Object[String[], int[]]
The values in the Strings array must be in the same position in the array as those in the int array i.e
String [0] is the string representation of int[0].
Its for a bar chart.
That is all working beautifully.
Now however I want to sort the int array in descending order by the value of the ints in the array and thus the order or the String array has to mirror this.
I am using a comparator to do this but it just wont work. I'm sure this is the way but how should it look?
Has anybody got any ideas?
Thanks in advance,
L.use the bubblesort:
for (int i = a.length; --i >= 0; ) {
for (int j = 0; j < i; j++) {
if (a[j][1] > a[j+1][1]) {
int temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
} -
How To Load SINGLE CELL Value as Object - In 2D Object Array - InvalidCastException
Setup: ---- VB.net - Visual Studio 2010 - Excel Version 2010 - Option Strict ON
The following WORKS FINE all day long for loading MULTIPLE range values IE: ("F2:F5") or more into a 2D Object Array... No problem... as in the following..
Dim myRangeTwo As Range = ws.Range("F2:F5") ' MULTIPLE CELL RANGE
Dim arr2(,) As Object = CType(myRangeTwo.Value(XlRangeValueDataType.xlRangeValueDefault), Object(,))
The ws.range("F2:F5") values are stuffed into the myRangeTwo range variable as 2D Objects and then those are easily stuffed into the 2D object array...
But this does not work for a SINGLE cell range...
Dim myRangeTwo As Range = ws.Range("F2:F2") ' SINGLE CELL RANGE F2 ONLY
Dim arr2(,) As Object = CType(myRangeTwo.Value(XlRangeValueDataType.xlRangeValueDefault), Object(,))
This triggers an Invalid Cast Exception error on trying to load into the arr2(,).. because the ws.range("F2:F2") is stuffed into the myRangeTwo variable as a "string"
not as an object therefore is not possible to stuff it into an Object Array and so correctly causes the Invalid Cast Error...
How do you handle this seemingly ridiculously simple problem ??
thanks... CjHello,
Simply answer, you need to determine if the range is a single cell or multiple cells. So the following is geared for returning a DataTable for a start and end cell addresses that are different, granted there is no check to see if the cells are valid i.e.
end cell is before start cell i.e.
Since B1 and B10 is a valid range we are good but if we pass in F1:F1 or F10:F10 we must make a decision as per the if statement at the start of the function and if I were expecting this to happen I would have another function that returned a single value.
Option Strict On
Option Infer On
Imports Excel = Microsoft.Office.Interop.Excel
Imports Microsoft.Office
Imports System.Runtime.InteropServices
Module ExcelDemoIteratingData_2
Public Sub DemoGettingDates()
Dim dt As DataTable = OpenExcelAndIterate(
IO.Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"GetDatesFromB.xlsx"),
"Sheet1",
"B1",
"B10")
Dim SomeDate As Date = #12/1/2013#
Dim Results =
From T In dt
Where Not IsDBNull(T.Item("SomeDate")) AndAlso T.Field(Of Date)("SomeDate") = SomeDate
Select T
).ToList
If Results.Count > 0 Then
For Each row As DataRow In Results
Console.WriteLine("Row [{0}] Value [{1}]",
row.Field(Of Integer)("Identifier"),
row.Field(Of Date)("SomeDate").ToShortDateString)
Next
End If
End Sub
Public Function OpenExcelAndIterate(
ByVal FileName As String,
ByVal SheetName As String,
ByVal StartCell As String,
ByVal EndCell As String) As DataTable
If StartCell = EndCell Then
' Decide logically what to do or
' throw an exception
End If
Dim dt As New DataTable
If IO.File.Exists(FileName) Then
Dim Proceed As Boolean = False
Dim xlApp As Excel.Application = Nothing
Dim xlWorkBooks As Excel.Workbooks = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
Dim xlWorkSheets As Excel.Sheets = Nothing
Dim xlCells As Excel.Range = Nothing
xlApp = New Excel.Application
xlApp.DisplayAlerts = False
xlWorkBooks = xlApp.Workbooks
xlWorkBook = xlWorkBooks.Open(FileName)
xlApp.Visible = False
xlWorkSheets = xlWorkBook.Sheets
' For/Next finds our sheet
For x As Integer = 1 To xlWorkSheets.Count
xlWorkSheet = CType(xlWorkSheets(x), Excel.Worksheet)
If xlWorkSheet.Name = SheetName Then
Proceed = True
Exit For
End If
Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkSheet)
xlWorkSheet = Nothing
Next
If Proceed Then
dt.Columns.AddRange(
New DataColumn() _
New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Int32), .AutoIncrement = True, .AutoIncrementSeed = 1},
New DataColumn With {.ColumnName = "SomeDate", .DataType = GetType(Date)}
Dim xlUsedRange = xlWorkSheet.Range(StartCell, EndCell)
Try
Dim ExcelArray(,) As Object = CType(xlUsedRange.Value(Excel.XlRangeValueDataType.xlRangeValueDefault), Object(,))
If ExcelArray IsNot Nothing Then
' Get bounds of the array.
Dim bound0 As Integer = ExcelArray.GetUpperBound(0)
Dim bound1 As Integer = ExcelArray.GetUpperBound(1)
For j As Integer = 1 To bound0
If (ExcelArray(j, 1) IsNot Nothing) Then
dt.Rows.Add(New Object() {Nothing, ExcelArray(j, 1)})
Else
dt.Rows.Add(New Object() {Nothing, Nothing})
End If
Next
End If
Finally
ReleaseComObject(xlUsedRange)
End Try
Else
MessageBox.Show(SheetName & " not found.")
End If
xlWorkBook.Close()
xlApp.UserControl = True
xlApp.Quit()
ReleaseComObject(xlCells)
ReleaseComObject(xlWorkSheets)
ReleaseComObject(xlWorkSheet)
ReleaseComObject(xlWorkBook)
ReleaseComObject(xlWorkBooks)
ReleaseComObject(xlApp)
Else
MessageBox.Show("'" & FileName & "' not located. Try one of the write examples first.")
End If
Return dt
End Function
Private Sub ReleaseComObject(ByVal sender As Object)
Try
If sender IsNot Nothing Then
System.Runtime.InteropServices.Marshal.ReleaseComObject(sender)
sender = Nothing
End If
Catch ex As Exception
sender = Nothing
End Try
End Sub
End Module
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. -
how to create an object array for the class ?
which should be increment dynamically.i will have an separate class which has an JPanel
with components for eg customclass .
for that i need to create an object with array in the
main class. which should be increment as the action
performed.Is there a question you want to ask? You've already been given an answer to the one you asked, yet you replied with a nonsensical statement. There is no such thing as a "dynamic array" in Java. All arrays are of a fixed size. If you want a larger array you'll have to create a larger array and copy the contents of the old array to the new array. Alternatively you can use a List implementation such as ArrayList that can take care of that job for you.
Maybe you are looking for
-
Record action for "Fit to artwork bounds"?
Hi, since there is no short cut for the very usefull (but hidden) function of fitting the page to the artwork bounds I tried to record the steps with an action. I create a new action and selected page setup in the menu and shrinkt to bounds of the pa
-
My new Quad Core iMac Not Getting Along With LG External.
I just got a new Quad Core iMac. It's great, except for one this: My LG Flatron W1953T insists on a 1360 x 768 resolution. Unfortunately, the Displays control panel does not offer that as an option. The closes is 1280 x 768, which means I have a stre
-
BBM outgoing messages show clock symbol
My outgoing BBM text messages are accompanied by a light blue clock symbol when normally there is a D followed by an R... Are these messages hanging? It has been hours. A battery pull doesn't seem to do anything to help. Help?!
-
Is the iTunes popularity bar on the iPhone?
On my iPad when I select an album in iTunes I can see which songs seem to be the most popular, but I don't see that on my iPhone. I'm just wondering if I'm missing it, becuase it's a handy tool.
-
SAVING EMAIL ATTACHMENTS TO THE CLOUD
When I am travelling, I would like to replace my laptop with my Playbook and mini keyboard but I can't for one limiting factor. I need to be able to save files from email attachments directly to a cloud service like box or dropbox or attach files fr