1

私は2つのドメインを持っています:

class A {
 String name
 B b
}

class B {
 String code
}

デフォルトの足場を使用します。A リスト ビューに移動すると、B インスタンスがないため、A インスタンスを作成できません。gspはこちら

<g:if test="${B?.list()}">
</g:if>
<g:else>
    <g:link class="create" action="create" controller="b">
        <g:message code="default.new.label" args="['b']" />
    </g:link>
</g:else>

B の作成リンクをクリックすると、B インスタンスを作成できますが、作成中の A オブジェクトへの「接続」が失われます。このシナリオでユーザーをサポートする良い方法はありますか? アイデアは、モーダル ボックスで create B リンクを開くことでしょうか?

4

1 に答える 1

0

Just add the ID of the A to params:

<g:link class="create" action="create" controller="b" params="[ 'a.id': aInstance.id ]">

The key just adapt to the relation attribute in the domain class B.

于 2012-09-04T10:03:22.837 に答える