File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
JSF
Author
bean in JSP cannot be resolved
Songezo Nkukwana
Ranch Hand
Joined: Nov 27, 2008
Posts: 51
posted
Feb 16, 2009 01:25:00
0
My first tutorial on
JSF
... I get a warning om my
JSP
file using JSF tags ...
userLogin.jsp
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSF 'userLogin.jsp' starting page</title> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <f:view> <f:loadBundle basename="com.jsfdemo.MessageBundle" var="bundle"/> <h:form id="loginForm" rendered="true"> <h:panelGrid> <h:outputLabel rendered="true" for="userName"> <h:outputText value="#{bundle.user_name_label}" /> </h:outputLabel> <h:inputText value="#{UserBean.userName}" rendered="true" required="true" id="userName" /> </h:panelGrid> <br> <h:panelGrid> <h:outputLabel rendered="true" for="password"> <h:outputText value="#{bundle.user_password_label}" /> </h:outputLabel> <h:inputSecret value="#{UserBean.password}" rendered="true" required="true" redisplay="false" id="password" /> </h:panelGrid> <br> <h:commandButton value="#{bundle.login_button_label}" rendered="true" action="#{UserBean.loginUser}" id="submit" /> </h:form> </f:view> </body> </html>
I get a yellow exclamation mark which complains on all UserBean that "UserBean cannot be resolved" ...
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"> <faces-config > <managed-bean> <managed-bean-name>UserBean</managed-bean-name> <managed-bean-class> com.jsfdemo.bean.UserBean </managed-bean-class> <managed-bean-scope>session</managed-bean-scope> <managed-property> <property-name>userName</property-name> <property-class>java.lang.String</property-class> <value></value> </managed-property> <managed-property> <property-name>password</property-name> <property-class>java.lang.String</property-class> <value></value> </managed-property> </managed-bean> <navigation-rule> <from-view-id>/userLogin.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/userLoginSuccess.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>failure</from-outcome> <to-view-id>/userLogin.jsp</to-view-id> </navigation-case> </navigation-rule> <navigation-rule> <from-view-id>/userLoginSuccess.jsp</from-view-id> </navigation-rule> </faces-config>
UserBean
package com.jsfdemo.bean; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; /** * @author Riyad * */ public class UserBean { //extends Object { private String password; private String userName; public UserBean() { } /** * @return Returns the password. */ public String getPassword() { return password; } /** * @param password The password to set. */ public void setPassword(String password) { this.password = password; } /** * @return Returns the userName. */ public String getUserName() { return userName; } /** * @param userName The userName to set. */ public void setUserName(String userName) { this.userName = userName; } public String loginUser() { if("myeclipse".equals(getUserName()) && "myeclipse".equals(getPassword())) return "success"; FacesContext facesContext = FacesContext.getCurrentInstance(); FacesMessage facesMessage = new FacesMessage( "You have entered an invalid user name and/or password"); facesContext.addMessage("loginForm", facesMessage); return "failure"; } }
Maybe the scope problem, or maybe MyEclipse related issues ???
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
Feb 16, 2009 05:23:06
0
It's just a warning, not an error. Just run it. Does it work? No worries then.
An IDE is just a tool, not some magic.
Code depot of a Java EE / JSF developer
|
JSF / Eclipse / Tomcat kickoff tutorial
|
DAO kickoff tutorial
|
I ♥ Unicode
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: bean in JSP cannot be resolved
Similar Threads
JSF Navigation Issue
initial page event
cannot forward to jsf page - unable to resolve jsf tag
navigation rules are not working...
JSF backingbean value is null always.
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter