Search in sources :

Example 1 with Person

use of com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person in project nalu-examples by NaluKit.

the class ListComponent method render.

@Override
public void render() {
    TableConfig<Person> tableConfig = new TableConfig<>();
    tableConfig.addColumn(ColumnConfig.<Person>create("name", "Name").setCellRenderer(cell -> a().textContent(cell.getTableRow().getRecord().getName() + ", " + cell.getTableRow().getRecord().getFirstName()).on(EventType.click, e -> getController().doUpdate(cell.getTableRow().getRecord())).element())).addColumn(ColumnConfig.<Person>create("street", "Street").setCellRenderer(cell -> new Text(cell.getTableRow().getRecord().getAddress().getStreet()))).addColumn(ColumnConfig.<Person>create("zip", "ZIP").textAlign("right").setCellRenderer(cell -> new Text(cell.getTableRow().getRecord().getAddress().getZip()))).addColumn(ColumnConfig.<Person>create("street", "Street").setCellRenderer(cell -> new Text(cell.getTableRow().getRecord().getAddress().getStreet()))).addColumn(ColumnConfig.<Person>create("city", "City").setCellRenderer(cell -> new Text(cell.getTableRow().getRecord().getAddress().getCity())));
    this.store = new LocalListDataStore<>();
    this.table = new DataTable<>(tableConfig, store);
    initElement(Card.create("SEARCH RESULTS").appendChild(Row.create().appendChild(Column.span12().appendChild(this.table))).element());
}
Also used : ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) Person(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person) Elements.a(org.jboss.elemento.Elements.a) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) AbstractComponent(com.github.nalukit.nalu.client.component.AbstractComponent) Column(org.dominokit.domino.ui.grid.Column) DataTable(org.dominokit.domino.ui.datatable.DataTable) ArrayList(java.util.ArrayList) List(java.util.List) EventType(org.jboss.elemento.EventType) Text(elemental2.dom.Text) HTMLElement(elemental2.dom.HTMLElement) Row(org.dominokit.domino.ui.grid.Row) Card(org.dominokit.domino.ui.cards.Card) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) Text(elemental2.dom.Text) Person(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person)

Example 2 with Person

use of com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person in project nalu-examples by NaluKit.

the class PersonService method initList.

private void initList() {
    Address address01 = new Address(1, "Evergreen Terrace", "7 42", "Springfield");
    persons.put(new Long(1), new Person(1, "Simpsons", "Homer", address01));
    persons.put(new Long(2), new Person(2, "Simpsons", "Marge", address01));
    persons.put(new Long(3), new Person(3, "Simpsons", "Bart", address01));
    persons.put(new Long(4), new Person(4, "Simpsons", "Maggie", address01));
    persons.put(new Long(5), new Person(5, "Simpsons", "Lisa", address01));
    Address address02 = new Address(2, "Blumenweg Nr. 13", "", "Entenhausen");
    persons.put(new Long(6), new Person(6, "Duck", "Donald", address02));
    persons.put(new Long(7), new Person(7, "Duck", "Trick", address02));
    persons.put(new Long(8), new Person(8, "Duck", "Tick", address02));
    persons.put(new Long(9), new Person(9, "Duck", "Tack", address02));
    Address address03 = new Address(2, "Am Goldberg Nr. 1", "", "Entenhausen");
    persons.put(new Long(10), new Person(10, "Duck", "Dagobert", address03));
}
Also used : Address(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Address) Person(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person)

Example 3 with Person

use of com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person in project nalu-examples by NaluKit.

the class ListController method start.

@Override
public void start() {
    List<Person> result = PersonService.get().get(new PersonSearch(this.name, this.city));
    this.component.resetTable();
    this.component.setData(result);
    if (result.size() == 0) {
        this.eventBus.fireEvent(new StatusChangeEvent("No person found"));
    } else if (result.size() == 1) {
        this.eventBus.fireEvent(new StatusChangeEvent("Found one person"));
    } else {
        this.eventBus.fireEvent(new StatusChangeEvent("Found " + Integer.toString(result.size()) + " persons"));
    }
    this.eventBus.fireEvent(new SelectEvent(SelectEvent.Select.LIST));
}
Also used : PersonSearch(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.PersonSearch) StatusChangeEvent(com.github.nalukit.example.nalu.loginapplication.client.event.StatusChangeEvent) Person(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person) SelectEvent(com.github.nalukit.example.nalu.loginapplication.client.event.SelectEvent)

Example 4 with Person

use of com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person in project nalu-examples by NaluKit.

the class PersonService method update.

public void update(Person person) throws PersonException {
    Person value = persons.get(new Long(person.getId()));
    if (value != null) {
        persons.remove(new Long(person.getId()));
        persons.put(new Long(person.getId()), person);
    }
}
Also used : Person(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person)

Example 5 with Person

use of com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person in project nalu-examples by NaluKit.

the class PersonService method insert.

public void insert(Person person) throws PersonException {
    Iterator<Person> iter = persons.values().iterator();
    long maxKey = 0;
    while (iter.hasNext()) {
        Person element = iter.next();
        if (maxKey < element.getId()) {
            maxKey = element.getId();
        }
    }
    maxKey++;
    person.setId(maxKey);
    persons.put(new Long(maxKey), person);
}
Also used : Person(com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person)

Aggregations

Person (com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Person)5 Address (com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.Address)1 PersonSearch (com.github.nalukit.example.nalu.loginapplication.client.data.model.dto.PersonSearch)1 SelectEvent (com.github.nalukit.example.nalu.loginapplication.client.event.SelectEvent)1 StatusChangeEvent (com.github.nalukit.example.nalu.loginapplication.client.event.StatusChangeEvent)1 AbstractComponent (com.github.nalukit.nalu.client.component.AbstractComponent)1 HTMLElement (elemental2.dom.HTMLElement)1 Text (elemental2.dom.Text)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Card (org.dominokit.domino.ui.cards.Card)1 ColumnConfig (org.dominokit.domino.ui.datatable.ColumnConfig)1 DataTable (org.dominokit.domino.ui.datatable.DataTable)1 TableConfig (org.dominokit.domino.ui.datatable.TableConfig)1 LocalListDataStore (org.dominokit.domino.ui.datatable.store.LocalListDataStore)1 Column (org.dominokit.domino.ui.grid.Column)1 Row (org.dominokit.domino.ui.grid.Row)1 Elements.a (org.jboss.elemento.Elements.a)1 EventType (org.jboss.elemento.EventType)1