Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Help. commandButton does not invoke Bean's method.

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic