Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Alert box issue in Struts

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

I'm using Struts for Controller,i.e presentation tier.
IBatis 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........



after insert operation i want to return a value determining whether save is successful or not?? how to proceed.


how should this part be implemented in jsp i.e displaying an alert box depending on some condition.....please help me (in my case return value) ???





Deepak
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Include some sort of flag and run some JavaScript based on the value of that flag?
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David,
COuld you please help jme further....

David wrote: Include some sort of flag and run some JavaScript based on the value of that flag?



My interpretation::

I have a flag in action class.i get true or false
------------------
Action class
---------------------
boolean flag = true;
then i redirect to mapping.findforward(Save.jsp); //ok im done with this


Clarifications.::
1> how do i proceed to write the logic in jsp with javascript functionality....i mean how do i mix both javascript and checking the flag condition in jsp
2> Bsed on 1st result, when i get the alert("records saved successfully") how do i proceed to someother page "MainMenu.jsp" ,when the user clicks on "Ok" button of the alert box.




Please help me....
 
Deepak Lal
Ranch Hand
Posts: 561
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,
Could you please help me with this....any snippet of code to achieve this



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
Sorry for replying again,but could you help me on this issue
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't seem to be too difficult to implement. I can't figure out which version of Struts you are using so I'm assuming Struts 2. From SaveAction, you need a way to pass a flag to the JSP indicating whether the insert operation was successful or not. You can do this simply by having a property in SaveAction action. In the JSP, use s:if and s:else tags to generate an alert box depending on whether the insert was successful. Then you can use the window.location in javascript to redirect the user to MainMenu.jsp (example). So Save.jsp would look something like this
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you having difficulty with? All you need to do is put the JavaScript code in the JSP and use JSP EL to decide which alert box to show.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic