0 Replies Latest reply on May 23, 2018 1:02 AM by JANGA ANUHYA

    In Grails Application Data insertion problem

    JANGA ANUHYA Newbie

      I am fresher,i am in training stage ...I have created one simple project by using Grails application in this i have some problem with data insertion, everything was creating but the problem is in success page,values are not inserting into database and not redirecting into success page .... could you  please @help me out with this problem

      Here is my code ......

      Domain class :

      package Test

      class Anu {

      String Name

      String CollegeName

      String Address

      String MobileNo

          static constraints = {

          }

      }

       

      Controller class:

      package Test

       

       

      class AnuController {

       

       

          def index() { }

      def display(){

      render view:"anu//index.gsp", model:[anu:Anu.getAll()]

      }

      def registration()

      {

      log.info("Anu Controller registration action")

      def responseData=new HashMap<>()

      def result,url

      url="/anu/registration.gsp"

      [anu:responseData]

       

      }

      def saveregister() {

      log.info("Anu Controller registration action")

      def responseData=new HashMap<>()

      def result,url

      url="/anu/Success.gsp"

      def mode=params.mode

      def Name=params.Name

      log.info(Name)

      [anu:responseData]

       

      }

       

      }

       

      View code:

      index.jsp:

      <html>

      <head>

      <style>

      body

      {

      background-color: lightgreen;

      }

      ul {

          list-style-type: none;

          margin: 0;

          padding: 0;

          overflow: hidden;

          background-color: #333;

      }

       

       

      li {

          float: left;

      }

       

       

      li a {

          display: inline-block;

          color: white;

          text-align: center;

          padding: 14px 16px;

          text-decoration: none;

      }

       

       

      li a:hover {

          background-color: #111;

      }

      .active {

          background-color: #4CAF50;

      }

      .active {

          background-color: green;

      }

      </style>

      <title>Student Registration</title>

      </head>

       

       

      <body>

      <ul>

             <li><g:link controller="Anu" action="registration" class="active">Registration</g:link></li>

      </li>

          </ul>

            

      </body>

      </html>

       

      Registration.jsp:

      <html>

      <head>

      <script type="text/javascript" src="validate.js"></script>

      </head>

      <body>

      <form action="#" name="StudentRegistration" onsubmit="return(validate());">

       

       

      <table cellpadding="2" width="20%" bgcolor="green" align="center"

      cellspacing="2">

       

       

      <tr>

      <td colspan=2>

      <center><font size=4><b>Registration Form</b></font></center>

      </td>

      </tr>

       

       

      <tr>

      <td>Name</td>

      <td><input type=text name=textname id="textname" size="30"></td>

      </tr>

       

       

       

       

      </tr>

      <tr>

      <td>CollegeName</td>

      <td><input type="text" name="college" id="collegename" size="30"></td>

      </tr>

       

       

      <tr>

      <td>Address</td>

      <td><input type="text" name="address" id="address" size="30"></td>

      </tr>

       

       

      <tr>

      <td>MobileNo</td>

      <td><input type="text" name="mobileno" id="mobileno" size="30"></td>

      </tr>

       

       

       

       

      <tr>

      <td>

      <g:submitButton name="Login" class="save" value="Login" />

      </td>

      </div>

      </tr>

      </table>

      </form>

      </body>

      </html>

       

      Datasource.groovy:

      dataSource {

      pooled = true

      driverClassName = "com.mysql.jdbc.Driver"

      dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"

      }

      hibernate {

      cache.use_second_level_cache = true

      cache.use_query_cache = true

      cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'

      }

      // environment specific settings

      environments {

      development {

      dataSource {

      dbCreate = "create" // one of 'create', 'create-drop','update'

      url = "jdbc:mysql://localhost:3306/ecog"

      username = "root"

      password = "ecg123"

      }

      hibernate {

      show_sql = true

      }

      }

      test {

      dataSource {

      dbCreate = "create" // one of 'create', 'create-drop','update'

      url = "jdbc:mysql://localhost:3306/ecog"

      username = "root"

      password = "ecg123"

      }

      }

      production {

      dataSource {

      dbCreate = "create"

      url = "jdbc:mysql://localhost:3306/ecog"

      username = "root"

      password = "ecg123"

      }

      }

      }