• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

html:select problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I'm trying to make a menu selection with struts 1.1 but I get the message "Property list returned a null value".
Please, where is the problem??

Here the code:


--------SelectionForm.java-------------



-----------SelectionAction.java---------------



I write also my Model code:

------users.java-----



Here my struts-config.xml file:


About html ption tag, I also tried with the collection attribute, but I got the message "Cannot find bean under name list".

Can anyone help me please? I'm spending too many days on this problem!!

Thank you in advance.

fpia
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Change:

to:
 
Fabrizio Pia
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I tried, but I got
"Failed to obtain specified collection"

Any suggestion please?
Fpia
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way you've got it set up, the SelectionAction only runs after the form has already been submitted. You need to have an action that runs before the JSP is displayed so that it can load the list into the ActionForm.

I'd suggest you create a new Action called something like "/prepareSelection" that uses the same ActionForm and forwards to this JSP. Then cut the code that loads the list from the SelectionAction and paste it into this new action. You would then display the page using a URL something like:
 
Fabrizio Pia
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
thank you. I understand what you mean.
Well, I did that, but now I got:

java.lang.NullPointerException
at com.test.struts.users.getUsers(users.java:12)

This means that it is the same problem. The collection is not yet ready. Right?
There are no problems in the code or jsp, but how the entities (action, form, jsp) are related among them and the order how they are made. Infact you wrote "The way you've got it set up...". Is there another way to avoid this problem? I mean, in order to have the correct order of the objects definition, do I need to change something in the main structure of my application?

Anyway I'm very surprised, beacuse I learnt a base struts application (like mine) is made of a jsp, a form and an action. Normally it works good! What are the changes I need to do?

Thank you for your suggestions.
Fpia
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error that you're currently getting has nothing to do with Struts. It's just a "plain old java error" (POJE?). In your users class (which, by the way should be Users, not users) you try to add to an ArrayList without instantiating it. That's why you're getting a NPE. Change the statment:

to

and it should work.

Regarding your concept of what a "base struts application" needs, what you say is generally true. However, your application goes a little beyond a "base application" because it has a list of values that needs to be populated before the JSP can be displayed. In this case, you need two actions: one to prepare the JSP, and one to process it once it has been submitted.
 
Fabrizio Pia
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ops! Yes you're right!
Now it works.

But anyway the LabelValueBean does a very strange effect...

Now my code is



The menu should have three options "Mr. White", "Mr...", while in my menu I see "LabelValueBean[Mr. White,1]", then as second option "LabelValueBean[Mr. Gree, 2]"...

The add method takes the "new" argument as a string nut the code should be correct!! Do I need to change the html ption configuration?

Can you help me please?
Thank you

Fpia
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read carefully my previous post dated Tuesday, April 24, 2007 1:09 PM
 
Ruth Stout was famous for gardening naked. Just like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic