• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

h:commond button's action does'nt work

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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">
<h:outputText styleClass="whitefont" value="User Name"/>
<h:inputText id="name" size="15" value="#{login.loginname}" />
<h:outputText 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
 
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"jsfron ron", please check your private messages for an important administrative matter.

Als, please read: UseCodeTags
 
ron thomas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavita thanks for your reply,i tried that but it's not working


@bear need full is done
 
Kavita Tipnis
Ranch Hand
Posts: 177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your logs for any errors and debugging your code should help catch what you are missing
 
ron thomas
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I already checked log is clean ...same code works with JSF 1.1,is there any limitation of jsf 1.2 for tiles ??
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic