This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Action method is never entered/executed.  Please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Action method is never entered/executed.  Please help" Watch "Action method is never entered/executed.  Please help" New topic
Author

Action method is never entered/executed. Please help

Tokunbo Oke
Ranch Hand

Joined: Sep 09, 2003
Posts: 57
After submission, status.jsp goes through all phases successfully, but never enters/executes the action method i.e. #{statusManagedBean.createStatusAction}, can anyone please suggest any reason that could be the cause.

Please see code below:

JSF - status.jsp
================
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<f:loadBundle basename="com.fujimitsu.moneytransfer.resources.UIResources" var="bundle"/>
<html>
<f:view>
<head>
<title><hutputText value="#{bundle.registerStatus}"/> </title>
<link href="../css/stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<f:verbatim><p>JavaServer Faces Page</p>
<p>
</p><table border="0" cellpadding="0" cellspacing="0" width="800">
<tr>
<td>
<h:graphicImage url="/images/resources.jpg" alt="#{bundle.img_alt_info}"/>
</td>
</tr>

<tr>
<td>
<h:messages globalOnly="false" styleClass="validationMessage" layout="table"/>
<p>
<h:form id="statusManagedBeanForm">
<h:panelGrid columns="3">
<hutputText value="#{bundle['statusField.status']}"/>
<h:inputText id="status" value="#{statusManagedBean.status}"/>
<h:message for="status" styleClass="validationMessage"/>
<hutputText value="#{bundle['statusDescField.statusDesc']}"/>
<h:inputText id="statusDesc" value="#{statusManagedBean.statusDesc}"/>
<h:message for="statusDesc" styleClass="validationMessage"/>
<hutputText value="Created By:"/>
<h:inputText id="createdBy" binding="#{statusManagedBean.createdBy}"/>
<h:message for="createdBy" styleClass="validationMessage"/>
</h:panelGrid>
<h:commandButton action="#{statusManagedBean.createStatusAction}" type="submit" value="Submit"/>
</h:form>
</p>
</td>
</tr>
</table>

</f:verbatim>

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




HTML code of status.jsp before the submit button is clicked
===========================================
<form id="statusManagedBeanForm" name="statusManagedBeanForm" method="post" action="/moneytransferFaces/pages/status.jsf" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="statusManagedBeanForm" value="statusManagedBeanForm" />
<table>
<tbody>
<tr>
<td>Status</td>
<td><input id="statusManagedBeanForm:status" type="text" name="statusManagedBeanForm:status" /></td>
<td></td>
</tr>
<tr>
<td>Status Desc</td>
<td><input id="statusManagedBeanForm:statusDesc" type="text" name="statusManagedBeanForm:statusDesc" /></td>
<td></td>
</tr>
<tr>
<td>Created By:</td>
<td><input id="statusManagedBeanForm:createdBy" type="text" name="statusManagedBeanForm:createdBy" /></td>
<td></td>
</tr>
</tbody>
</table>
<input type="submit" name="statusManagedBeanForm:j_id_jsp_948632549_16" value="Submit" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id4:j_id5" />
</form>





HTML code of status.jsp after the submit button is clicked
==========================================
Please note: action="/moneytransferFaces/pages/status.jsf" , is this what it is supposed to be?
<form id="statusManagedBeanForm" name="statusManagedBeanForm" method="post" action="/moneytransferFaces/pages/status.jsf" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="statusManagedBeanForm" value="statusManagedBeanForm" />
<table>
<tbody>
<tr>
<td>Status</td>
<td><input id="statusManagedBeanForm:status" type="text" name="statusManagedBeanForm:status" /></td>
<td></td>
</tr>
<tr>
<td>Status Desc</td>
<td><input id="statusManagedBeanForm:statusDesc" type="text" name="statusManagedBeanForm:statusDesc" /></td>
<td></td>
</tr>
<tr>
<td>Created By:</td>
<td><input id="statusManagedBeanForm:createdBy" type="text" name="statusManagedBeanForm:createdBy" /></td>
<td></td>
</tr>
</tbody>
</table>
<input type="submit" name="statusManagedBeanForm:j_id_jsp_948632549_16" value="Submit" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id1:j_id3" />
</form>


STATUS BEAN
===========
package com.fujimitsu.moneytransfer.beans;

import javax.faces.component.html.HtmlInputText;

public class Status {
private String status;
private String statusDesc;
private HtmlInputText createdBy;

public Status() {
}

public HtmlInputText getCreatedBy() {
return createdBy;
}

public void setCreatedBy(HtmlInputText createdBy) {
this.createdBy = createdBy;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}

public String getStatusDesc() {
return statusDesc;
}

public void setStatusDesc(String statusDesc) {
this.statusDesc = statusDesc;
}

public String createStatusAction() {
this.setStatusDesc("testing createStatusAction()...");

return "success";
}

}




FACES CONFIG
============
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2003 Sun Microsystems, Inc. All rights reserved.
SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
-->
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">

<faces-config>
<application>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
</application>
<managed-bean>
<managed-bean-name>statusManagedBean</managed-bean-name>
<managed-bean-class>
com.fujimitsu.moneytransfer.beans.Status
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/status.jsf</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/home.jsf</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/pages/status.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/pages/home.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<lifecycle>
<phase-listener>
com.fujimitsu.moneytransfer.utils.PrintTreePhaseListener
</phase-listener>
</lifecycle>
</faces-config>


web.xml
======
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>

<!--A short name that is intended to be displayed by tools.-->
<display-name>The simplest JSF application.</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>

</web-app>

DIRECTORY STRUCTURE
====================
appName
pages
WEB-INF
.........
.........

Thanks.
Venkat Sadasivam
Ranch Hand

Joined: May 10, 2008
Posts: 139
Common issue in invoking action methods are:
a) wrong EL expression
b) Validation/ Conversion error while submitting the form. Include <h:messages /> in top of the page to see the errors.


“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
Chandan Rajan
Greenhorn

Joined: Apr 25, 2008
Posts: 10
After the request is processed does the view stay back in status.jsp or does it move elsewhere?

Can you check if statusManagedBean.setStatus(), statusManagedBean.setStatusDesc(), statusManagedBean.setCreatedBy() are getting invoked?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action method is never entered/executed. Please help
 
Similar Threads
newbie null reference exception
Simple form: inputText does not reset
"#{...} is not allowed in template text" error
My Tomcat does not build my URL
Problems with running JSF in Eclipse 3.1