This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Doubt in using AJAX with JSP

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator

Hello Ranchers ,

I am having a JSP page with the combination of AJAX and JSON in it. In my application using ORM iBatis as the persistency Layer.

Now my doubt is that

we have a TextArea in JSP which needed to be submitted using AJAX technology .

Can i use normal JDBC with the combination of servlet for this ??

Or How can i use iBatis for this purpose ??

Any suggestions are welcome.

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Do i need to write a insert statement on to DomainObject.xml file for this purpose ?

Or

Can i use simply a normal jdbc and servlet for the insert purpose?? Will this be a good approach .


I want to know how applications use AJAX in their UI when using a ORM layer as their persistency .

 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
I don't know whether you can directly insert data into DB by calling AJAX using iBatis, But this how it should works,

JSP -> AJAX -> Servlet -> IBatis/JDBC

Does that helps?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator

Sagar ,thanks for replying . But i did not understand what you mentioned.

I can't found any example using in combination with AJAX and iBatis .

I want to know how sites do this when using iBatis/Hibernate as their ORM and AJAX as their UI.

Anybody please help.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
ORM is for data persistent layer and involved in database operation, as like JDBC.
Now it doesn't matter how you're persisting data, either using iBatis, Hibernate or simple JDBC, what matter is consistent ORM framework you're using in your web app.

so, If you're using iBatis, then call the iBatis db functions in servlet which in turn called by AJAX.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Sagar ,

Thanks for your answer.

Thats what my question is , "Is it necessary to do data persistency using consistent ORM framework what is being used in the web app.


Because if i mix the AJAX and iBatis the code will be messy as for every TextField i need to map a insert query on to the XML file.

so is this compulsary??
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
I don't know anything about iBatis, Hibernate. I only knew its a framework build upon ORM and makes developers life easy, by removing most of the JDBC stuff. Its called a next thing to do, if you're fed up with JDBC ( Correct me here )
RaviNada Kiran wrote:
Because if i mix the AJAX and iBatis the code will be messy as for every TextField i need to map a insert query on to the XML file.

If its messy, then don't do it. Its all depends upon How easy you can make it, and after all JDBC still rocks !
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks sagar,
iBatis and Hibernate are very good frameworks .Because this directly maps the java Objects to database and easy to acccess.

i am not fed up. I like iBatis for its simplicity

But my requirement is quite different now , other than persisting the Java Object (taken care by iBatis), i also need to do dynaic validation of the UI Fileds(each and every field on the onBlur) as well as inserting a TextArea field.

so i am think whether should go for cocnsistent ORM ??

I think you got my requirment
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
RaviNada Kiran wrote:i also need to do dynaic validation of the UI Fileds(each and every field on the onBlur) as well as inserting a TextArea field.

Now, this is something to do with Front end processing and nothing to do with "How you are storing values (using iBatis OR JDBC)" at backend. And if you want to validate it on server side, use javascript
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks , but i need to do a server side validation .

i am using iBatis , so the problem is .

Anybody Please help on this.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator

anybody any suggestions or example links ??
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator

Will it be a good pratice to use both JDBC programming and ORM technology in a project for different kinds of operations??


Need your responses .
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I want to know how applications use AJAX in their UI when using a ORM layer as their persistency .


There is no relationship using AJAX in an application and ORM layer as persistent mechanism. These two are used for two different things and can be easily integrated in any web application.

AJAX is used to process the request and send response asynchronously. The response can be either in XML/HTML or JSON format. (you can use any format you wish to unless you have capability to parse the response and display the end result).

In your scenario.
#1. You submit any input that is to be inserted in the DB asynchronously i.e. the page is not refreshed to a Servlet using AJAX(Prototype or any other Javascript framework or you write your own code using XMLHTTPRequest).

#2. Now the way this servlet processes the input in your case insert into DB can be done in any of the ways
1. Traditional JDBC Insert
2. IBatis SQL Mapper
3. Hibernate etc...

As you see these two things are not at all dependent on each other. If you are looking for a exactly similar example then it would be hard to find. Instead you can look at the example that shows how to implement an AJAX call from UI .
Secondly you can look at the design patterns to find out the ways you can integrate DataAccess(Using any approach) with the servlet.
Hope this helps.
Amit



 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Interesting answer.

Could you please mention any such prototype .

Could you please ellobrate or please guide me to a link how can we do the below.

"Prototype or any other Javascript framework or you write your own code using XMLHTTPRequest"
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I am talking about Javascript framework that helps you execute the AJAX requests, with most the internals handled by the framework.
Prototype is such a framework. See http://prototypejs.org/.
JQuery is one more other such framework. I have not worked with it but read about it on this forum.

Regards,
Amit
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Any Framework requires the contact of DB layer . Here the problem comes.

JQuery is nothing but JavaScrit only with extra capabilities.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
RaviNada Kiran wrote:Here the problem comes.

What problem? You haven't really made a point as to what you see as "the problem"?

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks Bear , i was expecting a reply from you.

The problem is that Each textfield on the UI should be dynamically validated (Consider for an example like a new Registration screen , already existing user name)

I am using iBatis so do i need to write a seperate select statement for every field on to the sqlmap.xml file in iBatis ??

or

should i go for normal jdbc programming??

Will it be a good approach if i use both ORM and JDBC in a Application.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
RaviNada Kiran wrote:Thanks Bear , i was expecting a reply from you.
Well, in the past you've indicated that my replies have not been welcome, so I was reluctant to participate. But this topic is meandering and needs to get some focus.

The question as to which ORM solution to use is completely independent of any issues regarding validation and the use or non-use of Ajax. They really have nothing to do with each other. This has already been pointed out.

So if your question is which ORM solution you should consider, this is not the right forum for that.

If your question is how to perform validation, that's a different question.

And which Ajax framework to use, if any, is yet another independent question.

So which is it to be?
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Report post to moderator
Bear Bibeault wrote:
If your question is how to perform validation, that's a different question.

This is my question "How to perform validation" when using AJAX and ORM Layer.



And also will it be a good approach to use both JDBC and ORM in a Application?
 
Sreejith Sasidharan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator
RaviNada Kiran, Please stop this thread, see you can follow framework if it can solve your task easily. If your requirement is will not fit into the framework or design patters you are free to break it. But here you can just go for jsp->ajax->servlet->vo/dao/business logic. If validation is the issue then you can find a solution using JavaScript where you can do a client side validation. if you want server side then you can do it in server side using servlet and ajax response. Without trying anything you will not get a solution...so try then you face issues get back, we will help you out.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Again, ORM has nothing to do with validation and Ajax. It's like asking which car you should buy in order to decide which type of breakfast taco to order.

I'm closing this topic as it has nothing to do with JSP.

If you want to pursue the JDBC vs. ORM question, please post such a question in the ORM forum.

If you want to purse the validation with Ajax question, please post in the HTML forum.

In either case, be sure that your questions are to the point.

 
    Bookmark Topic Watch Topic
  • New Topic