- This topic has 9 replies, 3 voices, and was last updated 17 years, 4 months ago by Riyad Kalla.
-
AuthorPosts
-
DurnikMemberI’ve followed the tutorial as best I can and it’s ‘somewhat’ working. The only issue I have is that the error message (when the user enters an incorrect password) is not displaying. Note: I’m using MyFaces (but this code has nothing but the standard JSF components)
The UserBean error code is as follows:
———————————————————————————————–
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”;
}
———————————————————————————————-The userLogin.jsp page (relevant code) is as follows: Note: I’m using the MyFaces outputLable ‘values’ to add the label text
———————————————————————————————-
<body>
<f:view>
<f:loadBundle basename=”com.jsfdemo.MessageBundle” var=”bundle”/>
<h:form id=”loginForm” rendered=”true”>
<h:outputLabel value=”#{bundle.user_name_label}” rendered=”true” for=”userName” />
<h:inputText value=”#{UserBean.userName}” rendered=”true” required=”true” id=”userName” />
<h:outputLabel value=”#{bundle.user_password_label}” rendered=”true” for=”password” />
<h:inputSecret value=”#{UserBean.password}” rendered=”true” required=”true” redisplay=”false” id=”password” />
<h:commandButton value=”#{bundle.login_button_label}” rendered=”true” action=”#{UserBean.loginUser}” id=”submit” />
</h:form>
</f:view>
</body>
———————————————————————————————Now, the 2nd question is: If you were starting a new project (internal use, no hard
delivery date), would you start with the 5.x beta or would you work with the 4.1.1 version
and hope that your project is portable?Configuration Details
*** Date: Fri May 26 11:24:18 EDT 2006*** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_06*** MyEclipse details:
MyEclipse Enterprise WorkbenchVersion: 4.1.1 GA
Build id: 20060228-4.1.1-GA*** Eclipse details:
Eclipse SDKVersion: 3.1.1
Build id: M20050929-0840Eclipse Platform
Version: 3.1.1
Build id: M20050929-0840Eclipse RCP
Version: 3.1.1
Build id: M20050929-0840Eclipse Java Development Tools
Version: 3.1.1
Build id: M20050929-0840Eclipse Plug-in Development Environment
Version: 3.1.1
Build id: M20050929-0840Eclipse Project SDK
Version: 3.1.1
Build id: M20050929-0840Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
E:\Development\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
dc_68
-vm
C:\WINDOWS\system32\javaw.exe
Riyad KallaMemberThe problem is in the tutorial I forgot to add a “messages” component to the JSP page to display the actual message. Try adding a <h:messages /> component, you should see it.
Also, I would suggest staying with 4.1.1, the projects will be portable so it’s no biggie.
DurnikMemberRiyad,
My thanks for the pointer to the fix. I’m teaching myself web development (internal tool project) and learning MyEclipse at the same time and it can sometimes get a wee bit overwhelming. Are there any plans to update the documentation and tutorials to the latest rev of the tools? I keep running into options, screens and items that don’t appear in any documentation that I can find and it’s frustrating.
Riyad KallaMemberThere are going to be changes in MyEclipse 5.0 then 5.1 to really improve the Struts and JSF support, so we want to wait until the majority of the changes are done before rewriting those tutorials.
ylouMemberRiyad,
Could you please give a complete <h:message … />. I try
<h:messages for=”password” ></h:messages> and
<h:messages for=”loginForm” ></h:messages>
both times it failed.
type Exception reportmessage
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /userLogin.jsp(44,1) Attribute for invalid for tag messages according to TLD
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1198)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:819)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:838)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:838)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
org.apache.jasper.compiler.Validator.validate(Validator.java:1737)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:408)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:439)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:114)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)note The full stack trace of the root cause is available in the JBossWeb/2.0.0.GA logs.
Thanks.
ylou
Riyad KallaMemberylou can you post the entire JSP page for your page that is giving you problems?
ylouMemberRiyad,
Here is my userLogin.jsp:<%@ page language=”java” pageEncoding=”ISO-8859-1″%>
<%@ 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>
<meta http-equiv=”pragma” content=”no-cache”>
<meta http-equiv=”cache-control” content=”no-cache”>
<meta http-equiv=”expires” content=”0″>
<meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″>
<meta http-equiv=”description” content=”This is my page”>
<!–
<link rel=”stylesheet” type=”text/css” href=”styles.css”>
–></head>
<body>
<f:view>
<f:loadBundle basename=”com.jsfdemo.MessageBundle” var=”bundle”/>
<h:form rendered=”true” id=”loginForm”>
<h:outputLabel for=”userName” rendered=”true”>
<h:outputText escape=”false” rendered=”true” value=”#{bundle.user_name_label}”> </h:outputText>
</h:outputLabel>
<h:inputText id=”userName” required=”false” rendered=”true” value=”#{UserBean.userName}”></h:inputText>
<br>
<h:outputLabel for=”password” rendered=”true”>
<h:outputText escape=”false” rendered=”true” value=”#{bundle.user_password_label}”></h:outputText>
</h:outputLabel>
<h:inputSecret id=”password” redisplay=”false” required=”true” rendered=”true” value=”#{UserBean.password}”></h:inputSecret>
<br>
<h:commandButton id=”submit” action=”#{UserBean.loginUser}” rendered=”true” value=”#{bundle.login_button_label}”></h:commandButton>
<br>
<h:messages for=”password” ></h:messages>
<br><br></h:form>
</f:view>
</body>
</html>There is a warning for undefined attribute name (for) in line
<h:messages for=”password” ></h:messages>
Thanks.
ylou
Riyad KallaMemberylou,
That page actually looks fine… are you sure the project has JSF capabilities added to you? You can open your project properties and go to MyEclipse, then you can look at the icons… the lit-up icons should be the Web one and the JSF one.
ylouMemberRiyad,
Using <h:messages ></h:messages> will work. Remove s from messages in <h:messages for=”password” ></h:messages> will work for password error.
Another issue, I got three warning “bundle cannot be resolved” for
<h:outputText escape=”false” rendered=”true” value=”#{bundle.user_name_label}”> </h:outputText>
<h:outputText escape=”false” rendered=”true” value=”#{bundle.user_password_label}”></h:outputText>
<h:commandButton id=”submit” action=”#{UserBean.loginUser}” rendered=”true” value=”#{bundle.login_button_label}”></h:commandButton>If I restart myeclpise, these warning will go away. However if I made any change in the userLogin.jsp, these warning will come back.
Ylou
Riyad KallaMemberYlou,
The “bundle cannot be resolved” warning is incorrect and is a bug, it should be corrected soon.Also there are two tags:
h:message = Used to display a specific error message for a specific component
h:messages = Used to display all error messagesIf you want to use “for” you need to use the h:message tag.
-
AuthorPosts