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/07 00:18:28 UTC

svn commit: r941954 - in /myfaces/current12/test-webapp/src/main: java/org/apache/myfaces/commandParams/ java/org/apache/myfaces/commandParams/CommandParamBean.java webapp/WEB-INF/examples-config.xml webapp/commandParams.jsp

Author: lu4242
Date: Thu May  6 22:18:28 2010
New Revision: 941954

URL: http://svn.apache.org/viewvc?rev=941954&view=rev
Log:
MYFACES-2463 CLONE -<f:param> violates the JSF spec (example)

Added:
    myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/commandParams/
    myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/commandParams/CommandParamBean.java
    myfaces/current12/test-webapp/src/main/webapp/commandParams.jsp
Modified:
    myfaces/current12/test-webapp/src/main/webapp/WEB-INF/examples-config.xml

Added: myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/commandParams/CommandParamBean.java
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/commandParams/CommandParamBean.java?rev=941954&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/commandParams/CommandParamBean.java (added)
+++ myfaces/current12/test-webapp/src/main/java/org/apache/myfaces/commandParams/CommandParamBean.java Thu May  6 22:18:28 2010
@@ -0,0 +1,85 @@
+/*
+ * 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.commandParams;
+
+import javax.annotation.PostConstruct;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
+ * 
+ * @author <a href="mailto:matzew@apache.org">Matthias Weßendorf</a>
+ */
+public class CommandParamBean {
+
+    private static Log log = LogFactory.getLog(CommandParamBean.class);
+    
+    private String greeting;
+    
+    private String param1;
+
+    public CommandParamBean()
+    {
+        greeting = "Hello";
+    }
+    
+    @PostConstruct
+    public void init()
+    {
+        FacesContext context = FacesContext.getCurrentInstance();
+        ExternalContext ex = context.getExternalContext();    
+     
+        if (ex != null && 
+            ex.getRequestParameterMap() != null && 
+            ex.getRequestParameterMap().containsKey("param1")) {
+          setParam1((String)ex.getRequestParameterMap().get("param1"));
+       }        
+    }
+    
+    public String getGreeting()
+    {
+        return greeting;
+    }
+
+    public void setGreeting(String greeting)
+    {
+        this.greeting = greeting;
+    }
+    
+
+    public String getParam1()
+    {
+        return param1;
+    }
+
+    public void setParam1(String param1)
+    {
+        this.param1 = param1;
+    }
+
+    public void updateGreeting(ActionEvent evt)
+    {
+        greeting = "Bye!";
+    }
+}
\ No newline at end of file

Modified: myfaces/current12/test-webapp/src/main/webapp/WEB-INF/examples-config.xml
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/webapp/WEB-INF/examples-config.xml?rev=941954&r1=941953&r2=941954&view=diff
==============================================================================
--- myfaces/current12/test-webapp/src/main/webapp/WEB-INF/examples-config.xml (original)
+++ myfaces/current12/test-webapp/src/main/webapp/WEB-INF/examples-config.xml Thu May  6 22:18:28 2010
@@ -144,6 +144,13 @@
   <managed-bean-class>org.apache.myfaces.selectItem.SelectItemEscapeBean</managed-bean-class>
   <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
+ <managed-bean>
+  <managed-bean-name>commandParamBean</managed-bean-name>
+  <managed-bean-class>org.apache.myfaces.commandParams.CommandParamBean</managed-bean-class>
+  <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+
+ 
  <!-- navigation rules for helloWorld.jsp -->
  <navigation-rule>
   <from-view-id>/helloWorld.jsp</from-view-id>

Added: myfaces/current12/test-webapp/src/main/webapp/commandParams.jsp
URL: http://svn.apache.org/viewvc/myfaces/current12/test-webapp/src/main/webapp/commandParams.jsp?rev=941954&view=auto
==============================================================================
--- myfaces/current12/test-webapp/src/main/webapp/commandParams.jsp (added)
+++ myfaces/current12/test-webapp/src/main/webapp/commandParams.jsp Thu May  6 22:18:28 2010
@@ -0,0 +1,60 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<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.
+ */
+//-->
+    <head>
+        <title>Hello World</title>
+    </head>
+
+    <body>
+        <f:view>
+            <h:form id="form1">
+              <h:panelGrid id="grid1" columns="2">
+                <h:outputText value="#{commandParamBean.greeting}"/>
+                <h:commandLink value="Update greeting" actionListener="#{commandParamBean.updateGreeting}">
+                    <f:param name="param1" value="value1"/>
+                </h:commandLink>
+                <h:commandButton value="Update greeting" actionListener="#{commandParamBean.updateGreeting}"/>
+              </h:panelGrid>
+            </h:form>
+            <h:form id="form2">
+              <h:panelGrid id="grid2" columns="2">
+                <h:outputText value="#{commandParamBean.greeting}"/>
+                <h:commandLink value="Update greeting" actionListener="#{commandParamBean.updateGreeting}">
+                    <f:param name="param1" value="value2"/>
+                </h:commandLink>
+                <h:commandButton value="Update greeting" actionListener="#{commandParamBean.updateGreeting}"/>
+              </h:panelGrid>
+            </h:form>
+            <h:outputLink value="BusinessObjectPropertySummary">
+               <f:param name="buisnessObjectClass" value="&amp;ñ&Ñ"/>
+               <h:outputText value="businessObjectDetails.name"/>
+            </h:outputLink>
+            
+            <h:panelGrid id="grid" columns="2">
+                <h:outputLabel for="showParam1" value="Parameter 1"/>
+                <h:outputText id="showParam1" value="#{commandParamBean.param1}"/>
+            </h:panelGrid>
+        </f:view>
+        <%@include file="inc/page_footer.jsp" %>
+    </body>
+</html>