Re: Submitting multiple instances in one WOForm
Re: Submitting multiple instances in one WOForm
- Subject: Re: Submitting multiple instances in one WOForm
- From: Chuck Hill <email@hidden>
- Date: Tue, 10 Apr 2007 09:15:05 -0700
On Apr 10, 2007, at 9:04 AM, David Avendasora wrote:
Ken and everyone, here's the gist of what I'm trying to do:
I had a component in my app that had a WOForm nested inside a
WORepetition to submit OrderItems to a manufacturing schedule. One
form for each OrderItem, each with it's own submit button. I
thought I could make the page much more efficient (from both the
user's and the application's perspective) by having just one form
that the user selects which items they want scheduled. The way they
indicate what OrderItems they want scheduled is by changing an
item's quantityToSchedule from null to some quantity. (using a
WOTextField)
The only form field in the form is the repeated quantityToSchedule.
The quantityToSchedule value is NOT an attribute of OrderItem, and
I'm not actually updating OrderItem, I am using the information
from the submitted form to create new instances of the
ScheduledOrderItem entity.
When I submit the form, I get a null pointer exception when I try
to pass the instance of OrderItem that is bound to the
WORepitition's "item" binding (aOrderItem). Am I doing something
obviously wrong?
YES!
Here's the structure of my page:
<WOForm>
<WOSubmitButton action=scheduleOrderItem>
<WORepetition list=openOrderItems, item=aOrderItem>
<WOString value=aOrderItem.Order.DueDate>,<WOString
value=aOrderItem.Part.PartName>,
<WOString value=aOrderItem.orderQuantity><WOTextField
value=quantityToSchedule>
</WORepitition>
</WOForm>
The submit button is outside of the repetition. Outside of the
repetition, aOrderItem is _guaranteed_ to be null. Either move the
submit button inside the repetition (one submit per order item), or
move this code:
log.debug("OrderItem to Schedule: "+aOrderItem.part
().partName());
manufacturingSchedule.scheduleOrderItem(ec, aOrderItem,
quantityToSchedule);
Into setQuantityToSchedule.
Chuck
Here's the method that is bound to hte action binding of the
WOSumbitButton:
Public WOComponent addOrderItemToSchedule() {
ec = session().defaultEditingContext();
log.debug("OrderItem to Schedule: "+aOrderItem.part
().partName());
manufacturingSchedule.scheduleOrderItem(ec, aOrderItem,
quantityToSchedule);
return context().page();
}
aOrderItem is null and I get a NPE. Why is aOrderItem null?
Dave
On Apr 10, 2007, at 10:54 AM, Ken Anderson wrote:
I unfortunately don't have the history from this thread around,
but there should be no problem with having a single submit button
saving hundreds of EOs, including multiple instances of the same
class. I have many forms where there's a single submit, but I
have hundreds of EOs on the page, and sometimes edit/insert many.
On Apr 10, 2007, at 11:48 AM, David Avendasora wrote:
That's the conclusion I've come to. So how do you submit multiple
instances of one class to a form without having to click submit
for every instance? Is it impossible?
On Apr 10, 2007, at 9:51 AM, Daniele Corti wrote:
wait, I've just remember: aOrderItem is the item bind in the
WORepetition? if so, it will be null, when clicking Submit
button, because the submit button is outside the WORepetition
(oh, well I think iit works in that way...)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden