• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AJAX code in j2ME applictaion

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I want to develop a simple project in j2ME which should have AJAX functionality, web services, and a rich interface.

Kindly help me on whether AJAX is possible in J2ME applications without using any external or third-party API. If yes, provide me some small snippets for trying.

Also, suggest me an application which can be built using AJAX, web services and user interface in J2ME. Should a SMS facility can also be included in the application.

Thanks.
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No AJAX isn't possible because you don't have html, css or Javascript in Java ME.

Well actually it's possible to call up a server using javax.microedition.io.Connector to return a Connection, HttpConnection or HttpsConnection, among others.

Then you just need to rewrite the AJAX XMLHttpRequest to send a request using Java's Connection : HTTPConnection/HTTPSConnection instead. Methods GET and Post are supported by HTTPConnection, the url is of course supported, and you can use a Thread/Runnable combo for async=true).

Java ME can also process XML using the SAX parser from SAXParserFactory (javax.xml.parsers) In JSR 172. So that takes care of the response part. But, with SAX you need to do your own work overwriting the methods of the DefaultHandler class.

Java ME can do SMS.
 
Priyanka Gawada
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.
Call up server is fine, still Javascript will be required to send asynchronous call. So, may be AJAX is still not possible on J2ME.
I heard about Java ME. But not understood what it is clearly?
Do you have any idea regarding this?
 
Walter Gabrielsen Iii
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as graphics, you get the things in javax.microedition.lcdui and javax.microedition.lcdui.game packages.

That means the screen graphics forms:
Alert,
Form (and its associated items: ChoiceGroup, CustomItem, DateField, Gauge, ImageItem, Spacer, StringItem, TextField),
List,
TextBox
Or make your own screens with Canvas, or GameCanvas and their assosiated paint() method and Graphics object.
 
Walter Gabrielsen Iii
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need Javascript for asynchronous tasks because you've got Java! To be more specific asynchronous (done at the same time) tasks are done in Java using Threads.

In Java ME you have the following options:

1. run() method and Thread Object:
java.lang.Runnable -- the run() method a class needs to implement to run its run() asynchronously.
java.lang.Thread -- the object that you need to "start()" the Runnable task in its own thread of execution(asynchronous task).

2. Timer, TimerTask
java.util.TimerTask -- this is like Runnable but for tasks that can be scheduled with a time setting.
java.util.Timer -- this is like Thread but with time scheduling instead of starting things right away.


Also if you learn about methods Object.wait(), Object.notify(), Thread.interrupt(), Timer.cancel(), and the synchronized block features of Java then you can extend the lifetime of your threads, and have them wait in the background not wasting resources until something happens.
 
Walter Gabrielsen Iii
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is Java ME? Java ME is the mobile edition (ME) of the Java programing language. Java is an object-oriented, platform independent --so you don't need a specific Operating System or computer platform to run it-- language for programmers who want their programs to run on many different platforms without needing to recompile their program for each one.
 
reply
    Bookmark Topic Watch Topic
  • New Topic