[Fwd: Re: ActionForm with ArrayList - Validation Problem]

2005-01-19 Thread Robert Taylor
This was a reply directly to me which I'm forwarding to the list so
future users can leverage the solutions provided in this message.
 original message ---
Robert,
It is hard to find in the archives, but while I was reading the other
messages posted lately I found someone having the same problem and he was
redirected to http://www.reumann.net/struts/articles/request_lists.jsp which
is exactly what you are explaining me...
I guess I'll change the scope to session - which is probably the easiest way
to go for me for now. Hopefully that's not creating other problems...
Struts is a very nice technology, but there is so much to know and to
search...
Great list! And nice people always willing to help.
Thanks, BW.
On 1/20/05 2:23 AM, "Robert Taylor" <[EMAIL PROTECTED]> wrote:
>> This is a common and well documented idiom, but can be hard to
>> find in the archives  ;)
>>
>> The problem is that to display the form with the select list, you have
>> to prepare the select list before displaying the page.
>>
>> When the user submits the form and validation fails, Struts will forward
>> to the input attribute value in the action mapping. If this value is the
>> .jsp instead of the action url which prepares the .jsp, you get the
>> behavior you describe below.
>>
>> One solution, is to assign the input attribute value to be the
>> preparation action for the page.
>>
>> Another solutions is to place your form in the session and override the
>> form reset() so that your customer list isn't wiped out when you submit
>> the request.
>>
>> Another solution is if your customer list is unique to the user and
>> doesn't change, populate the list and place it in the session when the
>> user logs in and don't put it in the action form at all.
>>
>> Another solution is if your customer list is static and global to all
>> users, populate the customer list on application start up
>> (ServletContextListener or Struts plugin) and place it in the
>> ServletContext as an attribute.
>>
>> hth,
>>
>> /robert
>>
>> Bernard Willemot wrote:
>
 Hi,

 Not sure it is the best practice...

 I have a for to edit a user called UserForm. This form contains a 
popup
 () with Customers.

 I didn¹t find an easier way to include the data of the popup in the
 UserForm:

 Public class UserForm extends ActionForm {
 
 protected ArrayList customer_popup;

 

 public ArrayList getCustomerPopup() {
 return this.customer_popup;
 }

 public void setCustomerPopup(ArrayList customer_popup) {
 this.customer_popup = customer_popup;
 }
 }

 So before editing the user and while building the form, I build 
the form and
 fill the ArrayList with the customers as well.

 So far so good that works, but if I use validation, and the page 
with the
 form needs be reloading to tell me what went wrong, I have the 
problem that
 struts doesn¹t find the arraylist in the form anymore:

 javax.servlet.ServletException: ServletException in
 '/setup/users/edit_user_data.jsp': Failed to obtain specified 
collection

 In the jsp, I use:

 

 value='id' />
 

 If I remove it, it works fine.


 Using struts 1.2.4 with TC 5.5.

 Any idea?

 Thank you, BW.

>
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: ActionForm with ArrayList - Validation Problem

2005-01-19 Thread Robert Taylor
This is a common and well documented idiom, but can be hard to
find in the archives ;)
The problem is that to display the form with the select list, you have
to prepare the select list before displaying the page.
When the user submits the form and validation fails, Struts will forward
to the input attribute value in the action mapping. If this value is the
.jsp instead of the action url which prepares the .jsp, you get the 
behavior you describe below.

One solution, is to assign the input attribute value to be the 
preparation action for the page.

Another solutions is to place your form in the session and override the
form reset() so that your customer list isn't wiped out when you submit
the request.
Another solution is if your customer list is unique to the user and 
doesn't change, populate the list and place it in the session when the 
user logs in and don't put it in the action form at all.

Another solution is if your customer list is static and global to all 
users, populate the customer list on application start up 
(ServletContextListener or Struts plugin) and place it in the 
ServletContext as an attribute.

hth,
/robert
Bernard Willemot wrote:
Hi,
Not sure it is the best practice...
I have a for to edit a user called UserForm. This form contains a popup
() with Customers.
I didn¹t find an easier way to include the data of the popup in the
UserForm:
Public class UserForm extends ActionForm {

protected ArrayList customer_popup;

public ArrayList getCustomerPopup() {
return this.customer_popup;
}

public void setCustomerPopup(ArrayList customer_popup) {
this.customer_popup = customer_popup;
}
} 

So before editing the user and while building the form, I build the form and
fill the ArrayList with the customers as well.
So far so good that works, but if I use validation, and the page with the
form needs be reloading to tell me what went wrong, I have the problem that
struts doesn¹t find the arraylist in the form anymore:
javax.servlet.ServletException: ServletException in
'/setup/users/edit_user_data.jsp': Failed to obtain specified collection
In the jsp, I use:

   

If I remove it, it works fine.
Using struts 1.2.4 with TC 5.5.
Any idea?
Thank you, BW.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


ActionForm with ArrayList - Validation Problem

2005-01-19 Thread Bernard Willemot
Hi,

Not sure it is the best practice...

I have a for to edit a user called UserForm. This form contains a popup
() with Customers.

I didn¹t find an easier way to include the data of the popup in the
UserForm:

Public class UserForm extends ActionForm {

protected ArrayList customer_popup;



public ArrayList getCustomerPopup() {
return this.customer_popup;
}

public void setCustomerPopup(ArrayList customer_popup) {
this.customer_popup = customer_popup;
}
} 

So before editing the user and while building the form, I build the form and
fill the ArrayList with the customers as well.

So far so good that works, but if I use validation, and the page with the
form needs be reloading to tell me what went wrong, I have the problem that
struts doesn¹t find the arraylist in the form anymore:

javax.servlet.ServletException: ServletException in
'/setup/users/edit_user_data.jsp': Failed to obtain specified collection

In the jsp, I use:


   


If I remove it, it works fine.


Using struts 1.2.4 with TC 5.5.

Any idea?

Thank you, BW.