30 Jan 2009, 13:24
Generic-user-small

Gavin Eugene Meyers (6 posts)

Hi Frederic, I have just reached Chapter 8 & 9 of your book. I am facing a few problems with the code for the email client you provided.
When I try to display a single email message by clicking on the subject link, I get the form displayed with blank data fields.

For some reason the get “message” field in the MessageDetailsActionBean is not getting set to the clicked message. I tried some println statements and confirmed that….it prints null for the message field.

The same is the problem when trying to delete a few messages. The “selectedMessages” field is not getting set to the selected messages, and I get a NullPointerException on the browser.

And in the layout_folder.jsp the folder names are not getting displayed as links.

I have used the code as is provided from the site from folders “email_01” to “email_20”

Please help me solve these problems.

Thanks Gavin

01 Feb 2009, 05:21
Freddy_avatar_pragsmall

Fred Daoud (21 posts)

Hi Gavin,

I just downloaded the code from http://www.pragprog.com/titles/fdstr/source_code and tried the “email_20” example and it works, I do not see the problems that you are describing.

If you downloaded the code a while ago, try downloading the latest version. If you already have a recent version and are still having problems, please describe your environment: OS, servlet container version, JDK version. Are you using an IDE to run the code?

With that information I’ll do my best to try to help.

Cheers Frederic

02 Feb 2009, 06:44
Generic-user-small

Gavin Eugene Meyers (6 posts)

Hi Frederic, I am using the latest code. But I am still facing the same problems. I am using Netbeans 6.5 IDE, my OS is Fedora Linux 6, Servlet container is Tomcat 6.0.18(comes bundled with netbeans) and JDK version is 1.6.0_10

Thanks Gavin

02 Feb 2009, 20:20
Freddy_avatar_pragsmall

Fred Daoud (21 posts)

I just tried the same configuration as yours, save for using Ubuntu Linux 8.04 - but that shouldn’t make much difference. I don’t know what the problem could be. Try running the Ant ‘build’ target and copying the dist/email_20.war file to your Tomcat installation’s webapp/ directory, then start Tomcat and use http://localhost:8080/email_20 with ‘freddy’ as the primary email and ‘nadia’ as the password to login.

04 Feb 2009, 08:12
Generic-user-small

Gavin Eugene Meyers (6 posts)

I have not solved the above problems as yet…working on it still….but I have a doubt regarding the ActionBeanContext class.

you have recommended that we subclass ActionBeanContext (MyActionBeanContext) in order to access HttpSession etc., so that it is typesafe.

I would like to know when are the getXXX() and setXXX() methods of the MyActionBeanContext called during the lifecycle of a request. I tried tracing the flow by inserting print statements in the get and set methods…but only the get method print statements are printed.

In the context of the Email app,for eg, when a user logs in, his username/password is validated, then control passes on to the MessageListActionBean which simply forwards it to the message_list jsp. When displaying the jsp the EL accesses the get methods.

When will the MyActionBeanContext’s set method(s) be called and populated? and by whom?

Thanks Gavin

04 Feb 2009, 22:25
Freddy_avatar_pragsmall

Fred Daoud (21 posts)

Starting in email_23, the login() method of LoginActionBean calls getContext().setUser(user). That’s where the user gets set in the session and is accessible via getContext().getUser() or ${actionBean.context.user}. In email_34, LoginInterceptor checks that the user is logged in and redirects to the login page if the user is not logged in.

Hope that helps.

Cheers, Freddy

05 Feb 2009, 11:26
Generic-user-small

Gavin Eugene Meyers (6 posts)

Thanks a lot for all the help.

I finally got the email app working. Was a good learning experience.

Thanks again Gavin

  You must be logged in to comment