• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1 Toekn Processing in Ajax Request

 
Mihir K Parekh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I am Using Struts 1.3 in My Application and I have used Struts token methods in my Base Action class for creating new Record. For Example

public class BasicCreateAction extends Action{

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

if(isTokenValid(request)){
// process request
// resetToken(request);
}else{
// duplicate request simply discard it
}
}

}

in My Application all my Action classes created for Creating Record in Application extends above class and leverage its base functionality.

this works perfectly in the scenario where User explicitly submits forms. in some case the record is created via Ajax Request and not by submitting form. for example,

User wants to create a Product in to application so he presented a product page to create it.it has some fields like Product Name , Number , SKU , and Product Type. the last filed Product Type is separate entity so i have provide option to user to create it by providing Popup menu to create it , in the Popup menu there is a form to create a Product Type. when user press a button on the Popup menu this Product type is created via Ajax Request sent to the server.

so my question is how can i save token for this scenario , so i can i use it in my Action Class as exactly as i can use in previous case ?

in previous case i am saving token from subclass of DispatchAction class where all forwarding of particular page occurs.

Thank You Mihir Parekh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic