NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
MikePhoenix
Joined: 19 May 2009 Posts: 30
|
Posted: Tue Sep 15, 2009 11:16 pm Post subject: problems getting JSF to work on NB 6.7.1 |
|
|
OK, I set up a JSF project on NB 6.7.1 and for some reason when I click on the button to execute an action (loggedon.authenticate), nothing happens except the form clears. I try to debug and it appears that the method in the bean loggedon (LogonBean,java) is never even entered. I've looked over the project and cannot figure out what is going on. I really could use some help here. The important pieces of code are below:
web.xml
| Code: |
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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-app_2_5.xsd">
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</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-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/welcomeJSF.jsp</welcome-file>
</welcome-file-list>
</web-app>
|
faces-config.xml
| Code: |
<?xml version='1.0' encoding='UTF-8'?>
<!-- =========== FULL CONFIGURATION FILE ================================== -->
<faces-config version="1.2"
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">
<managed-bean>
<managed-bean-name>loggedon</managed-bean-name>
<managed-bean-class>com.lingosys.quoteestimator.LogonBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/logon.jsp</from-view-id>
<navigation-case>
<from-outcome>loggedon</from-outcome>
<to-view-id>/request.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>returnce</from-outcome>
<to-view-id>/costestimator.jsp</to-view-id>
<redirect/>
</navigation-case>
<navigation-case>
<from-outcome>returnjas</from-outcome>
<to-view-id>/jasgenerator.jsp</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
</faces-config>
|
logon.jsp
| Code: |
<%--
Document : logon
Created on : Sep 14, 2009, 3:31:40 PM
Author : mphoenix
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Quote Estimator Logon</title>
</head>
<body>
<f:view>
<h1>Quote Estimator Logon</h1>
<p/>
<h:form id="generateForm" enctype="multipart/form-data" >
<p/>Both fields are required.
<p/>Enter User ID: <h:inputText id="uid" value="#{loggedon.uid}" required="true"/>
<p/>Enter Password: <h:inputSecret id="password" required="true"
value="#{loggedon.password}"/>
<p/><h:commandButton value="Logon" action="#{loggedon.authenticate}"/>
<p/><h:messages showDetail="true" showSummary="true"/>
</h:form>
</f:view>
</body>
</html>
|
LogonBean.java
| Code: |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.lingosys.quoteestimator;
import com.lingosys.hibernate.quoteest.User;
import com.lingosys.hibernate.quoteest.UserDao;
import com.lingosys.password.PasswordProcessor;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
/**
*
* @author mphoenix
*/
public class LogonBean {
private String uid = null;
private String password = null;
private boolean admin = false;
private boolean authenticated = false;
public LogonBean() {
}
public boolean getAuthenticated() {
return authenticated;
}
public void setAuthenticated(boolean authenticated) {
this.authenticated = authenticated;
}
public boolean getAdmin() {
return admin;
}
public void setAdmin(boolean admin) {
this.admin = admin;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String authenticate() throws NoSuchAlgorithmException, NoSuchAlgorithmException, UnsupportedEncodingException {
UserDao dao = new UserDao();
User user = dao.find(getUid());
PasswordProcessor pp = PasswordProcessor.getInstance();
if (pp.encrypt(getPassword()).equals(user.getPassword())) {
setAuthenticated(true);
if (user.getAdmin() == 'Y')
setAdmin(true);
return "loggedon";
}
else {
FacesContext.getCurrentInstance().
addMessage(null, new FacesMessage("Incorrect user ID and/or password, please try again."));
return "failed";
}
}
}
|
|
|
| Back to top |
|
 |
Futaleufu_John Posted via mailing list.
|
Posted: Wed Sep 16, 2009 1:08 pm Post subject: problems getting JSF to work on NB 6.7.1 |
|
|
All my page beans extend from AbstractPageBean. LogonBean doesn't.
Page beans (also known as request beans) have to have certain methods such
as init, preprocess and prerender.
How did you create the JSF page? Through the IDE? Manually?
When the IDE creates a new JSF page the corresponding page bean is also
created.
You can "manually" create a page bean as follows:
1. Right-click and selct New|Other to open New File dialog
2. Select JavaServer Faces category and select Visual Web JSF Request
Bean. Click Next.
3. Enter the name for this request bean and click Finish.
BTW, I am using NB 6.7 with Visual JSF, Visual JSF Runtime and Visual Web
JSF Backwards Compatibility Kit.
MikePhoenix wrote:
| Quote: |
OK, I set up a JSF project on NB 6.7.1 and for some reason when I click on
the button to execute an action (loggedon.authenticate), nothing happens
except the form clears. I try to debug and it appears that the method in
the bean loggedon (LogonBean,java) is never even entered. I've looked over
the project and cannot figure out what is going on. I really could use
some help here.
<managed-bean>
<managed-bean-name>loggedon</managed-bean-name>
<managed-bean-class>com.lingosys.quoteestimator.LogonBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
public class LogonBean {
}
|
-----
Any ads or links to ads that appear in this post are not endorsed nor
recommended by this poster.
--
View this message in context: http://www.nabble.com/problems-getting-JSF-to-work-on-NB-6.7.1-tp25467123p25472049.html
Sent from the Netbeans - J2EE mailing list archive at Nabble.com. |
|
| Back to top |
|
 |
MikePhoenix
Joined: 19 May 2009 Posts: 30
|
Posted: Wed Sep 16, 2009 5:32 pm Post subject: |
|
|
| Quote: | BTW, I am using NB 6.7 with Visual JSF, Visual JSF Runtime and Visual Web
JSF Backwards Compatibility Kit. |
Are these all available plugins? I don't recall seeing them in the plugin list. |
|
| Back to top |
|
 |
MikePhoenix
Joined: 19 May 2009 Posts: 30
|
Posted: Wed Sep 16, 2009 5:37 pm Post subject: |
|
|
| Also, I have written previous applications not using backing beans that did not contain AbstractPageBean as you described and they worked fine. |
|
| Back to top |
|
 |
Futaleufu_John Posted via mailing list.
|
|
| Back to top |
|
 |
Jeff Rubinoff Posted via mailing list.
|
Posted: Thu Sep 17, 2009 2:46 pm Post subject: problems getting JSF to work on NB 6.7.1 |
|
|
They are available as development plugins on the nightly build.
Futaleufu_John wrote: |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|