Hey Mike,

Okay, so that works great...but now I get these warnings in my log:
Feb 19 10:41:04 [4700] INFO NSLog - invokeAction: An non stored response return context.page(), which will result in suboptimal performance. Feb 19 10:41:04 [4700] INFO NSLog - ERXAjaxApplication.invokeAction: An Ajax response returned context.page(), which is almost certainly an error.

Is there a way to disable those warnings? (Ideally just specifically for that method?)

        - Leif

On Feb 19, 2009, at 4:47 AM, Mike Schrag wrote:

I posted about this a few weeks back ... It's actually expected behavior, though I might change that exception to explicitly say "hey are you returning null instead of context.page?".

The deal is that you selected to delete, say, index 1. Your action method gets fired, because your senderID matches, and your array then gets modified in the middle of the repetition. The repetition doesn't KNOW this, though, and just keeps processing the array, which causes an array out of bounds exception. I suspect we can actually fix this, internally, but the proper fix is that if you return something other than null, it signals the repetition that it no longer needs to keep processing the array for invokeActions, breaks out, and the world is good.

ms

On Feb 19, 2009, at 3:08 AM, Peer Sandtner wrote:

Hello Leif,

yesterday we experienced exactly the same problem. We "fixed" it by returning this.context().page() instead of null in the delete-method.

Anyone who could explain if this is a bug or a feature? ;-)

Regards,
Peer

PS: we are using Wonder 5.0.0.8627



Am 18.02.2009 um 23:48 schrieb Leif Harrison:

Hey all,

I was working on adding basic add/delete functionality to my app, but am having difficulty getting my delete functionality to work. I'm pretty sure it's something pretty stupid or obvious, as I've done this before and certainly have plenty of examples around...but I can't for the life of me figure out what I'm doing wrong.

Basically I'm getting an array out-of-bounds exception after trying to delete an object in an Ajax action: [2009-2-18 14:35:38 PST] <WorkerThread3> java.lang.IllegalArgumentException: Index (2) out of bounds [0, 1] at com.webobjects.foundation.NSArray.objectAtIndex(NSArray.java: 395) at com .webobjects .eocontrol ._EOCheapCopyMutableArray .objectAtIndex(_EOCheapCopyMutableArray.java:110) at er.extensions.components._private.ERXWORepetition $Context.objectAtIndex(ERXWORepetition.java:146) at er .extensions .components ._private .ERXWORepetition ._prepareForIterationWithIndex(ERXWORepetition.java:243) at er .extensions .components ._private.ERXWORepetition.invokeAction(ERXWORepetition.java:444) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java: 105) at com .webobjects .appserver ._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115)
...

Here's the basic component html:

<wo:AjaxUpdateContainer id = "ActivitiesListContainer">
<wo:form name = "ActivitiesList" multipleSubmit = "true">
<div id="activities_list">
<table>
        <tr>
                <th class="activities_list_delete_column">&nbsp;</th>
                <th class="activities_list_name_column">Name</th>
                <th class="activities_list_date_column">Created</th>
        </tr>
<wo:ERXWORepetition list = "[currentActivities]" item = "[anActivity]">
        <tr>
<td class="activities_list_delete_column"><wo:AjaxSubmitButton action = "[deleteActivity]" button="true" value = "Delete" updateContainerID = "ActivitiesListContainer" /></td> <td class="activities_list_name_column"><wo:string value="[anActivity.name]" /></td> <td class="activities_list_date_column"><wo:string value="[anActivity.createdAt]" /></td>
        </tr>
        </wo:ERXWORepetition>
</table>
</div>
<wo:AjaxSubmitButton action = "[addActivity]" id = "add_activity_button" value = "Add Activity" updateContainerID = "ActivitiesListContainer" />
</wo:form>
</wo:AjaxUpdateContainer>

And here's the (hopefully) relevant code:

public class MWActivitiesList extends ERXComponent {

    public Activity anActivity;
        
    public MWActivitiesList(WOContext context) {
        super(context);
    }
        
    public NSArray<Activity> currentActivities() {
        Session session = (Session)session();
        Account user = session.user();
        return user.activities();
    }

    public WOActionResults deleteActivity() {
        Session session = (Session)session();
        Account user = session.user();
        EOEditingContext ec = user.editingContext();

        user.deleteActivitiesRelationship(anActivity);

        try {
            ec.saveChanges();
        }
        catch ( Exception e ) {
log.debug("Exception raised deleting activity: " + e.toString());
            e.printStackTrace();
        }

        return null;
    }
}

Based on my logging, and looking at method calls, it looks almost like the ERXWORepitition is trying to access outside the bounds of the array, but doing so without even calling currentActivities() when updating the AjaxUpdateContainer. Also, strangely enough deleting from the END of the array works fine, it's only deletes from the beginning or middle that fail.

The component is pretty basic. The object model is pretty basic (generated in Eclipse from the EOModel). Nothing particularly tricky going on anywhere. Driving...me...crazy.

FYI, the Wonder build I'm using is 5.0.0.8421.

        - Leif

----------
Leif Harrison
Senior Engineer - Ubermind, Inc.
[email protected]


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/peer.sandtner%40alstercontor.de

This email sent to [email protected]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com

This email sent to [email protected]

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/rexfelis%40catsreach.org

This email sent to [email protected]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to