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 = deleteRecord;
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.
--
Paul Hoadley
http://logicsquad.net/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]