Instantiating a custom class through a string
I asked yesterday how to call a function from an XML file, and I figured out how to make that work using the string-to-function call.
so in my XML file I have <ITEM CALLBACK="ContactsList">View All</ITEM>, and my TextMenu class parses the XML file and creates my navigatable text menu instance. When enterMenu():String is called, it looks to see if the CALLBACK attribute has a value, and if so it returns it as a String.
so...
var callbackFnc:String = textMenu.enterMenu();
if(callbackFnc != null)
//here's where my problem is
var myClass:* = new [callbackFnc]();
I want to create a new instance of the ContactsList class through my XML file by having CALLBACK="ContactsList" and then using the string "ContactsList" to instantiate this object and add it to the the display list (it extends Sprite).
The code above currently invokes:
TypeError: Error #1007: Instantiation attempted on a non-constructor.
at com.cox::Contacts/::keyHandler()
How could I use a string of the class name to instantiate and add an instance of that class to the stage?
To create a class by is string name use this:
var ClassReference : Class = getDefinitionByName( "STRING NAME OF THE CLASS" ) as Class;
classInstance = new ClassReference();
in your case:
var ClassReference : Class = getDefinitionByName( "ContactsList" ) as Class
var contactList: * = new ClassReference();
Similar Messages
-
How to create custom attributes & object classes through ldif files in OID
Hi,
I have to create 4 attributes and one object class(custom) in OID. I want to creae these attributes and object class through LDIF file.
I tried creating an attribute through this command
ldapadd -p 389 -h localhost -D cn=orcladmin -w password -f D:/newattr.ldif
this ldif file contains inf. for creating a new attributes:
dn: cn=subschemasubentry
changetype: add
add: attributetypes
attributetypes: ( 1.2.3.4.5.6.10 NAME "xsUserType_new" DESC "User Type Definition" EQUALITY caseIgnoreMatch
SYNTAX "1.3.6.1.4.1.1466.115.121.1.15" )
I am getting error: Object class violation
Failed to find add in mandatory or optional attribute list.
Please help to find where I am going wrong...
Thanks.Hi Ajay,
Thank you for the help. Now i am able to create both attributes and object classes in OID through Ldif files.
I was getting constraint violation error because (I think) I was not giving proper naming convection for attributes and object classes. For OID, there are certain Ldap naming conventions. They are as follows:
# X below is the enterprise number assigned by IANA
1.3.6.1.4.1.X.1 - assign to SNMP objects
1.3.6.1.4.1.X.2 - assign to LDAP objects
1.3.6.1.4.1.X.2.1 - assign to LDAP syntaxes
1.3.6.1.4.1.X.2.2 - assign to LDAP matchingrules
1.3.6.1.4.1.X.2.3 - assign to LDAP attributes
1.3.6.1.4.1.X.2.4 - assign to LDAP objectclasses
1.3.6.1.4.1.X.2.5 - assign to LDAP supported features
1.3.6.1.4.1.X.2.9 - assign to LDAP protocol mechanisms
1.3.6.1.4.1.X.2.10 - assign to LDAP controls
1.3.6.1.4.1.X.2.11 - assign to LDAP extended operations
By using these conventions for attributes and object class, I did got any error and they were created in OID.
Thanks a zillion.
Kalpana. -
Dynamic Class Reference in Custom Class
I've created a custom class that I want to be able to
dynamically insert a movie clip from the library. I'm running into
trouble because I want to access the clip as a property of the
custom class object (ie: so it can be swapped out for another
library clip after instantiation, among other things). I'm using
getDefinitionByName() but I can't use it outside my addDiagram()
function (see attached code) because the string variable that
stores the name of the library clip isn't defined until after the
custom class constructor function. Any help is appreciated!
Thanks,
-Eriki'm not quite following - are you saying you want to access
panelDiagram in functions other than your addDiagram function? just
take your variable definition out of your function and make it a
class variable eg put the following line above your constructor:
private var panelDiagram:*;
and in the second line of your addDiagram function use:
panelDiagram = new diagramClass();
sorry if this isn't your answer, if it isn't i'm struggling
to understand the problem. -
Class has be instantiated in document class but having issue..HELP
Guys,
I am making my way with AS3 in little steps and have hit a
road block. This is what I have:
I have a document class called "Document Class"
I have a custom class called "Game"
I have instantiated an object of "Game" class and I am able
to trace a class method which return a simple "HELLO".
within my Game class, I have a variable(type Array) called
"questions" as instance variable.
I would like to add questions to "questions" array by using
"Mutator" method, or count the current elements with the questions
array and return the total number of questions. I am unable to add
or access elements to the questions array.
Any help would highly be appreciated, please.First thing: you need to set the functions you're calling to
public, so that you have access to them outside of your class.
Second: you are initializing 'questions' to null. I made some
changes and it seems to work for me:
//////////////Game
Class///////////////////////////////////////////////
public function Game()
//this.questions = null;
this.correctAnswers = null;
this.userAnswers = null;
// SETQUESTION FUNCTION CAN ADD QUESTIONS TO THE QUESTION
ARRAY;
public function myArr():void
trace(questions.length);
public function AddQuestions(val:String)
this.questions.push(val);
trace(val);
} -
Custom class loader and local class accessing local variable
I have written my own class loader to solve a specific problem. It
seemed to work very well, but then I started noticing strange errors in
the log output. Here is an example. Some of the names are in Norwegian,
but they are not important to this discussion. JavaNotis.Oppstart is the
name of my class loader class.
java.lang.ClassFormatError: JavaNotis/SendMeldingDialog$1 (Illegal
variable name " val$indeks")
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.lang.ClassLoader.defineClass(ClassLoader.java:431)
at JavaNotis.Oppstart.findClass(Oppstart.java:193)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at JavaNotis.SendMeldingDialog.init(SendMeldingDialog.java:78)
at JavaNotis.SendMeldingDialog.<init>(SendMeldingDialog.java:54)
at JavaNotis.Notistavle.sendMelding(Notistavle.java:542)
at JavaNotis.Notistavle.access$900(Notistavle.java:59)
at JavaNotis.Notistavle$27.actionPerformed(Notistavle.java:427)
JavaNotis/SendMeldingDialog$1 is a local class in the method
JavaNotis.SendMeldingDialog.init, and it's accessing a final local
variable named indeks. The compiler automatically turns this into a
variable in the inner class called val$indeks. But look at the error
message, there is an extra space in front of the variable name.
This error doesn't occur when I don't use my custom class loader and
instead load the classes through the default class loader in the JVM.
Here is my class loading code. Is there something wrong with it?
Again some Norwegian words, but it should still be understandable I hope.
protected Class findClass(String name) throws ClassNotFoundException
byte[] b = loadClassData(name);
return defineClass(name, b, 0, b.length);
private byte[] loadClassData(String name) throws ClassNotFoundException
ByteArrayOutputStream ut = null;
InputStream inn = null;
try
JarEntry klasse = arkiv.getJarEntry(name.replace('.', '/')
+ ".class");
if (klasse == null)
throw new ClassNotFoundException("Finner ikke klassen "
+ NOTISKLASSE);
inn = arkiv.getInputStream(klasse);
ut = new ByteArrayOutputStream(inn.available());
byte[] kode = new byte[4096];
int antall = inn.read(kode);
while (antall > 0)
ut.write(kode, 0, antall);
antall = inn.read(kode);
return ut.toByteArray();
catch (IOException ioe)
throw new RuntimeException(ioe.getMessage());
finally
try
if (inn != null)
inn.close();
if (ut != null)
ut.close();
catch (IOException ioe)
}I hope somebody can help. :-)
Regards,
Knut St�reI'm not quite sure how Java handles local classes defined within a method, but from this example it seems as if the local class isn't loaded until it is actually needed, that is when the method is called, which seems like a good thing to me.
The parent class is already loaded as you can see. It is the loading of the inner class that fails.
But maybe there is something I've forgotten in my loading code? I know in the "early days" you had to do a lot more to load a class, but I think all that is taken care of by the superclass of my classloader now. All I have to do is provide the raw data of the class. Isn't it so? -
Creating custom class instances for XML nodes
Hi guys,
I'm trying to load an external XML document in my application
and create an instance of a custom class for each node in the XML
based on the value of some of their elements. The instances created
will eventually end up in a DataGrid by the way. The problem I'm
having is there seems to be many ways of doing small parts of this
and I have no idea how to make them all gel. Initially I'm using
HTTPService to load the XML file but I've seen people just use an
XML object. Then, after that, I initially set the loaded XML to an
ArrayCollection but others have used XMLList or XMLListCollection.
I've no idea what's the best way to do this.
Eventually, when I've created all of these instances by
looping over the XML and creating them how will I make them
bindable to the data grid? I'm guessing I'll have to group them
somehow...
Any help would be greatly appreciated. ThanksHey Tracy,
That is exactly what I was talking about in a previous post
you replied to
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=585&threadid=1344350
Anyhow, Below is some code I created to do what your saying
somewhat dynamically. The idea being you can have many different
object types that you may want to populate with data from XML. In
my case I am using e4x as the result type from my web services. At
present I have about 6 different classes that call this function.
I'd love to get some opinions on the function. Good bad or
???? Any improvements etc????
package . . . .
import flash.utils.describeType;
import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import mx.utils.ObjectUtil;
* Utility class to convert xml based Objects to class
instances.
* Takes a value object as the destination and an xmlList of
data
* Look through all the items in the value object. Note we
are using classInfo..accessor since
* our objects are bound all variables become getter /
setter's or accessors.
* Also note, we can handle custom objects, arrays and
arrayCollections.
* History
* 03.11.2008 - Steven Rieger : Created class
public final class XMLToInstance
public static function xmlToInstance( destinationObject :
Object, sourceXMLList : XMLList ) : void
// Get the class definition in XML, from the passed in
object ( introspection so to speak )
var classInfo : XML = describeType( destinationObject );
// Loop through each variable defined in the class.
for each ( var aVar : XML in classInfo..accessor )
// If this is String, Number, etc. . . Just copy the data
into the destination object.
if( isSimple( aVar.@type ) )
destinationObject[aVar.@name] = sourceXMLList[aVar.@name];
else
// Dynamically create a class of the appropriate type
var className : String = aVar.@type;
var ObjectClass : Class = getDefinitionByName( className )
as Class;
var newDestObject : Object = Object( new ObjectClass());
// If this is a custom type
if( isCustomType( className ) && ObjectClass != null
// Recursively call itself passing in the custom data type
and the data to store in it.
// I haven't tested nested objects more than one level. I
suppose it should work.
// Note to self. Check.
xmlToInstance( newDestObject, sourceXMLList[aVar.@name] );
else
// Must be some sort of Array, Array Collection . . .
if( ObjectClass != null )
var anXMLList : XMLList = new XMLList(
sourceXMLList[aVar.@name] );
for each( var anItem : XML in anXMLList )
// I'm sure there are more types, just not using any of them
yet.
if( newDestObject is Array )
newDestObject.push( anItem )
else
newDestObject.addItem( anItem );
// Add the data to the destination object. . . .
destinationObject[aVar.@name] = newDestObject;
} // end function objectToInstance
public static function isSimple( dataType : String ) :
Boolean
* This function is pretty self explanatory.
* Check to see if this is a simple data type. Did I miss
any?
* History
* 03.11.2008 - Steven Rieger : Created function
switch( dataType.toLowerCase() )
case "number":
case "string":
case "boolean":
return true;
return false;
} // end isSimple
public static function isCustomType( className : String ) :
Boolean
* This function is pretty self explanatory.
* Check to see if this is a custom data type. Add them here
as you need. . .
* History
* 03.11.2008 - Steven Rieger : Created function
var aClassName : String = className.replace( "::", "."
).toLowerCase();
aClassName = aClassName.substr( aClassName.lastIndexOf( "."
) + 1, aClassName.length - aClassName.lastIndexOf( "." ) );
switch( aClassName )
case "ndatetimevo":
case "expenselineitemvo":
return true;
return false;
} // end isCustomType
} // end class
} // end package -
Webservice invocation - Custom class
Hi,
I am new to Jdeveloper and iam trying to invoke a webservice which does insert operation. I am invoking webservice using webservice data control mechanism.
In my data control pallette i have a method called conInsert(Object,String) where it takes two parameters
1) first parameter is of type java.lang.Object ( some custom class) - SiebelMessage_ListOfContactInterface_Contact
2) second parameter is of type java.lang.String - statusObject
WSDL entry for the conInsert operation:
<message
name="ConInsert_Input"
<partname="SiebelMessage"
type="xsdLocal0:ListOfContactInterfaceTopElmt"
</part
<partname="StatusObject"
type="xsd:string"
</part
</message
<messagename="ConInsert_Output"
<partname="SiebelMessage"
type="xsdLocal0:ListOfContactInterfaceTopElmt"
>
Now i need to create a form which accepts above specified fields and submit the form using conInsert (webservice operation). How can i create form accepting first and second parameter ?
Should i drag conInsert(Object;,String) method from Data control pallette to my jspx page ?
Can anyone help me with the solution.
Regards,
Ahmed.Shay,
I have tried the blog post url by Susan Duncan and i was able to map the fields through backing bean and through creating web service proxy. But while hitting the submit buttion i was encounted with below error.
JBO-29000: Unexpected exception caught: java.rmi.RemoteException, msg=Error parsing envelope: (1, 1) Start of root element expected.; nested exception is: javax.xml.soap.SOAPException: Error parsing envelope: (1, 1) Start of root element expected.*
Error parsing envelope: (1, 1) Start of root element expected.; nested exception is: javax.xml.soap.SOAPException: Error parsing envelope: (1, 1) Start of root element expected.*
I am not sure about why iam getting this error ?
btw, i have analyzed the sending and receiving packets from http analyzer
here is the request:
<?xml version = '1.0' encoding = 'UTF-8'?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://siebel.com.fmw1" xmlns:ns1="http://www.siebel.com/xml/Contact%20Interface">
<env:Body>
<ns0:ConInsert>
<SiebelMessage>
<ns1:ListOfContactInterface>
<ns1:Contact>
<ns1:Id>332</ns1:Id>
<ns1:FirstName>asdf</ns1:FirstName>
<ns1:LastName>asdf</ns1:LastName>
</ns1:Contact>
</ns1:ListOfContactInterface>
</SiebelMessage>
<StatusObject>asdf</StatusObject>
</ns0:ConInsert>
</env:Body>
</env:Envelope>
Here is the response:
HTTP/1.1 200 OK
Date: Tue, 04 Aug 2009 14:12:04 GMT
Server: IBM_HTTP_Server
siebel-error-symbol-1: Unknown Error Symbol
siebel-error-message-1: Invalid external service source 'WebService'. Check the server configuration or the request.(SBL-UIF-00243)
Content-Length: 0
Content-Type: text/xml; charset=UTF-8
Could you please tell me is anything wrong with my config ? looks like iam not able to reach server???
Regards,
Ahmed. -
Cannot convert type class java.lang.String to class oracle.jbo.domain.ClobDomain.
Using ADF Business Components I have a JSFF page fragment with an ADF form based on a table with has a column of type CLOB. The data is retrieved from the database and displayed correctly but when any field is changed and submitted the above error occurs. I have just used the drag and drop technique to create the ADF form with a submit button, am I missing a step?
I am using the production release of Jdeveloper11GReproduced and filed bug# 7487124
The workaround is to add a custom converter class to your ViewController project like this
package oow2008.view;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import oracle.jbo.domain.ClobDomain;
import oracle.jbo.domain.DataCreationException;
public class ClobConverter implements Converter {
public Object getAsObject(FacesContext facesContext,
UIComponent uIComponent,
String string) {
try {
return string != null ? new ClobDomain(string) : null;
} catch (DataCreationException dce) {
dce.setAppendCodes(false);
FacesMessage fm =
new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Invalid Clob Value",
dce.getMessage());
throw new ConverterException(fm);
public String getAsString(FacesContext facesContext,
UIComponent uIComponent,
Object object) {
return object != null ?
object.toString() :
null;
}then to register the converter in faces-config.xml like this
<faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
<application>
<default-render-kit-id>oracle.adf.rich</default-render-kit-id>
</application>
<converter>
<converter-id>clobConverter</converter-id>
<converter-class>oow2008.view.ClobConverter</converter-class>
</converter>
</faces-config>then reference this converter in the field for the ClobDomain value like this
<af:inputText value="#{bindings.Description.inputValue}"
label="#{bindings.Description.hints.label}"
required="#{bindings.Description.hints.mandatory}"
columns="40"
maximumLength="#{bindings.Description.hints.precision}"
shortDesc="#{bindings.Description.hints.tooltip}"
wrap="soft" rows="10">
<f:validator binding="#{bindings.Description.validator}"/>
<f:converter converterId="clobConverter"/>
</af:inputText> -
Problems with Reflection API and intantiating an class from a string value
I want to instantiate a class with the name from a String. I have used the reflection api so:
static Object createObject(String className) {
Object object = null;
try {
Class classDefinition = Class.forName(className);
object = classDefinition.newInstance();
} catch (InstantiationException e) {
System.out.println(e);
} catch (IllegalAccessException e) {
System.out.println(e);
} catch (ClassNotFoundException e) {
System.out.println(e);
return object;
Let's say my class name is "Frame1".
and then if i use:
Frame1 frm = (Frame1) createObject("Frame1");
everything is ok but i cannot do this because the name "Frame1" is a String variable called "name" and it doesn't work like:
name frm = (name) createObject("Frame1");
where i'm i mistaking?
Thanks very much!i have understood what you have told me but here is a little problem
here is how my test code looks like
Class[] parameterTypes = new Class[] {String.class};
Object frm = createObject("Frame1");
Class cls = frm.getClass();
cls.getMethod("pack",parameterTypes);
cls.getMethod("validate",parameterTypes);
everything works ok till now.
usually if i would of had instantiated the "Frame1" class standardly the "cls" (or "frm" in the first question ) object would be an java.awt.Window object so now i can't use the function (proprietary):
frame_pos_size.frame_pos_size(frm,true);
this function requires as parameters: frame_pos_size(java.awt.Window, boolean)
because my cls or frm objects are not java.awt.Window i really don't find any solution for my problem. I hope you have understood my problem. Please help. Thanks a lot in advance. -
Unit testing: Mocking custom classes with null
Hi,
I was trying to save time on testing the usual hashCode() and equals() methods so I got this class: http://www.cornetdesign.com/files/BeanTestCase.java.txt
I altered it a bit as it wasn't handling standard classes only primitives.
Anyway, I got to the point to include my own custom classes.
I have to create a 'mock' object for my class properties, e.g. field.getType().newInstance()
Fine, but there are some tricky instances. E.g. when I'd like to create an instance of java.net.URL which takes a URL as String in the constructor.
This is almost impossible to automate as it has to be a valid URL format not just a random String.
So, I thought I set them to null, e.g.
assertTrue(o1.equals(o2))
as both properties are null.
Is this the right approach you think?
I welcome any suggestions.
My initial idea was to save enormous amount of time automating the hashCode() and equals() method tests as they took so long to write.
ThanksTrouble would be that you are only testing the null branch of the equals or hashCode, which typically have to check for null, then if not null do an actual comparison.
It's worth the effort of learning to use a package such as EasyMock to create and program mock objects. It's tidiier if you are progamming to interfaces, however, but it will mock ordinary objects, though probably not if they are final.
What you could do is to define a factory interface, and have a table of anonymous classes wich generate various types. In effect create a library of dumy object factories.
Something like:
private interface DummyGenerator {
Object generate(int idx);
Class<?> getType();
private final static DummyGenerator[] generatorsTable {
new DummyGenerator() {
public Object generate(int idx) {
return new URL("http://nowhere.com/" + idx);
public Class<?> getType() { return URL.class; }
.. generators for other classes
private final static Map<Class<?>, DummyGenerator> genMap = new HashMap<Class<?>, DummyGenerator>(generatiorsTable.length);
static {
for(DummyGenerator gen : generatorsTable)
genMap.put(gen.getType(), gen);
} -
Need help calling and looping custom classes
Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
L6:
public class lab6
public static void main(String[] args)
Foreign camount = new Foreign();
camount = new Foreign();
camount.get();
camount.print();
camount.intake();
camount.convert();
camount.vertprint();
System.out.println(camount);
Foreign:
import java.util.Scanner;
public class Foreign
private String country;
private int choice;
private float dollars;
private float conversionValue;
private float conversionAmount;
public Foreign()
country = "null";
choice = 0;
dollars = 0;
conversionValue = 0;
conversionAmount = 0;
public void get()
Scanner Keyboard = new Scanner(System.in);
System.out.println("Foreign Exchange\n\n");
System.out.println("1 = U.S. to Canada");
System.out.println("2 = U.S. to Mexico");
System.out.println("3 = U.S. to Japan");
System.out.println("4 = U.S. to Euro");
System.out.println("0 = Quit");
System.out.print("\nEnter your choice: ");
choice = Keyboard.nextInt();
public void print()
System.out.print("\nYou chose " + choice);
public void intake()
Scanner Keyboard = new Scanner(System.in);
if (choice >= 1 && choice <= 4)
switch (choice)
case 1: System.out.println("\nU.S. to Canada");
conversionValue = 1.1225f;
country = ("Canadian Dollars");
break;
case 2: System.out.println("\nU.S. to Mexico");
conversionValue = 10.9685f;
country = ("Mexican Pesos");
break;
case 3: System.out.println("\nU.S. to Japan");
conversionValue = 118.47f;
country = ("Japanese Yen");
break;
case 4: System.out.println("\nU.S. to Euro");
conversionValue = 0.736377f;
country = ("European Union Euros");
break;
System.out.print("\nEnter U.S. dollar amount: ");
dollars = Keyboard.nextFloat();
public void convert()
conversionAmount = conversionValue * dollars;
public void vertprint()
System.out.println("\nCountry = " + country);
System.out.println("Rate = " + conversionValue);
System.out.println("Dollars = " + dollars);
System.out.println("Value = " + conversionAmount);
public String toString()
String line;
line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
return line;
I appreciate any help anyone can give me. This is driving me crazy. Thanks.1. first you need to write method to get choice value from Foreign class.
simply add this method.
public class Foreign {
// ... Add this
public int getChoice() {
return choice;
}2. Then in your main, you can obtain with previos method.
public static void main(String[] args) {
Foreign camount = new Foreign();
// remove this. you alredy create an instance in last statement.
//camount = new Foreign();
int choice = 0;
do {
camount.get();
choice = camount.getChoice();
// your process...
} while (choice != 0);
} -
Xcode 6.1.1 Custom Class Outlets Missing
I'm running through the basic Apple tutorial on iOS App Development https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapi OS/index.html#//apple_ref/doc/uid/TP40011343-CH2-SW1
Running Xcode Version 6.1.1 (6A2008a)
After creating custom View Controller and TableView Controller classes (Tutorial:Storyboards) I find that although the .m files appear in Build Phases they do not appear in the drop down menu for custom class. If I enter the name manually it correctly opens the .h files when clicking on the right arrow to the right of the custom name.
The standard outlets of View Controller (Search Display Controller & View), do not appear in the connections inspector of the custom class.
A test IBAction method does not appear as an option when connecting a Bar Button Item to the Exit object of the Custom View Controller.
Searching the internet for a solution I can find lots of similar stories with random work arounds, none of which have worked for me. However, most of these have been for previous versions of Xcode and one user reported that upgrading to 6.1 solved the problem.
I have redone this a few time to ensure that it isn't finger trouble and I do have a number of years of cocoa/Xcode experience, I'm just getting used to storyboards.
I have tried:
Clean project / Delete Derived Data / Relaunch Xcode
Delete references to .h & .m files of custom classes and then added them back in.
Is there any way of 'forcing' Xcode to recheck for Outlets and Actions in custom classes?To find out where th problem is, either Xcode or something in your environment, you should try to run Xcode as a different user.
The guest account is ideal for this as your are sure you will get a clean environment. You could also make a new user account and try running from there. If Xcode starts then the problem is something in your original user environment. If Xcode fails to stsrt with the new account then there is a system wide problem.
BTW is your account an admin account or a regular account?
regards -
Capture Customer Class in time of BP creation from Screen
Hi All,
I am facing a problem that I need to capture Customer Class , Sales Area Template and ID type in time of BP creation in DCHCK event. I have to check if user is putting these value correctly or not. If user entered wrong value then I have to through error message and not to save to BP.
Foe example I am using 'BUP_BUPA_BUT000_GET' to get all other data along with BP type and so on.
Plesae help regarding this if any one is aware of it.
Thanks & Regards
AjoyHi,
asaha... I want to know how it would be done ?
by ABAP customization or in the CRM IMG itself ?
can you brief about it ..
Thanks
" RA " -
Parsing XML in a Custom Class Problem
Hi, I am trying to parse an XML file from a class within my web app. It isn't a servlet, just a custom class to parse the xml.
However, I keep getting a null document printed when I try to print the document to the log file. This is the class:public class XMLParser
Document document;
public XMLParser()
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
try
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new File("SiteDescriptor.xml"));
catch(SAXException sxe)
// Error generated during parsing
Exception x = sxe;
if(sxe.getException() != null)
x = sxe.getException();
x.printStackTrace();
catch(ParserConfigurationException pce)
pce.printStackTrace();
catch(IOException ioe)
ioe.printStackTrace();
System.out.println("\n\n\n\n\n\n\n"+document+"\n\n\n\n\n");
}I know this code works as I use the exactly the same code in another application with the same XML file.
This is the XML file:
<root host="http://localhost:8080">
<branch name="Home Page" shortname="/" type="Home Page" instanceid="44987" typeid="1227">
<branch name="Films Archive" shortname="/films" type="Branch" instanceid="96354" typeid="1778">
<leaf name="Evil Dead" shortname="/films/evil_dead" type="Films" instanceid="58985" typeid="1147"/>
<leaf name="1984" shortname="/films/1984" type="Films" instanceid="49741" typeid="1147" />
</branch>
</branch
</root>And this is what I get when i print the document to the log file:
[#document: null]
Does anyone know why I cant get the class to read the document? I'm not getting any file not found exceptions or any other errors in the log.
Cheers,
PaulHi duffymo, I have tried as you suggested. I created a ServletContextListener implementation and in my web.xml file I have defined the XML file as a <context-param> and I have also defined the listener.
The ServletContextListener implementation creates the XML file as a resource using getResourceAsStream() and passes the InputStream to my parser. However, the parser still doesn't seem to work and prints out a null document in the log file: [#document: null]. Any ideas??
The web.xml file:
<context-param>
<param-name>siteDescriptor</param-name>
<param-value>/WEB-INF/SiteDescriptor.xml</param-value>
</context-param>
<listener>
<listener-class>cms.beans.InitializeXML</listener-class>
</listener>
......and the ServletContextListener is:
public class InitializeXML implements ServletContextListener
static InputStream in = null;
public void contextInitialized(ServletContextEvent sce)
ServletContext context = sce.getServletContext();
String siteDescriptor = context.getInitParameter("siteDescriptor");
try
in = context.getResourceAsStream(siteDescriptor);
catch(Exception e)
context.log("Error creating xml resource: " + e);
public void contextDestroyed(ServletContextEvent sce)
public static InputStream getXMLResource()
return in;
}Thanks,
Paul -
A Custom Class says my class is Null
Hi,
I have a class (Math2) with misc functions for my project. It
has a function called CheckRelations() which basically checks a
static array in another class (relation). But the Math2 class acts
as if the Relation class is non-existent, even though I have
imported it and I also have all files in the same folder. When I
try to relate to the class in any way i get a Runtime-Error 1009
(Cannot access a property or method of a null object reference.)
I tried tracing the class along with two other classes (one
imported, but another is not) the two classes trace fine: [class
Human] [class relationship]. The Relation class when traced in the
Math2 class results in a 'null'
Code for the CheckRelations function in math2 class: (takes
in String value, and returns the index at which the input =
relation.Type ( i.e. if (String_Input == Relation.Relations
.Type) --> return i ) Return -1 if not found)
import Human;
import Relation; //notice that Relationship is not imported
yet traces out fine
//......REST OF CLASS (other static functions
public static function
CheckRelations(relationType:String):int {
///////Variables
trace(Human,Relation,Relationship); //Human and Relationship
are classes I used to test problem
//Output: [class Human] null [class Relationship]
var relationType:String;
//relationType: the relation to look for in the relations
array
var array:Array = Relation.Relations; //Relations is a
public static var (array)
//array: the array to look inside
var relation:Relation;
//relation: used to hold temp values of relations to compare
var ReturnValue:int = -1;
//ReturnValue: the value to return
var i:uint;
//i: used in for..loops
///////Function
//SOURCE OF ERROR: any reference to Relation class
RelationCheck:for (i = 0; i < array.length; i++) {
relation = array as Relation;
if (relation.Type == relationType) { //relation.Type is a
string value
ReturnValue = i;
break RelationCheck;
return ReturnValue;
Code for getRelation function in Relation class:
public static function getRelation(relation:String):Relation
var val:int = Math2.CheckRelations(relation); // SOURCE OF
ERROR
if (val == -1) {
GameError.InvalidRelation(relation); //throws error when an
invalid relation is specified {this is NOT the problem I'm having}
}return Relations[relation];
------------------------------------------------------------------------------------------ ---------------------------------------------------------OK, I believe I have got the problem. When I tried to call
the Relation class from another class, I couldn't do that before I
cut any references to the Math2 class. So i ported the
checkRelations function into the Relation class itself in order to
cut any reference to the Math2 class. But to my surprise, when I
did that, I could trace out the Relation class normally from not
only another class, but the Math2 class itself! So after a long
time fiddling with the program I figured out that the reason Math2
was unable to relate to the Relation class was because the Relation
class was still not fully initiated. And since Relation class used
the Math2 class as part of the initiation, and the Math2 class
needed to use the Relation class itself in order to initiate the
Relation class there was practically no existence of the Relation
class as it was still in the initialization process (if that makes
any sense). So instead i called the defineRelations function in my
main fla file, to make sure the Relation class is all set before
hand, and it worked like a charm.
Anyways, thanks a lot Jamesabth
for taking the time to look at my code and help me
out, it was your advice that lead me to this discovery after all .
And also thanks to anyone who has took the time to look through my
problem even though they may have not been able to help me with
it.
Maybe you are looking for
-
PLEASE HELP ME WITH DM PROBLEM
Hi Guys, I kindly ask for your help with regards to my DM project. As you might recall, I am working on a project that is related to the field of agriculture and that has as an objective to find the "optimal values" of the operating conditions that a
-
ITunes Podcasts Stopped Updating With Upgrade
Hi, I posted this once before but I've just read on some other posts that .dll files are the problem with some other issues. Is it possible I have a corrupted .dll file that is not letting podcasts update? I've tried uninstalling, re-installing and e
-
Delivery Date And Reference Field
Hi All, SAP Business One 2007A PL 30. I just want to know if it is possible whilst in a Sales Order whether the delivery date can by default come in as the same date as the posting date. I know it is simple enough to press a key and then tab but jus
-
Can't get rid of annoying gray strip in Safari
There is a wide gray vertical strip containing bookmarks and reading list along the left side of my safari that I cannot seem to get rid of. I click on the eyelgasses, I click on the bookmarks but there doesn't appear to be a way to X out of it. He
-
Solution: Apache2 personal web sharing 403 Forbidden error
Many people are puzzled about Apache 2 throwing 403 Forbidden errors when accessing the user's personal website, although the computer website works. And a lot of incorrect solutions are floating around. I decided to post some info that hopefully wil