Announcement Announcement Module
Collapse
No announcement yet.
Problem facing in displaying message Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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).

    Comment

    Working...
    X