• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AjaxSubmitButton/AjaxUpdateContainer -> Index out of bounds after delete
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AjaxSubmitButton/AjaxUpdateContainer -> Index out of bounds after delete


  • Subject: AjaxSubmitButton/AjaxUpdateContainer -> Index out of bounds after delete
  • From: Leif Harrison <email@hidden>
  • Date: Wed, 18 Feb 2009 14:48:22 -0800

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@hidden


 _______________________________________________
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

  • Follow-Ups:
    • Re: AjaxSubmitButton/AjaxUpdateContainer -> Index out of bounds after delete
      • From: Peer Sandtner <email@hidden>
  • Prev by Date: Re: Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext in _globalIDForObject
  • Next by Date: Re: Invoking Subcomponent Action
  • Previous by thread: Re: Cannot obtain globalId for an object which is registered in an other than the databaseContext's active editingContext in _globalIDForObject
  • Next by thread: Re: AjaxSubmitButton/AjaxUpdateContainer -> Index out of bounds after delete
  • Index(es):
    • Date
    • Thread