Results 1 to 2 of 2

Thread: Problem facing in displaying message

  1. #1

    Default Problem facing in displaying message

    Hi All,
    I have got one entry page.
    In the Controller class I have one onSubmit() method, from where I am able to insert the values into the database.
    The insert method is as follows:
    Code:
    int status = memberJdbc.insert(empNo,empName,designation, projectManagerId,clusterManagerId,location,psaGrade,projectName);
    In the above code the method returns 1 on success.

    Here I want to display success message on the JSP page when the values are successfully inserted and failure message on failure.

    Please guide me in this regard

    Thanks and regard
    Sasikanth
    Regards,
    Sasikanth

  2. #2
    Join Date
    Aug 2004
    Posts
    123

    Default

    I take it you're using a SimpleFormController or similar. The onSubmit method returns a ModelAndView. What you need to do is to add the result you want to show as an object to the ModelAndView. So, you might decide to set a Boolean variable called 'succeeded' to True or False depending on how the insert went.

    Code:
    int status = memberJdbc.insert(empNo,empName,designation, projectManagerId,clusterManagerId,location,psaGrade,projectName);
    boolean ok=(status==1);
    //Your ModelAndView object...
    modelAndView.addObject("succeeded",new Boolean(ok));
    Your JSP which displays the result can then use the variable 'succeeded' to decide what to display. (You could, of course, use a String or other variable instead of a Boolean, it's just a means of passing information into your view).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •