src/main/java/org/efaps/ui/wicket/models/objects/UIForm.java
private void execute4NoInstance()
        throws EFapsException
    {
        final Form form = getForm();
        Type type = null;
        if (isCreateMode() || isEditMode()) {
            type = getCreateTargetType();
        } else {
            final List<EventDefinition> events = this.getCommand().getEvents(EventType.UI_TABLE_EVALUATE);
            if (events != null) {
                for (final EventDefinition eventDef : events) {
                    String tmp = eventDef.getProperty("Type");
                    if (tmp == null) {
                        tmp = eventDef.getProperty("Types");
                        if (tmp != null) {
                            UIForm.LOG.warn("Event '{}' uses deprecated API for type.", eventDef.getName());
                        } else {
                            UIForm.LOG.error("Event '{}' is not type property", eventDef.getName());
                        }
                    }
                    if (tmp != null) {
                        type = Type.get(tmp);
                        break;
                    }
                }
            }
        }

        FormElement currentFormElement = null;
        boolean addNew = true;
        UIClassification uiclass = null;
        boolean firstTable = true;
        for (final Field field : form.getFields()) {
            if (field.hasAccess(getMode(), AbstractInstanceObject.getInstance4Create(type), this.getCommand(),
                            getInstance()) && !field.isNoneDisplay(getMode())) {
                if (field instanceof FieldGroup) {
                    final FieldGroup group = (FieldGroup) field;
                    // in case that the first field is a group the element must be initiated
                    if (currentFormElement == null) {
                        currentFormElement = new FormElement();
                        this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                        addNew = false;
                    }
                    currentFormElement.setGroupCount(group.getGroupCount());
                } else if (field instanceof FieldHeading) {
                    this.elements.add(new Element(UIForm.ElementType.HEADING, new UIHeading((FieldHeading) field)));
                    addNew = true;
                } else if (field instanceof FieldClassification) {
                    uiclass = UIClassification.getUIClassification(field, this);
                    this.elements.add(new Element(UIForm.ElementType.CLASSIFICATION, uiclass));
                    this.classified = true;
                    addNew = true;
                } else if (field instanceof FieldTable) {
                    if (((FieldTable) field).getTargetStructurBrowserField() == null) {
                        final UIFieldTable uiFieldTable = new UIFieldTable(getCommandUUID(), getInstanceKey(),
                                                                           (FieldTable) field);
                        this.elements.add(new Element(UIForm.ElementType.TABLE, uiFieldTable));
                        if (firstTable) {
                            firstTable = false;
                        } else {
                            uiFieldTable.setFirstTable(false);
                        }
                    } else {
                        if ("GridX".equals(Configuration.getAttribute(ConfigAttribute.STRUCBRWSR_DEFAULTTYPEFORM))) {
                            final UIFieldGrid grid = UIFieldGrid.get(getCommandUUID(), getPagePosition(),
                                            getInstance(), (FieldTable) field);
                            this.elements.add(new Element(UIForm.ElementType.GRID, grid));
                        } else {
                            final UIFieldStructurBrowser uiFieldStrucBrws = new UIFieldStructurBrowser(getCommandUUID(),
                                        getInstanceKey(), (FieldTable) field);
                            this.elements.add(new Element(UIForm.ElementType.STRUCBRWS, uiFieldStrucBrws));
                        }
                    }
                    addNew = true;
                } else {
                    if (addNew) {
                        final FormElement formElement = new FormElement().setGroupCount(currentFormElement == null ? 0
                                        : currentFormElement.getGroupCount());
                        currentFormElement = formElement;
                        this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                        addNew = false;
                    }
                    final Attribute attr;
                    if (field.getAttribute() == null && field.getSelect() != null && type != null) {
                        final PrintQuery print = new PrintQuery(AbstractInstanceObject.getInstance4Create(type));
                        print.addSelect(field.getSelect());
                        print.dryRun();
                        attr = print.getAttribute4Select(field.getSelect());
                    } else {
                        attr = type != null ? type.getAttribute(field.getAttribute()) : null;
                    }

                    if (field.isHiddenDisplay(getMode())) {
                        final UIField uiField = new UIField(this, null, UIValue.get(field, attr, null)
                                        .setClassObject(this)
                                        .setInstance(getInstance()).setCallInstance(getInstance()));
                        addHidden(uiField);
                    } else {
                        final IUIElement cell;
                        if (field instanceof FieldSet) {
                            cell = new UIFieldSet(this, getInstance(), UIValue.get(field, attr, null)
                                                .setClassObject(this)
                                                .setInstance(getInstance())
                                                .setCallInstance(getInstance()));
                            if (type == null) {
                                ((UIFieldSet) cell).addHeader(new UIFieldSetColHeader(field.getLabel(), null, field));
                            } else {
                                final AttributeSet set = AttributeSet.find(type.getName(), field.getAttribute());
                                for (final String attrName : ((FieldSet) field).getOrder()) {
                                    final Attribute child = set.getAttribute(attrName);
                                    final UIFieldSetColHeader column = new UIFieldSetColHeader(field.getLabel(), child,
                                                    field);
                                    ((UIFieldSet) cell).addHeader(column);
                                }
                            }
                        } else if (field instanceof FieldCommand) {
                            cell = new UICmdField(this, (FieldCommand) field, getInstance());
                        } else if (field instanceof FieldPicker) {
                            cell = new UIField(this, null, UIValue.get(field, attr, null).setClassObject(this)
                                            .setInstance(getInstance()).setCallInstance(getInstance()));
                            final UIPicker picker = new UIPicker((FieldPicker) field, (AbstractInstanceObject) cell);
                            ((UIField) cell).setPicker(picker);
                        } else {
                            cell = new UIField(this, null, UIValue.get(field, attr,
                                                super.isPartOfWizardCall() ? getValue4Wizard(field.getName()) : null)
                                                .setClassObject(this)
                                                .setInstance(AbstractInstanceObject.getInstance4Create(type))
                                                .setCallInstance(getInstance()));
                        }
                        currentFormElement.addValue(cell);
                    }
                }
            }
        }
        if (uiclass != null) {
            final Set<Classification> clazzes = this.getCommand().getTargetCreateClassification();
            for (final Classification clazz : clazzes) {
                uiclass.addSelectedUUID(clazz.getUUID());
                Classification parent = clazz.getParentClassification();
                while (parent != null) {
                    uiclass.addSelectedUUID(parent.getUUID());
                    parent = parent.getParentClassification();
                }
            }
            if (!uiclass.isInitialized()) {
                uiclass.execute(null);
            }
            this.elements.addAll(getClassElements(uiclass, new HashMap<UUID, String>()));
        }
    }
private void execute4NoInstance()
        throws EFapsException
    {
        final Form form = getForm();
        Type type = null;
        if (isCreateMode() || isEditMode()) {
            type = getCreateTargetType();
        } else {
            final List<EventDefinition> events = this.getCommand().getEvents(EventType.UI_TABLE_EVALUATE);
            if (events != null) {
                for (final EventDefinition eventDef : events) {
                    String tmp = eventDef.getProperty("Type");
                    if (tmp == null) {
                        tmp = eventDef.getProperty("Types");
                        if (tmp != null) {
                            UIForm.LOG.warn("Event '{}' uses deprecated API for type.", eventDef.getName());
                        } else {
                            UIForm.LOG.error("Event '{}' is not type property", eventDef.getName());
                        }
                    }
                    if (tmp != null) {
                        type = Type.get(tmp);
                        break;
                    }
                }
            }
        }

        FormElement currentFormElement = null;
        boolean addNew = true;
        UIClassification uiclass = null;
        boolean firstTable = true;
        for (final Field field : form.getFields()) {
            if (field.hasAccess(getMode(), AbstractInstanceObject.getInstance4Create(type), this.getCommand(),
                            getInstance()) && !field.isNoneDisplay(getMode())) {
                if (field instanceof FieldGroup) {
                    final FieldGroup group = (FieldGroup) field;
                    // in case that the first field is a group the element must be initiated
                    if (currentFormElement == null) {
                        currentFormElement = new FormElement();
                        this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                        addNew = false;
                    }
                    currentFormElement.setGroupCount(group.getGroupCount());
                } else if (field instanceof FieldHeading) {
                    this.elements.add(new Element(UIForm.ElementType.HEADING, new UIHeading((FieldHeading) field)));
                    addNew = true;
                } else if (field instanceof FieldClassification) {
                    uiclass = UIClassification.getUIClassification(field, this);
                    this.elements.add(new Element(UIForm.ElementType.CLASSIFICATION, uiclass));
                    this.classified = true;
                    addNew = true;
                } else if (field instanceof FieldTable) {
                    if (((FieldTable) field).getTargetStructurBrowserField() == null) {
                        final UIFieldTable uiFieldTable = new UIFieldTable(getCommandUUID(), getInstanceKey(),
                                                                           (FieldTable) field);
                        this.elements.add(new Element(UIForm.ElementType.TABLE, uiFieldTable));
                        if (firstTable) {
                            firstTable = false;
                        } else {
                            uiFieldTable.setFirstTable(false);
                        }
                    } else {
                        if ("GridX".equals(Configuration.getAttribute(ConfigAttribute.STRUCBRWSR_DEFAULTTYPEFORM))) {
                            final UIFieldGrid grid = UIFieldGrid.get(getCommandUUID(), getPagePosition(),
                                            getInstance(), (FieldTable) field);
                            this.elements.add(new Element(UIForm.ElementType.GRID, grid));
                        } else {
                            final UIFieldStructurBrowser uiFieldStrucBrws = new UIFieldStructurBrowser(getCommandUUID(),
                                        getInstanceKey(), (FieldTable) field);
                            this.elements.add(new Element(UIForm.ElementType.STRUCBRWS, uiFieldStrucBrws));
                        }
                    }
                    addNew = true;
                } else {
                    if (addNew) {
                        final FormElement formElement = new FormElement().setGroupCount(currentFormElement == null ? 0
                                        : currentFormElement.getGroupCount());
                        currentFormElement = formElement;
                        this.elements.add(new Element(UIForm.ElementType.FORM, currentFormElement));
                        addNew = false;
                    }
                    final Attribute attr;
                    if (field.getAttribute() == null && field.getSelect() != null && type != null) {
                        final PrintQuery print = new PrintQuery(AbstractInstanceObject.getInstance4Create(type));
                        print.addSelect(field.getSelect());
                        print.dryRun();
                        attr = print.getAttribute4Select(field.getSelect());
                    } else {
                        attr = type != null ? type.getAttribute(field.getAttribute()) : null;
                    }

                    if (field.isHiddenDisplay(getMode())) {
                        final UIField uiField = new UIField(this, null, UIValue.get(field, attr, null)
                                        .setClassObject(this)
                                        .setInstance(getInstance()).setCallInstance(getInstance()));
                        addHidden(uiField);
                    } else {
                        final IUIElement cell;
                        if (field instanceof FieldSet) {
                            cell = new UIFieldSet(this, getInstance(), UIValue.get(field, attr, null)
                                                .setClassObject(this)
                                                .setInstance(getInstance())
                                                .setCallInstance(getInstance()));
                            if (type == null) {
                                ((UIFieldSet) cell).addHeader(new UIFieldSetColHeader(field.getLabel(), null, field));
                            } else {
                                final AttributeSet set = AttributeSet.find(type.getName(), field.getAttribute());
                                for (final String attrName : ((FieldSet) field).getOrder()) {
                                    final Attribute child = set.getAttribute(attrName);
                                    final UIFieldSetColHeader column = new UIFieldSetColHeader(field.getLabel(), child,
                                                    field);
                                    ((UIFieldSet) cell).addHeader(column);
                                }
                            }
                        } else if (field instanceof FieldCommand) {
                            cell = new UICmdField(this, (FieldCommand) field, getInstance());
                        } else if (field instanceof FieldPicker) {
                            cell = new UIField(this, null, UIValue.get(field, attr, null).setClassObject(this)
                                            .setInstance(getInstance()).setCallInstance(getInstance()));
                            final UIPicker picker = new UIPicker((FieldPicker) field, (AbstractInstanceObject) cell);
                            ((UIField) cell).setPicker(picker);
                        } else {
                            cell = new UIField(this, null, UIValue.get(field, attr,
                                                super.isPartOfWizardCall() ? getValue4Wizard(field.getName()) : null)
                                                .setClassObject(this)
                                                .setInstance(AbstractInstanceObject.getInstance4Create(type))
                                                .setCallInstance(getInstance()));
                        }
                        currentFormElement.addValue(cell);
                    }
                }
            }
        }
        if (uiclass != null) {
            final Set<Classification> clazzes = this.getCommand().getTargetCreateClassification();
            for (final Classification clazz : clazzes) {
                uiclass.addSelectedUUID(clazz.getUUID());
                Classification parent = clazz.getParentClassification();
                while (parent != null) {
                    uiclass.addSelectedUUID(parent.getUUID());
                    parent = parent.getParentClassification();
                }
            }
            if (!uiclass.isInitialized()) {
                uiclass.execute(null);
            }
            this.elements.addAll(getClassElements(uiclass, new HashMap<UUID, String>()));
        }
    }
private void execute4NoInstance ( ) throws EFapsException { final Form form = getForm ( ) ; Type type = null ; if ( isCreateMode ( ) || isEditMode ( ) ) { type = getCreateTargetType ( ) ; } else { final List < EventDefinition > events = this . getCommand ( ) . getEvents ( EventType . UI_TABLE_EVALUATE ) ; if ( events != null ) { for ( final EventDefinition eventDef : events ) { String tmp = eventDef . getProperty ( "Type" ) ; if ( tmp == null ) { tmp = eventDef . getProperty ( "Types" ) ; if ( tmp != null ) { UIForm . LOG . warn ( "Event '{}' uses deprecated API for type." , eventDef . getName ( ) ) ; } else { UIForm . LOG . error ( "Event '{}' is not type property" , eventDef . getName ( ) ) ; } } if ( tmp != null ) { type = Type . get ( tmp ) ; break ; } } } } FormElement currentFormElement = null ; boolean addNew = true ; UIClassification uiclass = null ; boolean firstTable = true ; for ( final Field field : form . getFields ( ) ) { if ( field . hasAccess ( getMode ( ) , AbstractInstanceObject . getInstance4Create ( type ) , this . getCommand ( ) , getInstance ( ) ) && ! field . isNoneDisplay ( getMode ( ) ) ) { if ( field instanceof FieldGroup ) { final FieldGroup group = ( FieldGroup ) field ; // in case that the first field is a group the element must be initiated if ( currentFormElement == null ) { currentFormElement = new FormElement ( ) ; this . elements . add ( new Element ( UIForm . ElementType . FORM , currentFormElement ) ) ; addNew = false ; } currentFormElement . setGroupCount ( group . getGroupCount ( ) ) ; } else if ( field instanceof FieldHeading ) { this . elements . add ( new Element ( UIForm . ElementType . HEADING , new UIHeading ( ( FieldHeading ) field ) ) ) ; addNew = true ; } else if ( field instanceof FieldClassification ) { uiclass = UIClassification . getUIClassification ( field , this ) ; this . elements . add ( new Element ( UIForm . ElementType . CLASSIFICATION , uiclass ) ) ; this . classified = true ; addNew = true ; } else if ( field instanceof FieldTable ) { if ( ( ( FieldTable ) field ) . getTargetStructurBrowserField ( ) == null ) { final UIFieldTable uiFieldTable = new UIFieldTable ( getCommandUUID ( ) , getInstanceKey ( ) , ( FieldTable ) field ) ; this . elements . add ( new Element ( UIForm . ElementType . TABLE , uiFieldTable ) ) ; if ( firstTable ) { firstTable = false ; } else { uiFieldTable . setFirstTable ( false ) ; } } else { if ( "GridX" . equals ( Configuration . getAttribute ( ConfigAttribute . STRUCBRWSR_DEFAULTTYPEFORM ) ) ) { final UIFieldGrid grid = UIFieldGrid . get ( getCommandUUID ( ) , getPagePosition ( ) , getInstance ( ) , ( FieldTable ) field ) ; this . elements . add ( new Element ( UIForm . ElementType . GRID , grid ) ) ; } else { final UIFieldStructurBrowser uiFieldStrucBrws = new UIFieldStructurBrowser ( getCommandUUID ( ) , getInstanceKey ( ) , ( FieldTable ) field ) ; this . elements . add ( new Element ( UIForm . ElementType . STRUCBRWS , uiFieldStrucBrws ) ) ; } } addNew = true ; } else { if ( addNew ) { final FormElement formElement = new FormElement ( ) . setGroupCount ( currentFormElement == null ? 0 : currentFormElement . getGroupCount ( ) ) ; currentFormElement = formElement ; this . elements . add ( new Element ( UIForm . ElementType . FORM , currentFormElement ) ) ; addNew = false ; } final Attribute attr ; if ( field . getAttribute ( ) == null && field . getSelect ( ) != null && type != null ) { final PrintQuery print = new PrintQuery ( AbstractInstanceObject . getInstance4Create ( type ) ) ; print . addSelect ( field . getSelect ( ) ) ; print . dryRun ( ) ; attr = print . getAttribute4Select ( field . getSelect ( ) ) ; } else { attr = type != null ? type . getAttribute ( field . getAttribute ( ) ) : null ; } if ( field . isHiddenDisplay ( getMode ( ) ) ) { final UIField uiField = new UIField ( this , null , UIValue . get ( field , attr , null ) . setClassObject ( this ) . setInstance ( getInstance ( ) ) . setCallInstance ( getInstance ( ) ) ) ; addHidden ( uiField ) ; } else { final IUIElement cell ; if ( field instanceof FieldSet ) { cell = new UIFieldSet ( this , getInstance ( ) , UIValue . get ( field , attr , null ) . setClassObject ( this ) . setInstance ( getInstance ( ) ) . setCallInstance ( getInstance ( ) ) ) ; if ( type == null ) { ( ( UIFieldSet ) cell ) . addHeader ( new UIFieldSetColHeader ( field . getLabel ( ) , null , field ) ) ; } else { final AttributeSet set = AttributeSet . find ( type . getName ( ) , field . getAttribute ( ) ) ; for ( final String attrName : ( ( FieldSet ) field ) . getOrder ( ) ) { final Attribute child = set . getAttribute ( attrName ) ; final UIFieldSetColHeader column = new UIFieldSetColHeader ( field . getLabel ( ) , child , field ) ; ( ( UIFieldSet ) cell ) . addHeader ( column ) ; } } } else if ( field instanceof FieldCommand ) { cell = new UICmdField ( this , ( FieldCommand ) field , getInstance ( ) ) ; } else if ( field instanceof FieldPicker ) { cell = new UIField ( this , null , UIValue . get ( field , attr , null ) . setClassObject ( this ) . setInstance ( getInstance ( ) ) . setCallInstance ( getInstance ( ) ) ) ; final UIPicker picker = new UIPicker ( ( FieldPicker ) field , ( AbstractInstanceObject ) cell ) ; ( ( UIField ) cell ) . setPicker ( picker ) ; } else { cell = new UIField ( this , null , UIValue . get ( field , attr , super . isPartOfWizardCall ( ) ? getValue4Wizard ( field . getName ( ) ) : null ) . setClassObject ( this ) . setInstance ( AbstractInstanceObject . getInstance4Create ( type ) ) . setCallInstance ( getInstance ( ) ) ) ; } currentFormElement . addValue ( cell ) ; } } } } if ( uiclass != null ) { final Set < Classification > clazzes = this . getCommand ( ) . getTargetCreateClassification ( ) ; for ( final Classification clazz : clazzes ) { uiclass . addSelectedUUID ( clazz . getUUID ( ) ) ; Classification parent = clazz . getParentClassification ( ) ; while ( parent != null ) { uiclass . addSelectedUUID ( parent . getUUID ( ) ) ; parent = parent . getParentClassification ( ) ; } } if ( ! uiclass . isInitialized ( ) ) { uiclass . execute ( null ) ; } this . elements . addAll ( getClassElements ( uiclass , new HashMap < UUID , String > ( ) ) ) ; } }
Method to execute the form in case of create or search.

@throws EFapsException on error
Method to execute the form in case of create or search .