wood burning stoves 2.0*
The moose likes JSF and the fly likes Help. commandButton does not invoke Bean's method. 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 "Help. commandButton does not invoke Bean Watch "Help. commandButton does not invoke Bean New topic
Author

Help. commandButton does not invoke Bean's method.

Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
my commandButton does not work�

Please advise me what am I doing wrong? My command button does not invoke method in Bean. System.out.println() would not print message in submit() method.

In jsp page:

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<h:commandButton action="#{ServicesBackingBean.submit}" value="#{bundle.addNewlySoldServiceButtonValue}" id="submit"/>

In faces-config.xml:

<faces-config>
<managed-bean>
<managed-bean-name>ServicesBackingBean</managed-bean-name>
<managed-bean-class>
com.softlets.projects.travelcards.beans.ServicesBackingBean
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<navigation-rule>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/in.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>



In ServicesBackingBean.java:


Setters and getters
�.

public String submit()
{
System.out.println(" ************ I am here in submit() method ********* ");
return �success�;
}
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
My Netbeans gives me some messages. Maybe it might help you to get an ideas.

When added an id to HTML Form tag and JSF message for form id I started getting some messages in Netbeans.

Here are my HTML FORM details:

<form id="submitForm">
.
.
.
<td><h:inputText value="#{ServicesBean.serviceName}" id="serviceName" size="50"/></td>
.
.
.
<h:commandButton action="#{ServicesBean.addService}" value="#{bundle.addNewlySoldServiceButtonValue}" id="submitButton"/>
</form>

<h:message for="submitForm"/>

Here are NetBeans Messages:

WARNING: Unable to find component with ID 'submitForm' in view.
18.12.2006 12:09:29 com.sun.faces.el.impl.Coercions applyArithmeticOperator
WARNING: Attempt to apply operator "-" to null value
18.12.2006 12:09:29 com.sun.faces.el.impl.Coercions applyArithmeticOperator
WARNING: Attempt to apply operator "-" to null value
18.12.2006 12:09:35 com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
WARNING: Unable to find component with ID 'submitForm' in view.


Thank you.
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
I was able to fix the problem with invoking Bean's method.

I should have used <h:form> instead of <form> tag. This was the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help. commandButton does not invoke Bean's method.
 
Similar Threads
navigation rules are not working...
commandLink param problem
inputText tag not working properly
Arraylist in bean cant be displayed in jsp
New to JSF..Please help