Thanks for answering.

I learned something new. I'm going to change my code.

Hugo

On Fri, Jul 13, 2012 at 6:25 PM, Chuck Hill <[email protected]>wrote:

>
> On 2012-07-13, at 2:52 PM, Hugo Cambero wrote:
>
> > Hi Everybody
> >
> > I'm Hugo, I've been developing using WebObjects and Wonder Frameworks,
> I'm newbie in this topic.
> >
> > I have a problem and I hope you can help me. I'm developing a test
> application, I want to display a list of ERXGenericRecord, but, in the last
> column,
> > I want to display a picture that can delete the selected row.
> >
> > Example:
> >
> > ID       NAME        LASTNAME       USERNAME          ACTIONS
> > 120     Hugo          Perez                sun13                   delete
> > 160     Aaron         Anthony            aaron12                 delete
> >
> > If the user clicks the delete picture of the first row, the application
> deletes the record 120.
> >
> > I'm trying to do it using the next code:
> >
> > <table>
> >       <tr>
> >          <td>ID</TD>
> >          <td>Name</td>
> >          <td>Lastname</td>
> >          <td>Username</td>
> >          <td>Actions</td>
> >       </tr>
> >       <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>
> > </table>
> > ---------------------------
> > DeleteLink : WOHyperlink {
> >     directActionName="deleteRecord";
>
> You don't want a direct action here, change this to (notice no quotes!):
>
>         action = deleteRecord;
>
> Then in AdminPage.java add this:
>
>
> public WOComponentAction deleteRecord() {
>         editingContext.deleteObject(entryItem);
>         editingContext.saveChanges();  // This can throw if the deletion
> fails
> }
>
>
> You also need the fixes below so the EOEditingContext is not changing all
> the time.
>
> Chuck
>
>
>
> > }
> >
> > DeleteImage : WOImage {
> >     filename = "css/img/boton/delete.png";
> >     mimeType="image/gif";
> > }
> > --------------------------
> > package your.app.components;
> >
> > import your.app.model.User;
> > import com.webobjects.appserver.WOContext;
> > import com.webobjects.foundation.NSArray;
> > import er.extensions.components.ERXComponent;
> > import er.extensions.eof.ERXEC;
> >
> > public class AdminPage extends ERXComponent {
> >     private User entryItem;
>
> private EOEditingContext editingContext;
>
>
> >
> >     public AdminPage(WOContext context) {
> >         super(context);
>
>         editingContext = ERXEC.newEditingContext();
>
>
> >     }
> >
> >     public User entryItem() {
> >         return entryItem;
> >     }
> >
> >     public void setEntryItem(User entryItem) {
> >         this.entryItem = entryItem;
> >     }
> >
> >     public NSArray<User> allUsers() {
> >         return User.fetchAllUsers( ERXEC.newEditingContext() );
>
>
>         return User.fetchAllUsers( editingContext );
>
>
> >     }
> > }
> >
> > I think, I can solve this problem, adding a key or data in GET method in
> the 'Delete Link', but, I don't know.
> > What do you recommend me?
> > What is the best way to do this exercise?
> >
> > Thanks!
> > _______________________________________________
> > 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/chill%40global-village.net
> >
> > This email sent to [email protected]
>
> --
> Chuck Hill             Senior Consultant / VP Development
>
> 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/gvc/practical_webobjects
>
>
>
>
>
>
>
>
>
 _______________________________________________
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]

Reply via email to