2013-06-04 3 views
0

데이터베이스에 저장할 때 사용자가 마스터/세부 관계를 형성 할 데이터를 입력 할 수있는 웹 페이지가 있습니다. 데이터를 명령 객체에 바인딩하는 Grails 컨트롤러에 데이터를 제출합니다. 얼마나 많은 "세부 사항"행이 제출 될지 알지 못하기 때문에 지연 목록을 사용하여 세부 정보를 바인딩하려고합니다. 나는 장관으로 실패하고있다. 내가 양식을 제출하면Grails : 지연 목록 문제

String title  
List testItems = LazyList.decorate(new ArrayList(), 
            FactoryUtils.instantiateFactory(VocabQuestion.class)); 

나는 다음과 같은 예외가 얻을 : :

| Error 2013-06-04 22:42:54,068 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [POST] /*****/vocabulary/save - parameters: 
testItems[1].question: Q2 
title: Test 
testItems[0].answer: A1 
testItems[0].question: Q1 
testItems[0].vocabulary_test_id: 
testItems[1].answer: A2 
create: Create 
No signature of method: vocabularytest.TestCreationCommand.propertyMissing() is applicable for argument types:() values: [] 
Possible solutions: propertyMissing(java.lang.String). Stacktrace follows: 
Message: No signature of method: vocabularytest.TestCreationCommand.propertyMissing() is applicable for argument types:() values: [] 
Possible solutions: propertyMissing(java.lang.String) 
    Line | Method 
->> 102 | <init> in vocabularytest.TestCreationCommand 

이 예외는 객체의 라이프 사이클 초기에 발생하는 시도를 Grails에 presumeably로

내 명령 개체 같이 보입니다 데이터를 바인딩합니다.

은 내가 나의 명령 개체를 정의하는 경우 :

String title  
List testItems = [new VocabQuestion()] 

만 양식에서 1 개 상세 기록을 제출 한 후 모든 것이 기대 작품으로.

어디로 잘못 가고 있습니까?

편집 다음과 같이

가 나중에 그루비 버전의 기본 인 LazyList 구문을 사용하는 내 VocabQuestion 도메인 클래스는 내가 대답을 발견

package vocabularytest 
class VocabQuestion { 

    static constraints = { 

    } 

    static belongsTo = [vocabularyTest: VocabularyTest] 

    String question 
    String answer 

} 
+0

'VocabQuestion' 정의를 공유 할 수 있습니까? –

답변

1

입니다 (대답하지 않을 수도 있지만, 그것은 작동) .

List testItems = [].withLazyDefault {new VocabQuestion()}