Re: Problem wo loop WOHyperlink
Re: Problem wo loop WOHyperlink
- Subject: Re: Problem wo loop WOHyperlink
- From: Paul Hoadley <email@hidden>
- Date: Sat, 14 Jul 2012 08:52:50 +0930
Hi Hugo,On 14/07/2012, at 7:22 AM, Hugo Cambero wrote: <wo:loop list="$allUsers" item="$entryItem"> <tr> <td> <wo:str value="$entryItem.primaryKey" />
</td> <td>
<wo:str value="$entryItem.name" />
</td> <td>
<wo:str value="$entryItem.lastname" />
</td> <td>
<wo:str value="$entryItem.username" />
</td> <td>
<webobject name = "DeleteLink" > <webobject name = "DeleteImage"/> </webobject> </td>
</tr> </wo:loop>
--------------------------- DeleteLink : WOHyperlink { directActionName="deleteRecord"; }
Change that to:
action = "">
And then add a method in your component class:
public class AdminPage extends ERXComponent { private User entryItem; public AdminPage(WOContext context) {
super(context); }
public User entryItem() { return entryItem; }
public void setEntryItem(User entryItem) { this.entryItem = entryItem; }
public NSArray<User> allUsers() { return User.fetchAllUsers( ERXEC.newEditingContext() ); }
public WOActionResults deleteRecord() { // This is just an example of what you might do—your business // logic might require something else entirely. entryItem.editingContext().deleteObject(entryItem); entryItem.editingContext().saveChanges(); return context().page(); }
When a WOHyperlink's action method is called inside a WORepetition like that, the repetition's 'item' ivar will contain the value you would expect: the object from allUsers() that corresponds to the hyperlink that was clicked.
|
_______________________________________________
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