• 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

Prototype and Scriptaculous

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

AJAX uses javascript, HTML and XML for displaying data from the databases directly. Doesnt it challenges the integrity of data stored in the databases???
 
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prithiraj,

Nope, not really. Ajax is just another presentation technology. Use the same best practices and common sense to let the user do what they need to do without handing over the keys to your domain model or database. You can challenge the integrity of the DB with web services, thick clients or any old technology if you don't provide a facade of some sort.

And BTW, despitre the acronym, Ajax doesn't have to use XML.

Cheers,

Dave
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David C. Crane:


Ajax is just another presentation technology. Use the same best practices and common sense to let the user do what they need to do without handing over the keys to your domain model or database.

And BTW, despitre the acronym, Ajax doesn't have to use XML.



Hi,
Thanks for the reply.

If AJAX doesnt need Xml then how is it possible to draw data from the database and display these on the screen?

Can AJAX stand alone without depending on the serverside Technologies in case of data pulling??

I am new to AJAX technology and just started reading from the internet.
May I know how much time will it take the developers having work experience in javascript to master AJAX??

Regards

Prithiraj
[ March 28, 2007: Message edited by: Prithiraj Sen Gupta ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try and avoid returning XML if at all possible. Traversing XML in Javascript is not a fun task. And generally, creating it in Java is not fun either. My personal preference (again, when possible) is to make an ajax request to the server, the server forwards that request to a JSP which renders some nice HTML ready to be popped right into the DIV of my choice. I use prototype's Ajax.Updater for this purpose.
 
David C. Crane
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prithiraj,

I ought to have clarified. You do need to send data from the server to the client somehow. In general, there are three options:

1. send structured data and then parse it in the JS tier. XML is a common choice, but so is the JSON format, largely because, as Greg said, parsing XML in JavaScript can be a bit of a pain.

2. generate Javascript on the server and then evaluate it on the client. Watch out for tight coupling!!

3. generate HTML on the server, for a fragment of the page, and then use JS and DOM to stitch it into the main page. Prototype provides a class called Javascript Ajax.Updater that makes this very easy to do.

Each approach has it's pros and cons. In chapters 3 to 4 we run through a pretty exhaustive comparison of these, in terms of ease of use, network load, etc.


HTH

Dave
 
David C. Crane
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And to answer your other questions...

Originally posted by Prithiraj Sen Gupta:

Can AJAX stand alone without depending on the serverside Technologies in case of data pulling??


Well, at the moment, you can write JS-only apps, but they won't be able to do very much. The server is still an essential ingredient. Howeverr, 'local storage' is a buzzword - Mozilla 3.0 will implement it, for example - this will allow a browser app to store data locally while offline and sync with the server later, so that reduces the dependency on the server a little bit.


I am new to AJAX technology and just started reading from the internet.
May I know how much time will it take the developers having work experience in javascript to master AJAX??



That's a hard one to answer! If you really know Javascript, then you should be up and running before long. But Ajax opens the door to using a lot more JS than previously, and coding styles and practices are rapidly evolving to cope with larger, more complex JS codebases. Don't be discouraged, though - although there is plenty to learn, it's an incremental learning curve.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David C. Crane:
And to answer your other questions...
If you really know JavaScript, then you should be up and running before long. But Ajax opens the door to using a lot more JS than previously, and coding styles and practices are rapidly evolving to cope with larger, more complex JS codebases. Don't be discouraged, though - although there is plenty to learn, it's an incremental learning curve.


Hi Dave,
Yes, you are true If I really know JavaScript, then I should be up and running before long. Actually the truth is that I am a student of an engineering college in final semester. I have started a project on ASP.net from January 2007 in a reputed Enterprise.

Originally posted by Prithiraj Sen Gupta:
I am new to AJAX technology and just started reading from the internet.
May I know how much time will it take the developers having work experience in javascript to master AJAX??


I apologies as I have Presented my self as a developer
I am inspired by the JavaScript and its ability to work with anything present in the browser. I am trying my best to use JavaScript as far as possible to make a perfect presentation. Just a couple of weeks before I read about the Buzzword "AJAX" and the technique behind the GOOGLE suggest, Google Earth and Gmail.
Thanks for your reply.
Can you tell me the best sources to master these technologies?? I am studying these from the sites which I feel not enough to satisfy my wants.
 
David C. Crane
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prithiraj Sen Gupta:

I apologies as I have Presented my self as a developer

If you're playing/working with computers, then you're a developer in my book. Don't get too hung up on titles I started developing age 14 on a pretty simple microcomputer, and most of the time, I'm still a kid kicking the tires to see how things work.


I am inspired by the JavaScript and its ability to work with anything present in the browser. I am trying my best to use JavaScript as far as possible to make a perfect presentation. Just a couple of weeks before I read about the Buzzword "AJAX" and the technique behind the GOOGLE suggest, Google Earth and Gmail.



Satou Kurinosuke kindly pointed out on another thread today or yesterday that Appx B of ''Ajax in Action' is freely available on the web, here:

http://java.sun.com/javascript/ajaxinaction/Ajax_in_Action_ApB.html

One of the most important bits of that book IMHO! It started life in Mumbai, actually, in an attempt to quicky get across the basics of JavaSCript to a couple of very bright young Java programmers (hi Bhupendra, Pooja !). If you can understand JSON/object literals, the prototype mechanism and JS functions & closures, then you've understood JavaScript.

Beyond that, one of the best ways to get JavaScript is by experimenting. Download the sample code for the P & S book (it's free, from Manning's website http://manning.com/crane3), and have a play with the 'scratchpad' application, which will let you run Javascript interactively - useful for short experiments.

Best of luck!

Dave
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am inspired by the reply.


Thanks & Regards

Prithiraj
[ March 29, 2007: Message edited by: Prithiraj Sen Gupta ]
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I read the Readme.txt- notepad.

The code for chapters 5-7 is self-contained, each in it's own zip file. These use JSP backends - see Appendix C for setup details.

Chapters 2-4 and 12 use the QuickGallery code, which has a PHP back-end - see Appendix D for setup instructions. The title page references the various versions of the gallery by chapter.

Chapters 8-11 use the Scratchpad application, which can run either straight off the filesystem, or a web server of your choice (no server-side components to install)!



I want to know why the codes for the chapters are divided like for PHP
(5-7), JSP(2,4 and 12) backends and some are Scratchpad application(independent from particular web server). Cannot these application use any of the backends? or you divided just for the illustration purpose??
[ March 29, 2007: Message edited by: Prithiraj Sen Gupta ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well the Scratchpad is a client-only example so no server-side compenents are necessary. Other things like the QuickGallery and Scriptaculous controls, such as the in-place editors and remote auto-completers, need server components.

A mix of PHP and Java was chosen to make the book more widely useful.

Also, the Java components aren't limited to JSPs -- there are also some servlets in there. For example, the remote auto-completer uses a Java servlet that serves up Sci-Fi movie titles from a faux database.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the Clarification..

Actually I become little afraid as I am working on ASP.net,
Which is not a platform independent language. I always hoped to work in JAVA. But everything doesnt come as one desires. I dont know what should be done.
I am also helping one of my cousins to build a project in J2EE as I want to gain practical knowledge in the java field.
Should I leave .Net though I have some experience or should I start working simultaneously both in .Net and Java(Open Source projects). Again If I do both there is always the risk of becoming "the jack of all trade but master of none".


Thanks & Regards

Prithiraj
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prithiraj Sen Gupta:
Actually I become little afraid as I am working on ASP.net,



Well, with regards to the book, you shouldn't fear. The focus is most definitely on the client side of things with the server components just there as "supporting cast". You should have no trouble figuring out how you would use other server-side technologies with the client code.

With regards to caree advice... well, I'm certainly not qualified to tell you what you should do. Personally, I chose to leave the world of proprietary software long ago (I once wrote Windows software).

Perhaps a topic in the Jobs Discussion forum would benefit you?

or should I start working simultaneously both in .Net and Java(Open Source projects).



Peronally I think having extra skills under your belt never hurts!
 
David C. Crane
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In total, we do about three unusual or noteworthy things in the server code throughout the book. Appendix E describes how to accomplish those things in PHP, Java, Ruby on Rails and .NET

Dave
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This discussion was really useful and interesting to me.

I will try my best to learn both JAVA and ASP.net.(Thanks Bear).

And I will learn these client side languages soon.(Thanks Dave).

I will also kick the tires to see how thing works.

Thanks & Regards

Prithiraj
[ March 30, 2007: Message edited by: Prithiraj Sen Gupta ]
 
David C. Crane
author
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for coming to the ranch with us Prithiraj, I'm glad the discussion was useful.

And give those tires a good kick from me

Dave
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

My personal preference (again, when possible) is to make an ajax request to the server, the server forwards that request to a JSP which renders some nice HTML ready to be popped right into the DIV of my choice. I use prototype's Ajax.Updater for this purpose.


Traditionaly, I use DWR to call the logic.
May I ask how to implement Gregg's strategy (Ajax.Updater) in the context of an available Java web framework ?
I don't think it fits in Struts actions, neither in JSF, but what about WebWork (my favorite) ?
Sure, it can be implemented as a pure servlet solution, but what if I'm already invested in a framework ?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I don't think it fits in Struts actions

Your assertion is flawed. If the web framework is capable of delivering a response (duh!) it can be used with Ajax.Updater (or any other Ajax mechanism) in this manner. How does the fact that a server-side compomnent is a Struts action affect what can be returned as the response?
[ March 30, 2007: Message edited by: Bear Bibeault ]
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Your assertion is flawed. If the web framework is capable of delivering a response (duh!) it can be used with Ajax.Updater (or any other Ajax mechanism) in this manner. How does the fact that a server-side compomnent is a Struts action affect what can be returned as the response?

[ March 30, 2007: Message edited by: Bear Bibeault ]



Yea, the cool thing about it is you don't really have to change your server side code to work with this method. The server doesn't care if it is an Ajax call or not. It's just a request and it ignorantly delivers a response. It's what you do with the response that makes a difference. And in this case, it's just a partial JSP. Easy cheesy beautiful.
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, do you know ? I'm infected with how DWR works (how to provide Http servlets objects to DWR calls) :roll:
So, using Struts (or WebWork) with Prototype is as simple as :
Ajax.Updater('placeholder', 'http://domain/action.do', { .....});
Right ?
[ March 30, 2007: Message edited by: John Todd ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right. Regardless of whether the request is from Ajax or not, the server will process it exactly the same. And if the server wants to generate an HTML fragment, or an XML document, or a JSON construct, or plain text, or the complete works of Shakespeare in PDF format as its response is immaterial to how the request was made.
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I don't want to hijack the thread but, Prototype is best used with request-based frameworks (WW, Struts ..) but not with component -based frameworks (JSF, Wicket ...), I think :roll:
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF has its own set of rules. One reason you will not find me ever considering it...
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it is not JSF only, all other component-based frameworks have their roles (Tapestry, Wicket).
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Congratulations :

Arjumand Bonhomme (144466)
Eric Pascarello (22379)
Saphalya Swain (142716)
Vani D Bandargal (108621)


Hi Dave, Bear

Can I get these(Ajax in Action, Prototype and Scriptaculous in Action)

books here, in INDIAN Markets ?


Thanks & Regards

Prithiraj
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be honest, I do not know. I'd check with the publisher at manning.com.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes Please,

I have also sent them them a mail. If I got the confirmation I will purchase those books.

Thanks & Regards

Prithiraj
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is JSON superior to XML??
We use XML in ASP.net to keep the business layer independent of any platform. Does JSON Provide this facility?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's like asking if ketchup is superior to mustard. It depends what you are putting it on.

I generally find JSON easier to use than XML since it's much easier to digest on the client than XML. But there are times when the structure of XML may be necessary.

So it's impossible to say which is superior unless you are considering a particular usage. And even then, it may end up being six of one...

P.S. Next week there will be a book promo in this forum for Ajax in Practice. An example of making just this type of decision for an example application is examined in detail in chapter 13 of that book.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It is true that both ketchup and mustard is eqaully necessary depending on the kind of stuff to be taken.
XML and JSON is used for document Interchange and data interchange respectively. Moreover, the interesting
point is that JSON is a subset of JavaScript. I need some practical knowledge about JSON to
know this technology(not only theoritically but also in pragmatic sense) down to the roots(so that I can build my 1st AJAX program with JSON).

How to get JSON output through server(stringifying like XML??? but how??)?
What makes machine easy in parsing and generating JSON than XML??
Where and when should we use these formats(Ketchup/Mustard ) in our AJAX applications??

How the book AJAX IN PRACTICE will help me in building and learning Ajax applications? How the book is different from AJAX IN ACTION?

Please confirm me about the arrival of the books "Ajax in Action","Prototype and Scriptalculous in Action",
in India. A week before I have already sent a mail to manning publishers.

Thanks & Regards

Prithiraj Sen Gupta
India

[ April 10, 2007: Message edited by: Prithiraj Sen Gupta ]
[ April 10, 2007: Message edited by: Prithiraj Sen Gupta ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Prithiraj Sen Gupta:
I need some practical knowledge about JSON to
know this technology(not only theoritically but also in pragmatic sense) down to the roots(so that I can build my 1st AJAX program with JSON).



http://json.org/ is a good place to start.

How to get JSON output through server(stringifying like XML??? but how??)?



There are a number of JSON generators available. One I've played around with a little is written by Frank Carver, one of the JR staff. It can be found at: http://blog.stringtree.org/.

Also a simple JSP page with EL markup makes a pretty good "poor man's" JSON generator, though not a general solution.

What makes machine easy in parsing and generating JSON than XML??



A single call to eval();

Where and when should we use these formats(Ketchup/Mustard ) in our AJAX applications??



That's a broad question and one that's tackled in chapter 13 of Ajax in Practice where a "mashup application" is designed and implemented. We go through the steps of deciding which data format to use: plain text? HTML? JSON? or XML?

How the book AJAX IN PRACTICE will help me in building and learning Ajax applications?



That's the whole point of the book. Previous Ajax books described what Ajax is. This book is designed to show you how to use it in real-world, practical applications.

How the book is different from AJAX IN ACTION?



https://coderanch.com/t/119789/HTML-JavaScript/Difference-between-AJAX-Action-AJAX

Please confirm me about the arrival of the books "Ajax in Action","Prototype and Scriptalculous in Action", in India. A week before I have already sent a mail to manning publishers.



I'm afraid that you will need to wait for the publisher's response as that is not infomration that I am privy to.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


The e v a l function is very fast. However, it can compile and execute any JavaScript program, so there can be security issues.



The above statement is from json.org
This says e v a l() can challenge security issues.
[ April 10, 2007: Message edited by: Prithiraj Sen Gupta ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, but this doesn't really introduce any new security measures than those you should already be taking with regards to SQL and HTML injection. Never trust input from a user.
 
Prithiraj Sen Gupta
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, for that we will provide validations like -not allowing any tags and
functions used in building web application. Rather, it is better not to use this function unless there is very strong Validations. So, it is best to use only in displaying data. and JSON parser during input.

Thanks & Regards
Prithiraj Sen Gupta
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic