(Quick Reference)

withMVCGroup(*)

Purpose

Create a new MVC group instance, then discard it once it is no longer of use.

Examples

Groovy

class SampleController {
    def action = { evt = null ->
        withMVCGroup('Other') { m, v, c ->
            // configure the group
        }
    }
}

Java

import griffon.core.*;
import org.codehaus.griffon.runtime.core.AbstractGriffonController;

public class SampleController extends AbstractGriffonController { void action() { withMVCGroup("Other", new MVCClosure<OtherModel, OtherView, OtherController>() { public void call(OtherModel m, OtherView v, OtherController c) { // configure the group } }); } }

Description

This method lets you create new instances of a MVC group that is short lived, for example one that creates a dialog. There are several ways to invoke this method depending on your needs

  • withMVCGroup(String groupType, Closure handler) - creates a new group identified by <groupType> with default settings.
  • withMVCGroup(String groupType, String groupName, Closure handler) - creates a new group identified by <groupType> with default settings and an specific <groupName>. You can reference the whole group by accessing app.groups.<groupName>.
  • withMVCGroup(String groupType, Map params, Closure handler) - creates a new group identified by <groupType> with additional params. The params argument will be fed as the args value of mvcGroupInit().
  • withMVCGroup(String groupType, String groupName, Map params, Closure handler) - a combination of all previous definitions.

The following methods work exactly the same as the previous ones but these provide better integration with Java based artifacts

  • withMVCGroup(String groupType, MVCClosure<M, V, C> handler) - creates a new group identified by <groupType> with default settings.
  • withMVCGroup(String groupType, String groupName, MVCClosure<M, V, C> handler) - creates a new group identified by <groupType> with default settings and an specific <groupName>. You can reference the whole group by accessing app.groups.<groupName>.
  • withMVCGroup(String groupType, Map params, MVCClosure<M, V, C> handler) - creates a new group identified by <groupType> with additional params. The params argument will be fed as the args value of mvcGroupInit().
  • withMVCGroup(String groupType, String groupName, Map params, MVCClosure<M, V, C> handler) - a combination of all previous definitions.

Fired Events:

  • NewInstance - for each member of the MVC group that had to be instantiated
  • InitializeMVCGroup - before each group member is initialized
  • CreateMVCGroup - after the group has been created
  • DestroyMVCGroup - after the group has been destroyed