File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes String[] is null upon reaching Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "String[] is null upon reaching Action" Watch "String[] is null upon reaching Action" New topic

String[] is null upon reaching Action

Theo van Loon
Ranch Hand

Joined: Feb 04, 2004
Posts: 71
Hello all, in my form i have a String[] which i fill using html:text tags. However when i reach the action in which i need the String[] it is null. What can i do to resolve this?
Kenneth Brooks

Joined: Feb 21, 2005
Posts: 9
I'm not exactly following what you mean that you have a String[] in your form?

Are you saying that you have multiple textfields that all have the same name?

Ricardo Estafan
Ranch Hand

Joined: Mar 29, 2004
Posts: 84
yes i have a String[] that compares to multiple text fields in the jsp. When i go into the action i guess the form resets and the String[] is null.
Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
Name of the String [] and name of that HTML element should be same or getting the value in the action . Are you using the same name ???

SCWCD 1.4, SCJP 1.4
Theo van Loon
Ranch Hand

Joined: Feb 04, 2004
Posts: 71
Ok situation now is as follows :

I have two action : one that initializes a shoppingcart and one dispatchaction that updates, deletes etc. In my form i have a map which contains key : product id and value is a String object containing the amount.

my form contains the following methods :

In my JSP i have the following code :

This works for displaying purposes. So it shows the correct amount. Question is though what can i do to update the amounts. When it reaches the action the map is null. Perhaps place the map in the request, but is it then possible to write to the given object using html:text tag.

Does anyone know how to deal with this issue???
[ February 28, 2005: Message edited by: Theo van Loon ]
I agree. Here's the link:
subject: String[] is null upon reaching Action
It's not a secret anymore!