Package grails.core

Examples of grails.core.GrailsTagLibClass


        List<Class> tagLibraryClasses = tagClassesByNamespace.get(namespace);
        if (tagLibraryClasses != null) {
            for (Class tagLibraryClass : tagLibraryClasses) {

                GrailsTagLibClass tagLib = tagClassToTagLibMap.get(tagLibraryClass);
                if (tagLib == null) {
                    tagLib = (GrailsTagLibClass) grailsApplication.addArtefact(TagLibArtefactHandler.TYPE, tagLibraryClass);
                    tagClassToTagLibMap.put(tagLibraryClass, tagLib);
                }
                String tagLibraryClassName = tagLibraryClass.getName();
                if (tagLib == null || !tagLib.hasTag(tagName)) {
                    continue;
                }

                if (!applicationContext.containsBean(tagLibraryClassName)) {
                    registerTagLib(tagLib);
                    if (tagLib.hasTag(tagName)) {
                        GenericBeanDefinition bd = new GenericBeanDefinition();
                        bd.setBeanClass(tagLibraryClass);
                        bd.setAutowireCandidate(true);
                        bd.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_NAME);
                        ((GenericApplicationContext)applicationContext).getDefaultListableBeanFactory().registerBeanDefinition(tagLibraryClassName, bd);
                        resolveTagLibraries.put(tagKey, tagLib.getFullName());
                        return (GroovyObject) applicationContext.getBean(tagLibraryClassName);
                    }
                }
            }
        }
View Full Code Here


    }
   
    private String getNamespace(Object instance) {
        GrailsApplication grailsApplication = getGrailsApplication(null);
        if (grailsApplication != null) {
            GrailsTagLibClass taglibrary = (GrailsTagLibClass) grailsApplication.getArtefact(TagLibArtefactHandler.TYPE, instance.getClass().getName());
            if (taglibrary != null) {
                return taglibrary.getNamespace();
            }
        }
        return TagOutput.DEFAULT_NAMESPACE;
    }
View Full Code Here

    public GroovyObject getTagLibraryForTag(HttpServletRequest request, HttpServletResponse response,String tagName, String namespace) {
        String nonNullNamesapce = namespace == null ? DEFAULT_NAMESPACE : namespace;
        String fullTagName = nonNullNamesapce + ":" + tagName;

        GrailsTagLibClass tagLibClass = (GrailsTagLibClass) getGrailsApplication().getArtefactForFeature(
                TagLibArtefactHandler.TYPE, fullTagName);
        if (tagLibClass == null) {
            return null;
        }

        return (GroovyObject)getApplicationContext().getBean(tagLibClass.getFullName());
    }
View Full Code Here

     */
    @Override
    public void initialize(ArtefactInfo artefacts) {
        tag2libMap = new HashMap<String, GrailsTagLibClass>();
        for (GrailsClass aClass : artefacts.getGrailsClasses()) {
            GrailsTagLibClass taglibClass = (GrailsTagLibClass) aClass;
            String namespace = taglibClass.getNamespace();
            namespace2tagLibMap.put(namespace, taglibClass);
            for (Object o : taglibClass.getTagNames()) {
                String tagName = namespace + ":" + o;
                if (!tag2libMap.containsKey(tagName)) {
                    tag2libMap.put(tagName, taglibClass);
                }
                else {
                    GrailsTagLibClass current = tag2libMap.get(tagName);
                    if (!taglibClass.equals(current)) {
                        LOG.info("There are conflicting tags: " + taglibClass.getFullName() + "." +
                                tagName + " vs. " + current.getFullName() + "." + tagName +
                                ". The former will take precedence.");
                        tag2libMap.put(tagName, taglibClass);
                    }
                }
            }
View Full Code Here

        Map tagLibs = (Map)pageContext.getAttribute(TAG_LIBS_ATTRIBUTE);
        if (tagLibs == null) {
            tagLibs = new HashMap();
            pageContext.setAttribute(TAG_LIBS_ATTRIBUTE, tagLibs);
        }
        GrailsTagLibClass tagLibClass = (GrailsTagLibClass) application.getArtefactForFeature(
                TagLibArtefactHandler.TYPE, GroovyPage.DEFAULT_NAMESPACE + ':' + name);

        GroovyObject tagLib;
        if (tagLibs.containsKey(tagLibClass.getFullName())) {
            tagLib = (GroovyObject)tagLibs.get(tagLibClass.getFullName());
        }
        else {
            tagLib = (GroovyObject)appContext.getBean(tagLibClass.getFullName());
            tagLibs.put(tagLibClass.getFullName(),tagLib);
        }
        return tagLib;
    }
View Full Code Here

TOP

Related Classes of grails.core.GrailsTagLibClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.