• 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

logic:iterate problem: NullPointerException

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all.
I have a problem with a logic:iterate tag. I'm using Struts 1.3.
I have to populate a select with data read from db (by invoking the first Action). When a select option is selected in the jsp, I have to invoke a second Action (on the same jsp page) which has to perform some operations and remember the previous selected option (in the select).
I show you my source code for semplicity.

Here is my ActionForm.
*******************************
CreazioneProfiloUtenteForm.java
*******************************



First, the ToCreazioneProfiloUtenteAction action is invoked. This action reads data from db and insert them in the ArrayList 'listaSport'; at the end, this ArrayList is setted in the request.
***********************************
ToCreazioneProfiloUtenteAction.java
***********************************


Then creazioneProfiloUtente.jsp is invoked. I have a select 'sport' that reads the collections in the ArrayList 'listaSport'. Then, I have to store in hidden fields the values of the 'listaSport' arraylist in order to avoid, in the second Action, to re-access to db to read the same values. In order to do so, I use logic:iterate but I have problems with it. I confirm that if I delete from source code the tag logic:iterate, all works well.
**************************
creazioneProfiloUtente.jsp
**************************


This is the second Action, which should be invoked when a select option is selected by user. Unfortunately, this Action is never accessed because I got a java NullPointerException before.
*****************************************
CaricamentoRuoliAttributiSportAction.java
*****************************************


*********
EXCEPTION
*********


*****************
STRUTS-CONFIG.XML
*****************


I can't understand where is the problem.
Can you help me?

Thanks to all in advance.

Bye bye.
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not really have an experience in Struts framework.

are you using any IDE for the development..
if yes, then use this to debug your code? I think its easy way to find.
 
Michele Giunti
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Eclipse.
I had already tried to debug but with no result.
I think the problem is in my ActionForm class but I can't find a solution.

The genereted html is the following:


I think there is a type mismatch between my ActionForm definition ('sport' is a String) and the generated html ('sport' is a org.apache.struts.util.LabelValueBean[]) but I can't understand how to solve the problem.
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm only experienced with struts up to 1.2.7 but I think your problem stems from the fact that this part of your jsp



is set up to generate indexed input fields with the same name as un-indexed property of your form bean. Basically you have a property name "sport" that is a string, but you are setting up hidden input fields that struts will try to put into an array list named sport.

I'm not sure what you're trying to accomplish with this part of your JSP since you are generating hidden fields in your html that don't appear to have any cooresponding properties in your form bean to hold them. If you only need these fields for something on the client side like javascript, just use a different id attribute in your iterate. If you want to keep them so you don't have to look them up again, create a list property in your form bean, populate it with the listaSport values, and use the logic iterate to hide the list on the screen.
 
reply
    Bookmark Topic Watch Topic
  • New Topic