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 h:commond button's action does'nt work 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 "h:commond button Watch "h:commond button New topic
Author

h:commond button's action does'nt work

ron thomas
Greenhorn

Joined: Apr 29, 2010
Posts: 3
Hi i am beginner in jsf i am trying to make a login application using JSF 1.2 with tiles,i stuck in commond button's action method,when i hit commond button nth happens can someone please help me out

here is my class file
package app;

import java.sql.SQLException;

import javax.naming.NamingException;

import Dao.Loginacess;

import javax.faces.*;

public class Login
{
String loginname="";
String password="";

public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

public String tp()
{
return "ttttppp";
}

public String checkValidUser() throws NamingException,SQLException
{
System.out.println("in method checkvalid user");

String dbpassword=null;

dbpassword = Loginacess.passwordcheck(loginname);

System.out.println("dbpassword==>"+dbpassword);
if(dbpassword.equals(password))
return "Sucess";
else
return "fail";
}
}
------------------------------------------------
faces config
<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<managed-bean>
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>app.Login</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>

</managed-bean>


</faces-config>
-----------------------------------------------
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>smartwin</display-name>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>TilesServet</servlet-name>
<servlet-class>org.apache.struts.tiles.TilesServlet</servlet-class>
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<init-param>
<param-name>definitions-parser-validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/smartwin</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
----------------------
login.jsp
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>

<f:view>



<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/smartwin/images/newcss.css">
<h:form id="loginform" >
<h:panelGrid columns="2" styleClass="topalign">
<hutputText styleClass="whitefont" value="User Name"/>
<h:inputText id="name" size="15" value="#{login.loginname}" />
<hutputText styleClass="whitefont" value="Password"/>
<h:inputText id="password" size="15" value="#{login.password}"/>
</h:panelGrid>
<h:commandButton value="submit" action="#{login.checkValidUser}" styleClass="topalignsub"/>
</h:form>

</f:view>
------------------
problem is action="#{login.checkValidUser}" when i hit submit button it does'nt go to checkValidUser method no message in console ,if i try to acess loginname i can but action does'nt work can someone please help

jar files
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
jsf-api.jar
jsf-impl.jar
jstl-1.2.jar
struts.jar
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
You have not specified any navigation rule in your faces-config.xml.
Hence it will not fire your action method. Please use code tags next time, it makes it easier to read code.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

"jsfron ron", please check your private messages for an important administrative matter.

Als, please read: UseCodeTags


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ron thomas
Greenhorn

Joined: Apr 29, 2010
Posts: 3
Hi Kavita thanks for your reply,i tried that but it's not working


@bear need full is done
Kavita Tipnis
Ranch Hand

Joined: Sep 21, 2008
Posts: 177
Check your logs for any errors and debugging your code should help catch what you are missing
ron thomas
Greenhorn

Joined: Apr 29, 2010
Posts: 3
I already checked log is clean ...same code works with JSF 1.1,is there any limitation of jsf 1.2 for tiles ??
Davie Lin
Ranch Hand

Joined: Aug 05, 2007
Posts: 294
insert a



in your commandButton and try that, that should work.

I only understand it has to do with the processing lifecycle, by why is it so behind in the lifecycle.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: h:commond button's action does'nt work
 
Similar Threads
JSF Spring integration
The requested resource () is not available
message /.jsp not found in JSF2.0+RichFaces3.3.3+Tomcat6.0.29
problem on JSF application
In Rich Faces rich:panelMenu a4j:commandButton action not called