Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSF
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
JSF
bean in JSP cannot be resolved
Songezo Nkukwana
Ranch Hand
Posts: 51
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
navigation rules are not working...
JSF Navigation Issue
JSF backingbean value is null always.
cannot forward to jsf page - unable to resolve jsf tag
initial page event
More...