Search is next step from the following thread whereby an UPDATE form may be
REUSED to ADD a database record: 

http://tapestry.1045711.n5.nabble.com/Reuse-Edit-Create-td5643323.html

The same form should do Query By Example (QBE) supported as by Hibernate: 

http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch17.html#querycriteria-examples

So the same exact form is now used to ADD, UPDATE or QBE.  

For the sake of completeness, here is EditPerson from 

http://tapestry.apache.org/hibernate-user-guide.html

modified for dual service as Edit/Create

public class EditPerson
{

  @Inject
  private Session session;

  @PageActivationContext
  @Property
  private Person person;

  @InjectPage
  private Persons persons;

  void onActivate(Person person)
  {
    this.person = person;
  }

  Object onPassivate() { return person; }

  @CommitAfter
  Object onSuccess()
  {
    session.saveOrUpdate(person);
    return persons;
  }
}


Persons.java is simply doing listing


public class Persons
{
         
  @Property
  private Person person;

  @Inject
  private Session session;
  
  public List<Person> getPersons()
  {
    return session.createCriteria(Person.class).list();
  }
  
}

Corresponding tmls are: 

EditPerson: <t:beaneditform object="person" />
Persons: <t:grid source="persons" />


which are inserted between the usual 

<html t:type="layout" title="Persons"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
      xmlns:p="tapestry:parameter">
</html>





--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Reuse-Edit-Create-for-Query-by-Example-tp5655916p5655916.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to