myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1569412 - in /myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler: CompositeTextInstruction.java TextUnit.java
Date Tue, 18 Feb 2014 16:28:27 GMT
Author: lu4242
Date: Tue Feb 18 16:28:27 2014
New Revision: 1569412

URL: http://svn.apache.org/r1569412
Log:
MYFACES-3850 html EL expression inside markup enables escape on static text in facelets jspx
mode (avoid compression over text wrapping instructions in a single one)

Added:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompositeTextInstruction.java
  (with props)
Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java

Added: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompositeTextInstruction.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompositeTextInstruction.java?rev=1569412&view=auto
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompositeTextInstruction.java
(added)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompositeTextInstruction.java
Tue Feb 18 16:28:27 2014
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.view.facelets.compiler;
+
+import java.io.IOException;
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.faces.context.FacesContext;
+
+/**
+ * This instruction group literal and non literal text instructions.
+ * Used to avoid text space compression, but note it is only used by
+ * TextUnit when there is no inline escape (jspx) and compression enabled.
+ *
+ */
+final class CompositeTextInstruction implements Instruction
+{
+    private Instruction[] instructions;
+
+    public CompositeTextInstruction(Instruction[] instructions)
+    {
+        this.instructions = instructions;
+    }
+
+    @Override
+    public void write(FacesContext context) throws IOException
+    {
+        for (Instruction i : instructions)
+        {
+            i.write(context);
+        }
+    }
+
+    @Override
+    public Instruction apply(ExpressionFactory factory, ELContext ctx)
+    {
+        Instruction[] array = new Instruction[instructions.length];
+        for (int i = 0; i < instructions.length; i++)
+        {
+            array[i] = instructions[i].apply(factory, ctx);
+        }
+        return new CompositeTextInstruction(array);
+    }
+
+    @Override
+    public boolean isLiteral()
+    {
+        boolean literal = true;
+        for (Instruction i : instructions)
+        {
+            if (!i.isLiteral())
+            {
+                literal = false;
+                break;
+            }
+        }
+        return literal;
+    }
+    
+}

Propchange: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CompositeTextInstruction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java?rev=1569412&r1=1569411&r2=1569412&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
(original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/TextUnit.java
Tue Feb 18 16:28:27 2014
@@ -167,18 +167,20 @@ final class TextUnit extends Compilation
                                 ELText[] splitText = ELText.parseAsArray(s);
                                 if (splitText.length > 1)
                                 {
-                                    for (ELText selText : splitText)
+                                    Instruction[] array = new Instruction[splitText.length];
+                                    for (int i = 0; i < splitText.length; i++)
                                     {
+                                        ELText selText = splitText[i];
                                         if (selText.isLiteral())
                                         {
-                                            this.instructionBuffer.add(
-                                                new LiteralNonExcapedTextInstruction(selText.toString()));
+                                            array[i] = new LiteralNonExcapedTextInstruction(selText.toString());
                                         }
                                         else
                                         {
-                                            this.instructionBuffer.add(new TextInstruction(this.alias,
selText ));
+                                            array[i] = new TextInstruction(this.alias, selText
);
                                         }
                                     }
+                                    this.instructionBuffer.add(new CompositeTextInstruction(array));
                                 }
                                 else
                                 {
@@ -217,18 +219,20 @@ final class TextUnit extends Compilation
                             ELText[] splitText = ELText.parseAsArray(s);
                             if (splitText.length > 1)
                             {
-                                for (ELText selText : splitText)
+                                Instruction[] array = new Instruction[splitText.length];
+                                for (int i = 0; i < splitText.length; i++)
                                 {
+                                    ELText selText = splitText[i];
                                     if (selText.isLiteral())
                                     {
-                                        this.instructionBuffer.add(
-                                            new LiteralNonExcapedTextInstruction(selText.toString()));
+                                        array[i] = new LiteralNonExcapedTextInstruction(selText.toString());
                                     }
                                     else
                                     {
-                                        this.instructionBuffer.add(new TextInstruction(this.alias,
selText ));
+                                        array[i] = new TextInstruction(this.alias, selText
);
                                     }
                                 }
+                                this.instructionBuffer.add(new CompositeTextInstruction(array));
                             }
                             else
                             {



Mime
View raw message