• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ibatis with Struts Question

 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I'm using Struts for Controller,i.e presentation tier.
IBtais as a Persistence Framework .

Action class --> Service class --> Ibatis .xml file --> Database(SQL Sever 2000)

I have implemented a Save operation In Service class which inserts a record in database.
When the record is successfully inserted into database.I want to show a Dialog box i.e an alert box saying
"Records are Saved Successfully" else an alert box "Save Operation Unsuccessful",in case records are not saved.

How do i implement this feature in Struts along with Ibatis Framework Integration
Please help........




 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Lal wrote:Hi All,
I'm using Struts for Controller,i.e presentation tier.
IBtais as a Persistence Framework .

Action class --> Service class --> Ibatis .xml file --> Database(SQL Sever 2000)

I have implemented a Save operation In Service class which inserts a record in database.
When the record is successfully inserted into database.I want to show a Dialog box i.e an alert box saying
"Records are Saved Successfully" else an alert box "Save Operation Unsuccessful",in case records are not saved.

How do i implement this feature in Struts along with Ibatis Framework Integration
Please help........






Well first I would say, keep database interaction in a DAO/Repository and not in a Use Case Service class. The DAO/Repository layer is right after the Service layer.

Also, what you want done doesn't matter if it is Struts, iBatis, Hibernate, Spring MVC.
It is just about return value or throw exception. Standard Java. If you are unsuccessful, throw an exception and catch it in the UI layer. If no exception, then return a boolean, or the object itself back and if it get a return value, then you know it is successful. Again on the UI end of things.

Hope that steers you in the right direction. The main thing is this functionality is not the responsibility of Struts or iBatis, so there isn't anything special in them that will give you your solution. It is all dependent on your and your api/design.

Thanks

Mark
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark Spritzler and other moderators,

My Queries are like below:

In Ibatis layer i have something like below.




1> Could you please tell me how to know if the record is successfully inserted in the above scenario ?
2> In case of success, how should i handle in Struts ?
3> In case of failure,how should i handle in Struts ?

I will be thankful to you if you code modify the code snippet which i have pasted and help me further.



Thanks and Regards,
Deepak Lal
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me how should i determine the return value of

once i get a count of records inserted.i want to proceed further.
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Ranchers,
Im stuck with this issue.Please help me with this...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic