Graal Ne peut pas obtenir la propriété " id " sur l'objet null

Je suis nouveau sur le graal et j'obtiens cette erreur: Impossible d'obtenir la propriété " id " sur l'objet null
Je suis en train de créer une application web qui affiche des montages en plus de l'ajout de nouveaux appareils. Cependant, lors de l'exécution de l'application que je suis incapable d'ajouter des accessoires ou de l'affichage de la page qui traite avec l'ajout de luminaires j'.e ajouter.spg. Ici sont les classes qui sont actuellement disponibles dans mon application.

Voici mon simple Luminaire domaine classe:

package cricketfixturesgrailsapp

class Fixture {
   Date date
   String venue




 //hasMany  = [scores:Scores]

 static hasMany = [team:Team]

static constraints = {
}
}

voici mon installation de contrôleur de classe:

package cricketfixturesgrailsapp

class FixtureController {

 //def index() { }
    def FixtureService


    def add() {
        if (request.method == 'GET') {
            [fixtureBean: new Fixture()]
        }
        else {
            def fixture = FixtureService.createFixture(params.fixture?.date, params.fixture?.venue)
            if (!fixture.hasErrors()) {
                redirect action: 'show', id: fixture.id
                return
            }

            [fixtureBean: fixture]
        }
    }

  def show() {
        def fixture = Fixture.get(params.id)
        if (fixture) {
            [fixtureBean: fixture]
        }

    }
            def find() {
        if (request.method == 'POST') {
            def fixtures = Fixture.findAllByDate(params.date)
            if (fixtures) {
                if (fixtures.size() > 1) {
                    render view: 'selection', model: [fixtures: fixtures]
                }
                else {
                    redirect action: 'show', id: fixtures[0].id
                }
            }
            else {
                [message: 'fixtures.not.found']
            }
        }
    }
}

J'ai créé un fixtureService à traiter avec la création et la mise à jour de luminaires

package cricketfixturesgrailsapp

import grails.transaction.Transactional

//@Transactional
class FixtureService {
//def serviceMethod() {

  Fixture createFixture(Date date, String venue)
    {
        def fixture = new Fixture(date: date, venue:venue)
        fixture.save()
        fixture
    }

void updateFixture(Fixture fixture,Date date, String venue)
{
    fixture.date = date
    fixture.venue = venue
    fixture.save()
}

Team createTeam(String teamName1, String teamName2, long fixtureId){

    def team = new Team(teamName1: teamName1, teamName2: teamName2, fixture: Fixture.load(fixtureId))
    team.save()
    team

}
void updateTeam(String teamName1, String teamName2, long fixtureId) {
    team.teamName1 = teamName1
    team.teamName2 = teamName2
    team.fixture = Fixture.load(fixtureId)
    team.save()
}

}

Un formfield.spg pour la forme

${label}: <span class="errors"><g:fieldError bean="${bean}" field="${field}" /></span>
<br/>
<g:textField name="${name + '.' +field}" value="${fieldValue(bean:bean, field:field)}" />

En plus, j'ai créé 3 gsp fichiers, ajouter pour ajouter un luminaire, trouver, trouve un luminaire en salle et montrer qui montre les montages, voici les 3 gsp fichiers:

Ajouter gsp

<!--
  To change this license header, choose License Headers in Project Properties.

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add fixture</title>
    </head>

    <body>
      <h2><g:if test="${!fixtureBean.id}">New </g:if>Fixture:</h2>

      <g:form action="${ fixture.id ? 'edit' : 'add'}" id="${fixtureBean?.id}">
            <table>
                <tr>
                    <th>
                        <g:render template="/common/formField"
                                  model="[name:'fixture', bean:fixtureBean, field:'date', label:'Date']" />
                    </th>
                </tr>
                <tr>
                    <th>
                        <g:render template="/common/formField"
                                  model="[name:'fixture', bean:fixtureBean, field:'venue', label:'Venue']" />
                    </th>
                </tr>

                <tr>
                    <td>
                        <p><input type="submit" value="${ fixtureBean.id ? 'Update' : 'Add'} Fixture"/></p>
                    </td>
                </tr>
            </table>
        </g:form>
    </body>
</html>

    </body>
</html>

trouver.gsp

<html>
    <head>
        <meta name="layout" content="main">
        <title>Find fixtures</title>
    </head>

    <body id="find">
        <h2>Find fixtures:</h2>

        <g:form action="find">
            <table>
                <tr>
                    <th>
                        venue
                        <br/>
                        <g:textField name="venue"/>
                    <span class="errors"><g:message code="${message}"></g:message></span>
                    </th>
                </tr>
                <tr>
                    <td><p class="submit"><input type="submit" value="Find fixtures"/></p></td>
                </tr>
            </table>
        </g:form>

        <br/>
        <g:link controller="Fixture" action="add">Add fixture</g:link></a>
    </body>
</html>

spectacle.gsp

<html>
    <head>
        <meta name="layout" content="main">
        <title>fixture Information</title>
    </head>

    <body id="show">
        <h2>fixture Information</h2>

            <table>
                <tr>
                    <th>Date</th>
                    <td><b>${fixtureBean.date} ${fixtureBean.venue}</b></td>
                </tr>

            </table>

    </body>
</html>

Aussi ma page d'accueil par défaut est l'indice.gsp, où les utilisateurs sont invités à cliquer sur un lien pour trouver des appareils qui à son tour permet à un luminaire ajouté

<!DOCTYPE html>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Sample title</title>
    </head>
    <body>
      <h2><g:message code="welcome"/></h2>

        <ul>

                        <li><g:link controller="Fixture" action="add">Find fixture</g:link></li>

        </ul>
    </body>
</html>

stacktrace

....Error 
|
2014-02-23 20:35:23,016 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver  - NullPointerException occurred when processing request: [GET] /CricketFixturesGrailsApp/fixture/add
Cannot get property 'id' on null object. Stacktrace follows:
Message: Error evaluating expression [fixture.id ? 'edit' : 'add'] on line [20]: Cannot get property 'id' on null object
Line | Method
->>   20 | doCall    in C:/apache-tomcat-7.0.50/webapps/CricketFixturesGrailsApp/grails-app/views/fixture/add.gsp
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Caused by NullPointerException: Cannot get property 'id' on null object
->>   44 | doCall    in C__apache_tomcat_7_0_50_webapps_CricketFixturesGrailsApp_grails_app_views_fixture_add_gsp$_run_closure2_closure8
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|     47 | run       in C__apache_tomcat_7_0_50_webapps_CricketFixturesGrailsApp_grails_app_views_fixture_add_gsp
|    200 | doFilter  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter  in grails.plugin.cache.web.filter.AbstractFilter
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
InformationsquelleAutor Sky | 2014-02-23