August 2009 Archives

XML Manipulation in Flex and ActionScript

| No Comments
There are lots of crazy ways of manipulating XML in ActionScript.Here are a few simple tips and tricks on manipulating XML in Actionscript.

  1. Declaring an XML Variable: An XML variable can be created in ActionScript as follows :
                 var tempSearchXML:XML =     <searchCriteria>
                                                                <branchName>023</branchName>
                                                                <contfirstname></contfirstname>
                                                                 <contlastname></contlastname>
                                                                 <contmailsort></contmailsort>
                                                                 <contphone></contphone>
                                                             </searchCriteria>
                                         
2.  Preview an XML Variable : An XML variable can be previewed in an Alert Box by converting the XML to a string object
       
            Alert.show(tempSearchXML.toString());
           
3.  Getting the value of a Node in the XML:

           Alert.show(tempSearchXML.branchName.toString());

4.  Setting the Value of Node in the XML : The following code sets the value of a node 'contfirstname '.
 
            tempSearchXML.contfirstname ="Armaghan";

5.  Setting / Changing / Updating the Node Attribute in the XML: The following code snippet changes the name of a Node from 'contlastname' to 'lastname'.

            tempSearchXML.contlastname.setName("lastname") ;
           
5.  Delete a Node in the XML: The following code snippet deletes a Node called 'contphone' in the XML.

            delete tempSearchXML.contphone;

6.  Adding a Node in the XML: The following code snippet adds a Node called 'text' in the XML and sets its value at the same time.

            tempSearchXML.text ="Taylor" ;

Happy Coding :)

Dump the Ant build information to a log file

| No Comments

If you ever need to dump the build information from the command prompt console into a log file, just add a -logfile <filename>.log parameter after your build file call in the command prompt console and you're good to go.

Happy Coding :)

Default Value in QueryParam Annotations

| No Comments
In order to remove any null pointer exceptions while using RestEasy Annotations, you can always pass a default value and handle it appropriately in the Data Access Objects ( If you are using one. This ensures that there are no null pointer excpetions from the returning classes.

Here is a code snippet to do just this:

public StreamingOutput getUsersSummaryList(@QueryParam("active") @DefaultValue("0") String active  ){}

PermGen space error (Hibernate, JPA)

| No Comments

If you ever come across a PerGen space error in Hibernate or JPA...it refers to the java.lang.outfspacememoryerror (Your webapp is out of memory). PermGen is  used to store the class definations ( and I do mean all the Loaded Classes ). This error refers to the heap space being full due to the large number of classes.

Generally you can recover from these errors by restarting your WebServer. If you want to really fix it, do one of the following 2:

1. Hibernate: Change the hibernate.properties file from  "hibernate.bytecode.provider javassist" to hibernate.bytecode.provider cglib".

2. JPA:  Change the persistance.xml file from
<property name="hibernate.bytecode.provider" value="javaassist"/> to <property name="hibernate.bytecode.provider" value="cglib"/>

Happy Coding :)

About this Archive

This page is an archive of entries from August 2009 listed from newest to oldest.

May 2009 is the previous archive.

September 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Categories