You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/05/02 03:40:16 UTC

svn commit: r940145 - in /myfaces/tomahawk/trunk/examples/simple/src/main: java/org/apache/myfaces/examples/messages/ java/org/apache/myfaces/examples/messages/MessagesBean.java webapp/WEB-INF/examples-config.xml webapp/home.jsp webapp/messages.jsp

Author: lu4242
Date: Sun May  2 01:40:15 2010
New Revision: 940145

URL: http://svn.apache.org/viewvc?rev=940145&view=rev
Log:
TOMAHAWK-1494 HtmlMessageRenderer evaluates value expressions of not rendered components

Added:
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/messages/
    myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/messages/MessagesBean.java
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/messages.jsp
Modified:
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml
    myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp

Added: myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/messages/MessagesBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/messages/MessagesBean.java?rev=940145&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/messages/MessagesBean.java (added)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/java/org/apache/myfaces/examples/messages/MessagesBean.java Sun May  2 01:40:15 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.examples.messages;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+public class MessagesBean
+{
+
+    public void printMessages(ActionEvent e)
+    {
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        
+        facesContext.addMessage(null, new FacesMessage("[1 Global Summary Only]"));
+        facesContext.addMessage(null, new FacesMessage("[2 Global Summary]","[Global Detail]"));
+        facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "[3 Global Summary]","[3 Global Detail]"));
+        
+        facesContext.addMessage("mainForm:input1", new FacesMessage("[4 input1 Summary Only]"));
+        facesContext.addMessage("mainForm:input1", new FacesMessage("[5 input1 Summary]","[5 input1 Detail]"));
+        facesContext.addMessage("mainForm:input2", new FacesMessage(FacesMessage.SEVERITY_FATAL, "[6 input1 Summary]","[6 input1 Detail]"));
+    }
+}

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml?rev=940145&r1=940144&r2=940145&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/WEB-INF/examples-config.xml Sun May  2 01:40:15 2010
@@ -623,7 +623,13 @@
         <managed-bean-class>org.apache.myfaces.examples.selectOneRow.SelectOneRowList</managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>	
-     
+    
+    <!-- Managed bean for h:messages example -->
+    <managed-bean>
+        <managed-bean-name>messagesBean</managed-bean-name>
+        <managed-bean-class>org.apache.myfaces.examples.messages.MessagesBean</managed-bean-class>
+        <managed-bean-scope>request</managed-bean-scope>
+    </managed-bean>
 
     <!-- NAVIGATION RULES -->
 

Modified: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp?rev=940145&r1=940144&r2=940145&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp (original)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/home.jsp Sun May  2 01:40:15 2010
@@ -32,6 +32,7 @@
                 <h:outputLink value="buffer.jsf" ><f:verbatim>Buffer</f:verbatim></h:outputLink>
                 <h:outputLink value="div.jsf" ><f:verbatim>Div</f:verbatim></h:outputLink>
 				<h:outputLink value="filteredStylesheet.jsf" ><f:verbatim>Filtered Stylesheet</f:verbatim></h:outputLink>
+                <h:outputLink value="messages.jsf" ><f:verbatim>Messages</f:verbatim></h:outputLink>
                 <h:outputText value="Data Table"/>
                 <h:panelGrid style="padding-left:25px">
                     <h:outputLink value="masterDetail.jsf" ><f:verbatim>Master-Detail</f:verbatim></h:outputLink>

Added: myfaces/tomahawk/trunk/examples/simple/src/main/webapp/messages.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/examples/simple/src/main/webapp/messages.jsp?rev=940145&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/examples/simple/src/main/webapp/messages.jsp (added)
+++ myfaces/tomahawk/trunk/examples/simple/src/main/webapp/messages.jsp Sun May  2 01:40:15 2010
@@ -0,0 +1,216 @@
+<%@ page session="false" contentType="text/html;charset=utf-8" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
+<html>
+
+<!--
+/*
+ * 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.
+ */
+//-->
+
+<%@ include file="inc/head.inc" %>
+
+<body>
+
+<f:view>
+
+<f:loadBundle basename="org.apache.myfaces.examples.resource.example_messages" var="example_messages"/>
+
+       <p>h:messages with layout="list" globalOnly="true"</p>
+       <h:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="true"/>
+                   
+       <p>t:messages with layout="list" globalOnly="true"</p>
+       <t:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="true"/>
+                   
+       <p>h:messages with layout="list" globalOnly="false"</p>
+       <h:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="false"/>
+
+       <p>t:messages with layout="list" globalOnly="false"</p>
+       <t:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="false"/>
+                   
+       <p>h:messages with layout="list" showDetail="true" showSummary="false"</p>
+       <h:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="false"/>
+
+       <p>t:messages with layout="list" showDetail="true" showSummary="false"</p>
+       <t:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="false"/>
+                   
+       <p>h:messages with layout="list" showDetail="true" showSummary="true"</p>
+       <h:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="true"/>
+
+       <p>t:messages with layout="list" showDetail="true" showSummary="true"</p>
+       <t:messages layout="list"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="true"/>
+                   
+       <p>h:messages with layout="table" globalOnly="true"</p>
+       <h:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="true"/>
+                   
+       <p>t:messages with layout="table" globalOnly="true"</p>
+       <t:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="true"/>
+                   
+       <p>h:messages with layout="table" globalOnly="false"</p>
+       <h:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="false"/>
+
+       <p>t:messages with layout="table" globalOnly="false"</p>
+       <t:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   globalOnly="false"/>
+                   
+       <p>h:messages with layout="table" showDetail="true" showSummary="false"</p>
+       <h:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="false"/>
+
+       <p>t:messages with layout="table" showDetail="true" showSummary="false"</p>
+       <t:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="false"/>
+                   
+       <p>h:messages with layout="table" showDetail="true" showSummary="true"</p>
+       <h:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="true"/>
+
+       <p>t:messages with layout="table" showDetail="true" showSummary="true"</p>
+       <t:messages layout="table"
+                   style="background:lightgreen"
+                   errorStyle="background:orange" 
+                   fatalStyle="background:red"
+                   infoStyle="background:yellow"
+                   warnStyle="background:lightblue"
+                   showDetail="true" showSummary="true"/>
+                   
+       <h:form id="mainForm">
+         <!-- With outputLabel no label -->
+         <h:panelGrid columns="3">
+            <h:outputLabel for="input1" value="#{example_messages['forceOne']}"/>
+            <h:inputText id="input1" required="true">
+                <f:validateLongRange minimum="0"/>
+            </h:inputText>
+            <h:message for="input1"/>
+         </h:panelGrid>
+         <!-- With outputLabel and label -->
+         <h:panelGrid columns="3">           
+            <h:outputLabel for="input2" value="Output Label 2"/>
+            <h:inputText id="input2" required="true">
+                <f:validateLongRange minimum="0"/>
+            </h:inputText>
+            <h:message for="input2"/>
+         </h:panelGrid>
+         <!-- With label and no outputLabel -->
+         <h:panelGrid columns="3">                       
+            <h:outputText value="Output Text 3"/>
+            <h:inputText id="input3" required="true">
+                <f:validateLongRange minimum="0"/>
+            </h:inputText>
+            <h:message for="input3"/>
+         </h:panelGrid>
+         <h:commandButton actionListener="#{messagesBean.printMessages}" value="Print Messages"/>
+       </h:form>
+
+<jsp:include page="inc/mbean_source.jsp"/>
+
+</f:view>
+
+<%@ include file="inc/page_footer.jsp" %>
+
+</body>
+
+</html>
\ No newline at end of file