Wednesday, September 12, 2012

Enabling DropBox with PhoneGap

Hi there,
                    So as you must have guessed I am gonna try integrating my PhoneGap with dropbox and see how it works.

Well I have an idea where we can enable upload option as upload via dropbox.

I think Its cool So I am gonna Implement this.

For this recipe we will need :
  • PhoneGap development environment
  • As dropbox does not have direct Integration with PhoneGap we will use Jquerry libraries and see how It works. Documentation 
Step 1:
  • Go here and register for API key
  • I got my dropbox set up and I have API Key Test Page
  • So I will be using my API key to run code on Code
  • Download unzip the package now put package in phoneGap Folder and there you go... :)
Here is my demo

Wednesday, September 5, 2012

JNDI Lookup for Jboss Server

Usage: For production it is possible the data wil migrate from one source to another. So when It happens you dont want to recompile your app rather just change configuration file. So here it Goes

Step 1:
  • Create Appname-ds.xml file
  • Save to to path : JBOSS_HOME/server/default/deploy
  • Modify contents of Appname-ds.xml:
Filename: Appname-ds.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE datasources
    PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<datasources>
    <local-tx-datasource>
       <jndi-name>appDatasource</jndi-name>
       <use-java-context>false</use-java-context>
       <connection-url>jdbc:sqlserver:SomeConnectionString
       <driver-class>com.microsoft.sqlserver.jdbc.SQL.ServerDriver
       <user-name>SomeUser</user-name>
       <password>Somepassword</password>
    </local-tx-datasource>
</datasources>

Step2:
  •  Copy the code snippet to create statements
/**
    * @name connectdb
    * @return 1 if successful , -1 if Connection is unsuccessful 
*/
    public int connectdb()
    {
    int r =-1;
  
        Properties p = new Properties();    
        p.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
        p.put( Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces" );
        Constant.connection = null;
        Context ctx = null;
        try
        {
            ctx = new javax.naming.InitialContext( p );
            WrapperDataSource ds = (WrapperDataSource) ctx.lookup(appDatasource);
            Constant.connection = ds.getConnection();
            r=1;
        }
        catch ( Exception ex )
        {
            r= -1;
            ex.printStackTrace();
        }
        finally
        {
            if ( ctx != null )
                try {
                    ctx.close();
                } catch (NamingException e) {
                    e.printStackTrace();
                }
            System.out.println("Context Closed");
        }
        return r;
 } 
Step 3:
Rebuils your application
Clean Server : Delete Data,temp,work folder in JBOSS_HOME
Restart server
Publish

Step 4:
You are Done! :)

Solved: Flickering , Double transition problems implementing IOS on device

Everything works fine on emulator but on device on transitioning to the subpage flickers and the page is displayed once and again with effect

More clearly its shown 


After your custom CSS in main page add

<style>

     /*** patch for jquerymobile page flicker ***/
     .ui-page {

                  height: 100% !important; 
                  -webkit-backface-visibility: hidden;
               }
        .input { outline: none; }
</style>

And my HTML code snippet
<div data-role="page" id="infoPage"> 

     <div data-role="header" data-position="inline">
        <h1>My App 
        <a href="#anotherPage" data-icon="back" class="ui-btn-right" data-transition="flip">Back</a>
     </div>     
     <div data-role="content">
              Some Information 
     </div>  <!-- /Content --> 

     <div data-role="footer" data-id="foo1" data-position="fixed"> 
        <p>Some Footer</p>
     </div><!-- /footer --> 
</div><!-- /Page ends --> 

And now my Project looks like 



Still this is just a work around so issues associated are data-transition = "slide" does not work still but data-transition"slidereverse" works.
You can tryout different things listed on thread : here at some point it seem to be a very critical issue.