Help. commandButton does not invoke Bean's method.

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"%>

<form id="submitForm">

.

.

.

<h:inputText value="#{ServicesBean.serviceName}" id="serviceName" size="50"/>

.

.

.

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

</form>

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:

?br>Setters and getters

?

public String submit()

{

System.out.println(" ************ I am here in submit() method ********* ");

return 搒uccess?

}

[1550 byte] By [serezhkaa] at [2007-11-26 12:53:35]
# 1

I wonder if you're experiencing the html bug in MyFaces.

Essentially your html tags, like <form> will be stripped out and rendered last after your jsf inputs and buttons have already been rendered.

try using <h:form> instead of <form> or wrapping verbatim tags around your html code.

Longbottoma at 2007-7-7 16:44:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Indeed, you have to use h:form instead.
BalusCa at 2007-7-7 16:44:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Thank you very much!Using <h:form> instead of <form> helped. It works now. Thank you.
serezhkaa at 2007-7-7 16:44:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

hi,

if you're using form instead of h:form, you're telling jsf to not include a UIForm in your component tree which is very annoying!

Since for buttons and links jsf (at least for 1.1_02 ri) uses javascript code having dependency on the UIForm rendering to handle onclick events, if you don't render the UIForm you're stucked!

trevorijonesa at 2007-7-7 16:44:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
> which is very annoying!> ...> you're stucked!Why are you telling that so hard? Just use h:form instead and no matters further :)
BalusCa at 2007-7-7 16:44:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Sorry, i didn't mean to be rude.I was just trying to explain why we should use <h:form> instead of <form>
trevorijonesa at 2007-7-7 16:44:18 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...