private void createAutobindings(List<FieldBindingInfo> bindings, boolean full) throws Exception {
   BeanObserveInfo beanObserveObject = null;
   if (full) {
     if (m_gridSelectionModel == null) {
       if (m_model instanceof BeanObserveInfo) {
         beanObserveObject = (BeanObserveInfo) m_model;
       }
     } else {
       beanObserveObject = m_gridSelectionModel;
     }
   }
   WidgetObserveInfo formPanel = (WidgetObserveInfo) m_target;
   for (WidgetObserveInfo field : formPanel.getChildren()) {
     Property property = field.getJavaInfo().getPropertyByTitle("name");
     if (property != null) {
       Object nameValue = property.getValue();
       if (nameValue instanceof String && !StringUtils.isEmpty(nameValue.toString())) {
         FieldBindingInfo binding =
             field.createFieldBinding(field.getSelfProperty(), "\"" + nameValue.toString() + "\"");
         if (full) {
           if (beanObserveObject == null) {
             binding.setModel(m_model, null);
           } else {
             binding.setModel(
                 beanObserveObject,
                 beanObserveObject.resolvePropertyReference(binding.getParsedProperty(), null));
           }
         }
         binding.setAutobind(true);
         binding.setParentBinding(this);
         bindings.add(binding);
       }
     }
   }
 }
 private void finishBinding(
     Expression grid, Expression bindingElement, IDatabindingsProvider iprovider)
     throws Exception {
   DatabindingsProvider provider = DatabindingsProvider.cast(iprovider);
   BeansObserveTypeContainer beansContainer = provider.getBeansContainer();
   WidgetsObserveTypeContainer widgetsContainer = provider.getWidgetsContainer();
   //
   WidgetObserveInfo gridWidget = widgetsContainer.getBindableWidget(grid);
   m_model = gridWidget;
   m_modelProperty = gridWidget.getSelfProperty();
   //
   ClassLoader classLoader = CoreUtils.classLoader(provider.getJavaInfoRoot());
   String bindingElementClassName = AstNodeUtils.getFullyQualifiedName(bindingElement, true);
   Class<?> bindingElementClass = classLoader.loadClass(bindingElementClassName);
   //
   m_gridSelectionModel =
       new BeanObserveInfo(beansContainer.getBeanSupport(), m_modelProperty, bindingElementClass);
   gridWidget
       .getSelfProperty()
       .setProperties(
           m_gridSelectionModel.getChildren(ChildrenContext.ChildrenForPropertiesTable));
   //
   for (FieldBindingInfo binding : m_fieldBindings) {
     binding.setModel(
         m_model,
         m_gridSelectionModel.resolvePropertyReference(binding.getParsedProperty(), null));
     binding.setGridSelectionModel(m_gridSelectionModel);
   }
   //
   int index = provider.getBindings().indexOf(this);
   provider.getBindings().addAll(index + 1, m_fieldBindings);
   //
   if (m_autobind) {
     createAutobindings(m_fieldBindings, true);
   }
 }
 ////////////////////////////////////////////////////////////////////////////
 //
 // Code generation
 //
 ////////////////////////////////////////////////////////////////////////////
 @Override
 public void addSourceCode(List<String> lines, CodeGenerationSupport generationSupport)
     throws Exception {
   String variable = getVariableIdentifier();
   if (variable == null) {
     variable = generationSupport.generateLocalName("formBinding");
     setVariableIdentifier(variable);
   }
   //
   String startPrefix = m_gridSelectionModel != null ? "final " : "";
   //
   String startCode =
       isField() ? "" : startPrefix + "com.extjs.gxt.ui.client.binding.FormBinding ";
   lines.add(
       startCode
           + variable
           + " = new com.extjs.gxt.ui.client.binding.FormBinding("
           + m_target.getReference()
           + ");");
   //
   if (!m_fieldBindings.isEmpty()) {
     lines.add("//");
   }
   //
   for (FieldBindingInfo binding : m_fieldBindings) {
     binding.addSourceCode0(lines, generationSupport);
   }
   //
   if (!m_fieldBindings.isEmpty()) {
     lines.add("//");
   }
   //
   if (m_gridSelectionModel == null) {
     if (m_autobind) {
       lines.add(variable + ".autoBind();");
     }
     if (m_storeReference != null) {
       lines.add(variable + ".setStore(" + m_storeReference + ");");
     }
     lines.add(variable + ".bind(" + m_model.getReference() + ");");
   } else {
     String gridSelectionElementClass = m_gridSelectionModel.getObjectType().getName();
     //
     lines.add(
         m_model.getReference()
             + ".getSelectionModel().addListener(com.extjs.gxt.ui.client.event.Events.SelectionChange,");
     lines.add(
         "\t\tnew com.extjs.gxt.ui.client.event.Listener<com.extjs.gxt.ui.client.event.SelectionChangedEvent<"
             + gridSelectionElementClass
             + ">>() {");
     lines.add(
         "\t\t\tpublic void handleEvent(com.extjs.gxt.ui.client.event.SelectionChangedEvent<"
             + gridSelectionElementClass
             + "> event) {");
     lines.add(
         "\t\t\t\t" + gridSelectionElementClass + " selectionItem = event.getSelectedItem();");
     lines.add("\t\t\t\tif (selectionItem == null) {");
     lines.add("\t\t\t\t\t" + variable + ".unbind();");
     lines.add("\t\t\t\t} else {");
     lines.add("\t\t\t\t\t" + variable + ".bind(selectionItem);");
     lines.add("\t\t\t\t}");
     lines.add("\t\t\t}");
     lines.add("\t\t});");
   }
 }