Uli,

I'm seeing isDelete() called as it renders the display but I'm not seeing setDelete(boolean delete) being called on submit. Can you please play spot the obvious error? Here's the code:

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
<body>
        <form t:type="form" t:id="deletables">
<table t:type="grid" t:source="persons" t:row="person" t:model="mymodel" t:volatile="false">
                        t:rowsPerPage="2" t:pagerPosition="top">[Persons Grid 
here]
                        <t:parameter name="deleteCell">
                                <input t:type="checkbox" t:id="delete" 
value="delete"/>
                        </t:parameter>
                </table>
                <input type="submit" value="Save"/>
         </form><br/>
</body>
</html>

package jumpstart.web.pages.examples.tables;

import java.util.ArrayList;
import java.util.List;

import jumpstart.business.domain.examples.Person;
import jumpstart.business.domain.examples.iface.IPersonServiceLocal;
import jumpstart.web.services.IBusinessServicesLocator;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.Retain;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;

public class GridForm {

        @SuppressWarnings("unused")
        @Property
        @Persist
        private List<Person> _persons;

        @SuppressWarnings("unused")
        @Property
        private Person _person;

        @Inject
        private IBusinessServicesLocator _businessServicesLocator;

        @Inject
        private BeanModelSource _beanModelSource;

        @Inject
        private ComponentResources _componentResources;

        @SuppressWarnings("unchecked")
        @Property
        @Retain
        private BeanModel _myModel;

        @Property
        private boolean _delete;

        @SuppressWarnings("unused")
        private List<Person> _personsToDelete;

        @SuppressWarnings("unused")
        @Property
        private Person _personToDelete;

        void setupRender() {

                if (_myModel == null) {
_myModel = _beanModelSource.create(Person.class, false, _componentResources.getMessages());
                        _myModel.add("delete", null);
_myModel.include("id", "firstName", "lastName", "startDate", "delete");
                }

// Get all persons - ask business service to find them (from the database)
                _persons = getPersonService().findPersons();
        }
        public void onPrepareForSubmit() {
                if (_persons == null) {
                        _persons = new ArrayList<Person>();
                }
        }

        void onSuccess() {
                List<Person> dudes = getPersonsToDelete();
                System.out.println(">>>> dudes = " + dudes);
                for (Person p : getPersonsToDelete()) {
                        System.out.println(">>>> delete " + p.getFirstName());
                }
        }

        private IPersonServiceLocal getPersonService() {
// Use our business services locator to get the EJB3 session bean called "PersonServiceLocal".
                return _businessServicesLocator.getPersonServiceLocal();
        }

        public List<Person> getPersonsToDelete() {
                if (_personsToDelete == null) {
                        _personsToDelete = new ArrayList<Person>();
                }
                return _personsToDelete;
        }

        public void setDelete(boolean delete) {
                if (delete) {
                        getPersonsToDelete().add(_person);
                }
        }

        public boolean isDelete() {
                return _delete;
        }
}


Geoff

On 16/10/2008, at 2:13 AM, Ulrich Stärk wrote:

Please ignore my stupidity. I misinterpreted the error message I was getting that had nothing to do with this.

You can still add a delete column to your model with model.add("delete", null) and add a "deleteCell" parameter to your template in order to have a delete column. Works like a charm.

Uli

Ulrich Stärk schrieb:
Woah! Indeed, this doesn't work anymore. Evil. How are we supposed to do this now?
Uli
Geoff Callender schrieb:
No response, so I guess that means we can't add a Delete column to a Grid any more.


On 14/10/2008, at 8:36 PM, Geoff Callender wrote:

Can anyone tell me if Penyihir's technique for adding a Delete column to Grid still works?

Please note this is not the same as editing a flag in the source entity - this is different - it's editing a column that we've added to the model.

On 10/12/2007, at 7:08 PM, Penyihir Kecil wrote:

it might be help :
-------------------
GridClub.tml
------------------
<form t:type="Form" t:id="clubForm">
     <table t:type="grid" rowsPerPage="5" pagerPosition="top"
source="clubList" row="club" remove="idClub" model="clubModel">
         <t:parameter name="deleteCell">
<input t:type="Checkbox" t:id="delete" value="delete"/>
         </t:parameter>
         <t:parameter name="updateCell">
<a t:type="PageLink" t:id="update" page="admin/ FormClub"
context="club.idClub"><img src="../images/edit.gif"/></a>
         </t:parameter>
         <!-- <t:parameter name="deleteCell">
             <a t:type="ActionLink" t:id="delete"
context="club.idClub">delete</a>
         </t:parameter>-->
     </table>
     <input type="submit" value="delete"/>

---------------------
GridClub.java
---------------------
@Inject
   private IClubDao clubDao;
   private List<Club> clubList;
   private Club club;           @Retain
   private BeanModel clubModel;
   @Inject
   private BeanModelSource beanModelSource;
 @Inject
 private ComponentResources resources;

 private boolean delete;
 public List<String> deletedList;


 public boolean isDelete() {
       return delete;
   }

   public void setDelete(boolean delete) {
if(delete) { getDeletedList().add(club.getIdClub());
       }
          }
           public List<String> getDeletedList() {
       if(deletedList == null){
deletedList = new ArrayList<String>(); }
       return deletedList;
   }

   void pageLoaded(){
clubModel = beanModelSource.create(Club.class, true, resources);
     clubModel.add("delete",null);
     clubModel.add("update",null);
            }

   public Club getClub() {
       return club;
   }
   public void setClub(Club club) {
       this.club = club;
   }
   public IClubDao getClubDao() {
       return clubDao;
   }
   public List<Club> getClubList() {
       if(clubList == null){
clubList = new ArrayList<Club>(); clubList = getClubDao().queryForList("", "");
       }
              return clubList;
   }
       public BeanModel getClubModel() {
       return clubModel;
   }
       Object onSuccessFromClubForm(){
for (Iterator<String> iter = getDeletedList().iterator(); iter.hasNext();) {
           String element = iter.next();
           setClub((Club) getClubDao().findByPrimaryKey(element));
           getClubDao().delete(getClub());
} deletedList = null;
       return GridClub.class;
   }

On 12/10/07, Cristian Gonzalo Gary <[EMAIL PROTECTED]> wrote:

Hello
I need to modified the Column label, and put into and image with a link .

Thanks.
Gracias.
--
View this message in context:
http://www.nabble.com/-T5--How-Add-and-Image-to-Grid-Column-Label.-tp14242580p14242580.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to