File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts action class call from java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts action class call from java script" Watch "Struts action class call from java script" New topic
Author

Struts action class call from java script

jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Hi,

I am trying to call javascipt function to for the pop up to confirm to delet or not basically delete link is there and then need to call action class from java script.

Can anyone give me advice?

Thanks,
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Use Ajax if you don't want the page to be submitted otherwise you can also submit a form using javascript...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 507
Hello,
May be you can use Confirm dialog box that JavaScript provides to know user response like "Ok" or "Cancel".

Please see this link.


Of course if you still need to open a new browser window and then use some action to display "Ok, Cancel" buttons, you can do that using window.open() and passing the correct action URL as parameter. But unless specifically needed that would be too much for this kind of scenario.

Regards,
Amit

jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Hi,

Thanks for your reply.

When we click ok on pop up after that we need call the action.

Could you please give me the solution for this?

Thanks,
Bachi
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Dummu Bachi please check your private messages for some administrative matter...
Rishi Kanth
Ranch Hand

Joined: May 23, 2006
Posts: 43
You can use the Struts URL tag.


then use the



jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Hi,

Sorry to ask you like this where can I find struts url tag?

I am new to struts that is why I am asking like this.

Thanks,
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What do you mean by "where can I find it"?

Which version of Struts are you using?
jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
I am using struts 1.2.

"where can I find it"?
I mean the uri to include in the JSP page.
jaisai vijay
Ranch Hand

Joined: Dec 17, 2009
Posts: 70
Hi All,

Thanks for your help. I am doing in the following way

function delete(num){

val confirmMessage = confirm("Do you want to delete ?");
if(confirmMessage){
document.form[0].action="/projectName/action.do?do=methodName&id="+num;
document.form[0].submi();
}
}

onclick="javascript:delete(1)"

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts action class call from java script
 
Similar Threads
call javascript function from java class
Invoking java class from Javascript
Action in Action
Calling Action Class by using javaScript in Struts 2
displaytag question