Start by creating a simple Person.java
POJO. Something like this:
public Person {
String firstName;
public getFirstName() {
return firstName;
}
public setFirstName(String to) {
this.firstName = to;
}
//etcetera...
}
Make sure that every property you want to edit has a getter & setter.
You now have 2 options:
- The list of people is a
List<Person>
and when you edit one, you edit the object directly from that list.
- When the user wants to edit an entry, you pass (for instance) the note ID of the document from the list to the inplace form, get the document, construct a
Person
object and use that as the binding in the form.
Assuming that the instance of the Person
is called person
, you can bind them to the inputs like:
<xp:inputText value="#{person.firstName} />
For the save action in the inplace form, I would create a separate PersonRepo
class with a static save function that consumes the current Person
object and saves it to the database:
public class PersonRepo {
public static void savePerson( Person person ) {
Database db = ExtLibUtil.getCurrentDatabase();
Document doc = db.createDocument();
doc.replaceItemValue("firstName" , firstName);
doc.save();
}
}
You can then call that from the save button:
PersonRepo.savePerson(person);