Package org.thymeleaf.standard.fragment

Examples of org.thymeleaf.standard.fragment.StandardFragment


            final Configuration configuration = viewTemplateEngine.getConfiguration();
            final ProcessingContext processingContext = new ProcessingContext(context);

            final String dialectPrefix = getStandardDialectPrefix(configuration);

            final StandardFragment fragment =
                    StandardFragmentProcessor.computeStandardFragmentSpec(
                            configuration, processingContext, viewTemplateName, dialectPrefix, StandardFragmentAttrProcessor.ATTR_NAME);

            if (fragment == null) {
                throw new IllegalArgumentException("Invalid template name specification: '" + viewTemplateName + "'");
            }

            templateName = fragment.getTemplateName();
            nameFragmentSpec = fragment.getFragmentSpec();
            final Map<String,Object> nameFragmentParameters = fragment.getParameters();

            if (nameFragmentParameters != null) {

                if (FragmentSelectionUtils.parameterNamesAreSynthetic(nameFragmentParameters.keySet())) {
                    // We cannot allow synthetic parameters because there is no way to specify them at the template
View Full Code Here


            final Configuration configuration = viewTemplateEngine.getConfiguration();
            final ProcessingContext processingContext = new ProcessingContext(context);

            final String dialectPrefix = getStandardDialectPrefix(configuration);

            final StandardFragment fragment =
                    StandardFragmentProcessor.computeStandardFragmentSpec(
                            configuration, processingContext, viewTemplateName, dialectPrefix, StandardFragmentAttrProcessor.ATTR_NAME);

            if (fragment == null) {
                throw new IllegalArgumentException("Invalid template name specification: '" + viewTemplateName + "'");
            }

            templateName = fragment.getTemplateName();
            nameFragmentSpec = fragment.getFragmentSpec();
            final Map<String,Object> nameFragmentParameters = fragment.getParameters();

            if (nameFragmentParameters != null) {

                if (FragmentSelectionUtils.parameterNamesAreSynthetic(nameFragmentParameters.keySet())) {
                    // We cannot allow synthetic parameters because there is no way to specify them at the template
View Full Code Here

      throw new IllegalArgumentException("layout:decorator attribute must appear in the root element of your content page");
    }
    Document document = arguments.getDocument();

    // Locate the decorator page
    StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
        arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
        DIALECT_PREFIX_LAYOUT, PROCESSOR_NAME_FRAGMENT);
    Template decoratortemplate = arguments.getTemplateRepository().getTemplate(new TemplateProcessingParameters(
        arguments.getConfiguration(), fragment.getTemplateName(), arguments.getContext()));
    element.removeAttribute(attributeName);

    Document decoratordocument = decoratortemplate.getDocument();
    Element decoratorrootelement = decoratordocument.getFirstElementChild();
View Full Code Here

   */
  @Override
  protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {

    // Locate the page and fragment to include
    StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
        arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
        DIALECT_PREFIX_LAYOUT, PROCESSOR_NAME_FRAGMENT);
    List<Node> includefragments = fragment.extractFragment(arguments.getConfiguration(),
        arguments, arguments.getTemplateRepository());

    element.removeAttribute(attributeName);

    // Gather all fragment parts within the include element
View Full Code Here

   */
  @Override
  protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {

    // Locate the page and fragment to include
    StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
        arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
        DIALECT_PREFIX_LAYOUT, PROCESSOR_NAME_FRAGMENT);
    List<Node> includefragments = fragment.extractFragment(arguments.getConfiguration(),
        arguments, arguments.getTemplateRepository());

    element.removeAttribute(attributeName);

    // Gather all fragment parts within the replace element
View Full Code Here

   */
  @Override
  protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) {

    // Locate the page and fragment to include
    StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
        arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName),
        DIALECT_PREFIX_LAYOUT, PROCESSOR_NAME_FRAGMENT);
    List<Node> includefragments = fragment.extractFragment(arguments.getConfiguration(),
        arguments, arguments.getTemplateRepository());

    element.removeAttribute(attributeName);

    // Gather all fragment parts within the substituteby element
View Full Code Here

        final String dialectPrefix = Attribute.getPrefixFromAttributeName(attributeName);

        final String fragmentSignatureAttributeName =
                getFragmentSignatureUnprefixedAttributeName(arguments, element, attributeName, attributeValue);

        final StandardFragment fragment =
                StandardFragmentProcessor.computeStandardFragmentSpec(
                        arguments.getConfiguration(), arguments, attributeValue, dialectPrefix, fragmentSignatureAttributeName);

        final List<Node> extractedNodes =
                fragment.extractFragment(arguments.getConfiguration(), arguments, arguments.getTemplateRepository());

        final boolean removeHostNode = getRemoveHostNode(arguments, element, attributeName, attributeValue);

        // If fragment is a whole document (no selection inside), we should never remove its parent node/s
        // Besides, we know that StandardFragmentProcessor.computeStandardFragmentSpec only creates two types of
        // IFragmentSpec objects: WholeFragmentSpec and DOMSelectorFragmentSpec.
        final boolean isWholeDocument = (fragment.getFragmentSpec() instanceof WholeFragmentSpec);

        if (extractedNodes == null || removeHostNode || isWholeDocument) {
            return extractedNodes;
        }
View Full Code Here

            // need to ensure engine initialised before getting configuration
            if (!engine.isInitialized()) {
                engine.initialize();
            }
            // allow template fragment syntax to be used e.g. template.html :: area
            final StandardFragment fragment = StandardFragmentProcessor.computeStandardFragmentSpec(
                    engine.getConfiguration(), new ProcessingContext(context), templateScript, null, "th:"
                            + StandardFragmentAttrProcessor.ATTR_NAME);

            // and pass the fragment name and spec then onto the engine
            engine.process(fragment.getTemplateName(), context, fragment.getFragmentSpec(), out);
        }catch(IOException x) {
            throw new RenderException(x);
        }

View Full Code Here

TOP

Related Classes of org.thymeleaf.standard.fragment.StandardFragment

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.