Enclose your buttons in an <h:form> tag. 

-----Original Message-----
From: Matthias Klein [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 10, 2006 3:11 PM
To: users@myfaces.apache.org
Subject: [newbie]: click on commandButton does nothing. Why?

I am sure this is a super simple newbie problem, but would you mind
helping me? Thanks so much!

I wanted to start playing with MyFaces and JSF by building a tiny
application:
index.jsp simply forwards to menu.faces (which is the file menu.jsp) In
menu.jsp there is one little button leading to details.jsp In
details.jsp there are two buttons: one leading back to menu.jsp and one
leading to content.jsp content.jsp has a button to menu.jsp.

I can deploy everything in Tomcat 5.5 and call each page individually by
using the .faces suffix instead of their real file name suffix .jsp.

But here is the thing: when I click on any of those buttons, nothing
happens. Absolutely nothing. I have added a System.out... statement in
the method that is supposed to be called but that is not called either.

Do you have any idea what I did wrong?

Here some code:

-------------------------------------
Index.jsp
-------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
        <body>
                <jsp:forward page="/menu.faces" />
        </body>
</html>

-------------------------------------
Menu.jsp
-------------------------------------
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib
uri="http://java.sun.com/jsf/html"; prefix="h" %> <%@ taglib
uri="http://java.sun.com/jsf/core"; prefix="f" %> <f:view>
        <f:loadBundle
basename="ca.gc.nrc.iit.eConservatoire.frontend.bundles.MessageBundle"
var="bundle" />

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <html>
                <head>
                        <title><h:outputText
value="#{bundle.menu_frame}" /></title>
                </head>

                <body>

                        menu<br>
//                      <h:commandButton value="Weiter" rendered="true"
action="#{MenuBackingBean.userClick}" />
        <h:commandButton value="Weiter" rendered="true"
action="showDetails" />
                </body>
        </html>
</f:view>

-------------------------------------
Details.jsp
-------------------------------------
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib
uri="http://java.sun.com/jsf/html"; prefix="h" %> <%@ taglib
uri="http://java.sun.com/jsf/core"; prefix="f" %> <f:view>
        <f:loadBundle
basename="ca.gc.nrc.iit.eConservatoire.frontend.bundles.MessageBundle"
var="bundle" />

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <html>
                <head>
                        <title><h:outputText
value="#{bundle.details_frame}" /></title>
                </head>

                <body>

                        <h:panelGrid columns="2">
                                <h:outputText
value="#{bundle.details_title}" />
                                <h:outputText
value="#{DetailsBackingBean.title}" />
                                <h:outputText
value="#{bundle.details_author}" />
                                <h:outputText
value="#{DetailsBackingBean.author}" />
                        </h:panelGrid>

                        <h:commandButton
value="#{bundle.details_startbutton}." rendered="true"
action="#{DetailsBackingBean.showContent}" />
                        <h:commandButton
value="#{bundle.details_backbutton}" rendered="true"
action="#{DetailsBackingBean.showMenu}" />

                </body>
        </html>
</f:view>

-------------------------------------
Content.jsp
-------------------------------------
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib
uri="http://java.sun.com/jsf/html"; prefix="h" %> <%@ taglib
uri="http://java.sun.com/jsf/core"; prefix="f" %> <f:view>
        <f:loadBundle
basename="ca.gc.nrc.iit.eConservatoire.frontend.bundles.MessageBundle"
var="bundle" />

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <html>
                <head>
                        <title><h:outputText
value="#{bundle.content_frame}" /></title>
                </head>

                <body>

                        content<br>
                        <h:commandButton
value="#{bundle.content_backbutton}" rendered="true"
action="#{ContentBackingBean.showMenu}" />

                </body>
        </html>
</f:view>

-------------------------------------
Faces-config.xml
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer
Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd";>

<faces-config >

        <application>
                <locale-config>
                        <default-locale>en</default-locale>
                        <supported-locale>en</supported-locale>
                        <supported-locale>de</supported-locale>
                </locale-config>
        
<message-bundle>ca.gc.nrc.iit.eConservatoire.frontend.bundles.MessageBun
dle</message-bundle>
        </application>

        <managed-bean>
        
<managed-bean-name>DetailsBackingBean</managed-bean-name>
        
<managed-bean-class>ca.gc.nrc.iit.eConservatoire.frontend.DetailsBacking
Bean</managed-bean-class>
                <managed-bean-scope>session</managed-bean-scope>
                <managed-property>
                        <description>Title of the Learning
Object</description>
                        <property-name>title</property-name>
        
<property-class>java.lang.String</property-class>
                        <value></value>
                </managed-property>
                <managed-property>
                        <description>Author of the Learning
Object</description>
                        <property-name>author</property-name>
        
<property-class>java.lang.String</property-class>
                        <value></value>
                </managed-property>
        </managed-bean>

        <managed-bean>
                <managed-bean-name>MenuBackingBean</managed-bean-name>
        
<managed-bean-class>ca.gc.nrc.iit.eConservatoire.frontend.MenuBackingBea
n</managed-bean-class>
                <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
        <managed-bean>
        
<managed-bean-name>ContentBackingBean</managed-bean-name>
        
<managed-bean-class>ca.gc.nrc.iit.eConservatoire.frontend.ContentBacking
Bean</managed-bean-class>
                <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>

        <navigation-rule>
                <from-view-id>/menu.jsp</from-view-id>
                <navigation-case>
                        <from-outcome>showDetails</from-outcome>
                        <to-view-id>/details.jsp</to-view-id>
                </navigation-case>
                <navigation-case>
                        <from-outcome>menu</from-outcome>
                        <to-view-id>/menu.jsp</to-view-id>
                </navigation-case>
        </navigation-rule>
        <navigation-rule>
                <from-view-id>/details.jsp</from-view-id>
                <navigation-case>
                        <from-outcome>showMenu</from-outcome>
                        <to-view-id>/menu.jsp</to-view-id>
                </navigation-case>
                <navigation-case>
                        <from-outcome>showContent</from-outcome>
                        <to-view-id>/content.jsp</to-view-id>
                </navigation-case>
        </navigation-rule>
        <navigation-rule>
                <from-view-id>/content.jsp</from-view-id>
                <navigation-case>
                        <from-outcome>showMenu</from-outcome>
                        <to-view-id>/menu.jsp</to-view-id>
                </navigation-case>
        </navigation-rule>
</faces-config>


-------------------------------------
Web.xml
-------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
  <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
  </context-param>
  <listener>
 
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener<
/listener-class>
  </listener>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
  <filter>
    <filter-name>MyFacesExtensionsFilter</filter-name>
 
<filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</f
ilter-class>
    <init-param>
      <param-name>maxFileSize</param-name>
      <param-value>20m</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>*.faces</url-pattern>
  </filter-mapping>
</web-app>




Reply via email to