Java Script and S:URL in Struts2

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Java Script and S:URL in Struts2


But before calling the action deleteUser I want to use a confirmation message something like using the above java script. Which will promt to the user does he really want to delete the user and then I can call the deleteUser Struts action.

Please help me on that or suggest me how should I do it.

If possible post a sample code where somebody has done something like this.

Thanks everybody for reading this post
geek_developer
cheers everyone

Very Simple Question

I wrote the following java script code. I am not sure whether it will work or not

<script> function deleteUser(url) { var msg = confirm("Do you really want to delete the given selected user ?") if (msg) {window.location.href = site} else (null) } </script>


I have a piece of code which I wanna use

<s:url id="deleteUrl" action="deleteUser" namespace="user">
<s: param name="user.userID" value="userID" />
</s:url>
<s:a href="%{deleteUrl}">
<s:text name="Delete" />
</s:a>
Reply | Threaded
Open this post in threaded view
|

Re: Java Script and S:URL in Struts2

dynamicd
try using the preInvokeJS="confirm("Do you really want to delete the given selected user ?") "  in the <s:a tag > 
Reply | Threaded
Open this post in threaded view
|

Re: Java Script and S:URL in Struts2

geek_developer
In reply to this post by geek_developer
Thanks for your reply but that doesn't seems to be working

The error I am getting is

/pages/userList.jsp(58,59) equal symbol expected....

My code is :

       <s:url id="deleteUrl" action="deleteUser" namespace="user">
               <s: param name="user.userID" value="userID" />
       </s:url>
     
       <s:a preInvokeJS="confirm("Do you really want to delete the given selected user ?")"                
               href="%{deleteUrl}">
              <s:text name="Delete" />
        </s:a>

I am really poor in Java Script.
What am I doing wrong?