@Override
    public Component getReadOnly(final String _wicketId,
                                 final AbstractUIField _uiField)
        throws EFapsException
    {
        Component ret = null;
        if (applies(_uiField)) {
            String icon = _uiField.getFieldConfiguration().getField().getIcon();
            if (icon == null && _uiField.getInstance() != null
                            && _uiField.getFieldConfiguration().getField().isShowTypeIcon()
                            && _uiField.getInstance().getType() != null) {
                final Image image = Image.getTypeIcon(_uiField.getInstance().getType());
                if (image != null) {
                    icon = image.getName();
                }
            }
            String content = null;
            for (final IComponentFactory factory : _uiField.getFactories().values()) {
                if (factory instanceof AbstractUIFactory) {
                    final AbstractUIFactory uiFactory = (AbstractUIFactory) factory;
                    if (uiFactory.applies(_uiField)) {
                        content = uiFactory.getReadOnlyValue(_uiField);
                        break;
                    }
                }
            }
            if (StringUtils.isEmpty(content)) {
                if (isCheckOut(_uiField) && icon != null) {
                    ret = new IconCheckOutLink(_wicketId, Model.of(_uiField), content, icon);
                } else {
                    ret = new LabelField(_wicketId, Model.of(""), _uiField);
                }
            } else if (isCheckOut(_uiField)) {
                if (icon == null) {
                    ret = new CheckOutLink(_wicketId, Model.of(_uiField), content);
                } else {
                    ret = new IconCheckOutLink(_wicketId, Model.of(_uiField), content, icon);
                }
            } else {
                // evaluate which kind of link must be done
                IRequestablePage page = null;
                IRequestablePage calledByPage = null;
                if (RequestCycle.get().getActiveRequestHandler() instanceof IPageRequestHandler) {
                    page = ((IPageRequestHandler) RequestCycle.get().getActiveRequestHandler()).getPage();
                    if (page != null && page instanceof AbstractContentPage) {
                        final PageReference pageRef = ((AbstractContentPage) page).getCalledByPageReference();
                        if (pageRef != null) {
                            calledByPage = pageRef.getPage();
                        }
                    }
                }

                // first priority is the pagePosition than..
                boolean ajax = page != null
                                && ((Component) page).getDefaultModelObject() instanceof IPageObject
                                && PagePosition.TREE.equals(((IPageObject) ((Component) page).getDefaultModelObject())
                                                .getPagePosition());
                if (!ajax) {
                    ajax = _uiField.getParent() != null
                                && _uiField.getParent() instanceof IPageObject
                                && PagePosition.TREE.equals(((IPageObject) _uiField.getParent()).getPagePosition());
                }

                if (!ajax) {
                    // ajax if the page or the reference is a ContentContainerPage,
                //  or the table was called as part of a WizardCall meaning connect is done
                //  or it was opened after a form in modal mode
                    ajax = page != null && (page instanceof ContentContainerPage
                                || calledByPage instanceof ContentContainerPage)
                                || page instanceof TablePage
                                        && ((AbstractUIPageObject) ((Component) page).getDefaultModelObject())
                                                .isPartOfWizardCall()
                        // form opened modal over a form
                        || page instanceof FormPage && calledByPage instanceof FormPage
                            && Target.MODAL.equals(((UIForm) ((Component) page).getDefaultModelObject()).getTarget())
                        // form opened modal over a table that itself is part of a contentcontainer
                        || page instanceof FormPage
                            && Target.MODAL.equals(((UIForm) ((Component) page).getDefaultModelObject()).getTarget())
                            && calledByPage instanceof TablePage
                            && ((TablePage) calledByPage).getCalledByPageReference() != null
                            && !(((TablePage) calledByPage).getCalledByPageReference().getPage() instanceof MainPage);
                }
                // verify ajax by checking if is not a recent link
                if (ajax && RequestCycle.get().getActiveRequestHandler() instanceof IComponentRequestHandler) {
                    ajax = ajax && !(((IComponentRequestHandler) RequestCycle.get().getActiveRequestHandler())
                                    .getComponent() instanceof RecentLink);
                }

                // check if for searchmode the page is in an pop up window
                boolean isInPopUp = false;
                if (_uiField.getParent().isSearchMode()) {
                    if (((IWizardElement) _uiField.getParent()).isWizardCall()) {
                        final IWizardElement pageObj = ((IWizardElement) _uiField
                                        .getParent()).getUIWizardObject().getWizardElement().get(0);
                        if (pageObj instanceof IPageObject) {
                            isInPopUp = PagePosition.POPUP.equals(((IPageObject) pageObj).getPagePosition());
                        } else {
                            isInPopUp = Target.POPUP.equals(((ICmdUIObject) pageObj).getCommand().getTarget());
                        }
                    }
                }

                if (icon == null) {
                    if (ajax) {
                        // checking if is a link of a structurbrowser browserfield
                        if (page instanceof StructurBrowserPage
                                        && ((UIStructurBrowser) _uiField.getParent()).isBrowserField(_uiField)) {
                            ret = new LoadInTargetAjaxLink(_wicketId, Model.of(_uiField), content, ScriptTarget.TOP);
                        } else {
                            ret = new MenuContentLink(_wicketId, Model.of(_uiField), content);
                        }
                    } else if (isInPopUp) {
                        ret = new LoadInTargetAjaxLink(_wicketId, Model.of(_uiField), content, ScriptTarget.OPENER);
                    } else {
                        ret = new ContentContainerLink(_wicketId, Model.of(_uiField), content);
                    }
                } else {
                    if (ajax) {
                        ret = new IconMenuContentLink(_wicketId, Model.of(_uiField), content, icon);
                    } else if (isInPopUp) {
                        ret = new IconLoadInTargetAjaxLink(_wicketId, Model.of(_uiField), content,
                                        ScriptTarget.OPENER, icon);
                    } else {
                        ret = new IconContentContainerLink(_wicketId, Model.of(_uiField), content, icon);
                    }
                }
            }
        }
        return ret;
    }
@Override
    public Component getReadOnly(final String _wicketId,
                                 final AbstractUIField _uiField)
        throws EFapsException
    {
        Component ret = null;
        if (applies(_uiField)) {
            String icon = _uiField.getFieldConfiguration().getField().getIcon();
            if (icon == null && _uiField.getInstance() != null
                            && _uiField.getFieldConfiguration().getField().isShowTypeIcon()
                            && _uiField.getInstance().getType() != null) {
                final Image image = Image.getTypeIcon(_uiField.getInstance().getType());
                if (image != null) {
                    icon = image.getName();
                }
            }
            String content = null;
            for (final IComponentFactory factory : _uiField.getFactories().values()) {
                if (factory instanceof AbstractUIFactory) {
                    final AbstractUIFactory uiFactory = (AbstractUIFactory) factory;
                    if (uiFactory.applies(_uiField)) {
                        content = uiFactory.getReadOnlyValue(_uiField);
                        break;
                    }
                }
            }
            if (StringUtils.isEmpty(content)) {
                if (isCheckOut(_uiField) && icon != null) {
                    ret = new IconCheckOutLink(_wicketId, Model.of(_uiField), content, icon);
                } else {
                    ret = new LabelField(_wicketId, Model.of(""), _uiField);
                }
            } else if (isCheckOut(_uiField)) {
                if (icon == null) {
                    ret = new CheckOutLink(_wicketId, Model.of(_uiField), content);
                } else {
                    ret = new IconCheckOutLink(_wicketId, Model.of(_uiField), content, icon);
                }
            } else {
                
                IRequestablePage page = null;
                IRequestablePage calledByPage = null;
                if (RequestCycle.get().getActiveRequestHandler() instanceof IPageRequestHandler) {
                    page = ((IPageRequestHandler) RequestCycle.get().getActiveRequestHandler()).getPage();
                    if (page != null && page instanceof AbstractContentPage) {
                        final PageReference pageRef = ((AbstractContentPage) page).getCalledByPageReference();
                        if (pageRef != null) {
                            calledByPage = pageRef.getPage();
                        }
                    }
                }

                
                boolean ajax = page != null
                                && ((Component) page).getDefaultModelObject() instanceof IPageObject
                                && PagePosition.TREE.equals(((IPageObject) ((Component) page).getDefaultModelObject())
                                                .getPagePosition());
                if (!ajax) {
                    ajax = _uiField.getParent() != null
                                && _uiField.getParent() instanceof IPageObject
                                && PagePosition.TREE.equals(((IPageObject) _uiField.getParent()).getPagePosition());
                }

                if (!ajax) {
                    
                
                
                    ajax = page != null && (page instanceof ContentContainerPage
                                || calledByPage instanceof ContentContainerPage)
                                || page instanceof TablePage
                                        && ((AbstractUIPageObject) ((Component) page).getDefaultModelObject())
                                                .isPartOfWizardCall()
                        
                        || page instanceof FormPage && calledByPage instanceof FormPage
                            && Target.MODAL.equals(((UIForm) ((Component) page).getDefaultModelObject()).getTarget())
                        
                        || page instanceof FormPage
                            && Target.MODAL.equals(((UIForm) ((Component) page).getDefaultModelObject()).getTarget())
                            && calledByPage instanceof TablePage
                            && ((TablePage) calledByPage).getCalledByPageReference() != null
                            && !(((TablePage) calledByPage).getCalledByPageReference().getPage() instanceof MainPage);
                }
                
                if (ajax && RequestCycle.get().getActiveRequestHandler() instanceof IComponentRequestHandler) {
                    ajax = ajax && !(((IComponentRequestHandler) RequestCycle.get().getActiveRequestHandler())
                                    .getComponent() instanceof RecentLink);
                }

                
                boolean isInPopUp = false;
                if (_uiField.getParent().isSearchMode()) {
                    if (((IWizardElement) _uiField.getParent()).isWizardCall()) {
                        final IWizardElement pageObj = ((IWizardElement) _uiField
                                        .getParent()).getUIWizardObject().getWizardElement().get(0);
                        if (pageObj instanceof IPageObject) {
                            isInPopUp = PagePosition.POPUP.equals(((IPageObject) pageObj).getPagePosition());
                        } else {
                            isInPopUp = Target.POPUP.equals(((ICmdUIObject) pageObj).getCommand().getTarget());
                        }
                    }
                }

                if (icon == null) {
                    if (ajax) {
                        
                        if (page instanceof StructurBrowserPage
                                        && ((UIStructurBrowser) _uiField.getParent()).isBrowserField(_uiField)) {
                            ret = new LoadInTargetAjaxLink(_wicketId, Model.of(_uiField), content, ScriptTarget.TOP);
                        } else {
                            ret = new MenuContentLink(_wicketId, Model.of(_uiField), content);
                        }
                    } else if (isInPopUp) {
                        ret = new LoadInTargetAjaxLink(_wicketId, Model.of(_uiField), content, ScriptTarget.OPENER);
                    } else {
                        ret = new ContentContainerLink(_wicketId, Model.of(_uiField), content);
                    }
                } else {
                    if (ajax) {
                        ret = new IconMenuContentLink(_wicketId, Model.of(_uiField), content, icon);
                    } else if (isInPopUp) {
                        ret = new IconLoadInTargetAjaxLink(_wicketId, Model.of(_uiField), content,
                                        ScriptTarget.OPENER, icon);
                    } else {
                        ret = new IconContentContainerLink(_wicketId, Model.of(_uiField), content, icon);
                    }
                }
            }
        }
        return ret;
    }
@ Override public Component getReadOnly ( final String _wicketId , final AbstractUIField _uiField ) throws EFapsException { Component ret = null ; if ( applies ( _uiField ) ) { String icon = _uiField . getFieldConfiguration ( ) . getField ( ) . getIcon ( ) ; if ( icon == null && _uiField . getInstance ( ) != null && _uiField . getFieldConfiguration ( ) . getField ( ) . isShowTypeIcon ( ) && _uiField . getInstance ( ) . getType ( ) != null ) { final Image image = Image . getTypeIcon ( _uiField . getInstance ( ) . getType ( ) ) ; if ( image != null ) { icon = image . getName ( ) ; } } String content = null ; for ( final IComponentFactory factory : _uiField . getFactories ( ) . values ( ) ) { if ( factory instanceof AbstractUIFactory ) { final AbstractUIFactory uiFactory = ( AbstractUIFactory ) factory ; if ( uiFactory . applies ( _uiField ) ) { content = uiFactory . getReadOnlyValue ( _uiField ) ; break ; } } } if ( StringUtils . isEmpty ( content ) ) { if ( isCheckOut ( _uiField ) && icon != null ) { ret = new IconCheckOutLink ( _wicketId , Model . of ( _uiField ) , content , icon ) ; } else { ret = new LabelField ( _wicketId , Model . of ( "" ) , _uiField ) ; } } else if ( isCheckOut ( _uiField ) ) { if ( icon == null ) { ret = new CheckOutLink ( _wicketId , Model . of ( _uiField ) , content ) ; } else { ret = new IconCheckOutLink ( _wicketId , Model . of ( _uiField ) , content , icon ) ; } } else { // evaluate which kind of link must be done IRequestablePage page = null ; IRequestablePage calledByPage = null ; if ( RequestCycle . get ( ) . getActiveRequestHandler ( ) instanceof IPageRequestHandler ) { page = ( ( IPageRequestHandler ) RequestCycle . get ( ) . getActiveRequestHandler ( ) ) . getPage ( ) ; if ( page != null && page instanceof AbstractContentPage ) { final PageReference pageRef = ( ( AbstractContentPage ) page ) . getCalledByPageReference ( ) ; if ( pageRef != null ) { calledByPage = pageRef . getPage ( ) ; } } } // first priority is the pagePosition than.. boolean ajax = page != null && ( ( Component ) page ) . getDefaultModelObject ( ) instanceof IPageObject && PagePosition . TREE . equals ( ( ( IPageObject ) ( ( Component ) page ) . getDefaultModelObject ( ) ) . getPagePosition ( ) ) ; if ( ! ajax ) { ajax = _uiField . getParent ( ) != null && _uiField . getParent ( ) instanceof IPageObject && PagePosition . TREE . equals ( ( ( IPageObject ) _uiField . getParent ( ) ) . getPagePosition ( ) ) ; } if ( ! ajax ) { // ajax if the page or the reference is a ContentContainerPage, //  or the table was called as part of a WizardCall meaning connect is done //  or it was opened after a form in modal mode ajax = page != null && ( page instanceof ContentContainerPage || calledByPage instanceof ContentContainerPage ) || page instanceof TablePage && ( ( AbstractUIPageObject ) ( ( Component ) page ) . getDefaultModelObject ( ) ) . isPartOfWizardCall ( ) // form opened modal over a form || page instanceof FormPage && calledByPage instanceof FormPage && Target . MODAL . equals ( ( ( UIForm ) ( ( Component ) page ) . getDefaultModelObject ( ) ) . getTarget ( ) ) // form opened modal over a table that itself is part of a contentcontainer || page instanceof FormPage && Target . MODAL . equals ( ( ( UIForm ) ( ( Component ) page ) . getDefaultModelObject ( ) ) . getTarget ( ) ) && calledByPage instanceof TablePage && ( ( TablePage ) calledByPage ) . getCalledByPageReference ( ) != null && ! ( ( ( TablePage ) calledByPage ) . getCalledByPageReference ( ) . getPage ( ) instanceof MainPage ) ; } // verify ajax by checking if is not a recent link if ( ajax && RequestCycle . get ( ) . getActiveRequestHandler ( ) instanceof IComponentRequestHandler ) { ajax = ajax && ! ( ( ( IComponentRequestHandler ) RequestCycle . get ( ) . getActiveRequestHandler ( ) ) . getComponent ( ) instanceof RecentLink ) ; } // check if for searchmode the page is in an pop up window boolean isInPopUp = false ; if ( _uiField . getParent ( ) . isSearchMode ( ) ) { if ( ( ( IWizardElement ) _uiField . getParent ( ) ) . isWizardCall ( ) ) { final IWizardElement pageObj = ( ( IWizardElement ) _uiField . getParent ( ) ) . getUIWizardObject ( ) . getWizardElement ( ) . get ( 0 ) ; if ( pageObj instanceof IPageObject ) { isInPopUp = PagePosition . POPUP . equals ( ( ( IPageObject ) pageObj ) . getPagePosition ( ) ) ; } else { isInPopUp = Target . POPUP . equals ( ( ( ICmdUIObject ) pageObj ) . getCommand ( ) . getTarget ( ) ) ; } } } if ( icon == null ) { if ( ajax ) { // checking if is a link of a structurbrowser browserfield if ( page instanceof StructurBrowserPage && ( ( UIStructurBrowser ) _uiField . getParent ( ) ) . isBrowserField ( _uiField ) ) { ret = new LoadInTargetAjaxLink ( _wicketId , Model . of ( _uiField ) , content , ScriptTarget . TOP ) ; } else { ret = new MenuContentLink ( _wicketId , Model . of ( _uiField ) , content ) ; } } else if ( isInPopUp ) { ret = new LoadInTargetAjaxLink ( _wicketId , Model . of ( _uiField ) , content , ScriptTarget . OPENER ) ; } else { ret = new ContentContainerLink ( _wicketId , Model . of ( _uiField ) , content ) ; } } else { if ( ajax ) { ret = new IconMenuContentLink ( _wicketId , Model . of ( _uiField ) , content , icon ) ; } else if ( isInPopUp ) { ret = new IconLoadInTargetAjaxLink ( _wicketId , Model . of ( _uiField ) , content , ScriptTarget . OPENER , icon ) ; } else { ret = new IconContentContainerLink ( _wicketId , Model . of ( _uiField ) , content , icon ) ; } } } } return ret ; }
{@inheritDoc}
{