Search in sources :

Example 1 with Person

use of de.gishmo.example.devk.shared.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) 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) Person(de.gishmo.example.devk.shared.model.dto.Person) 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(de.gishmo.example.devk.shared.model.dto.Person)

Example 2 with Person

use of de.gishmo.example.devk.shared.model.dto.Person in project nalu-examples by NaluKit.

the class ListController method start.

@Override
public void start() {
    PersonServiceFactory.INSTANCE.getAll(new PersonSearch(this.name, this.city)).onSuccess(reponse -> {
        this.component.resetTable();
        this.component.setData(reponse.getPersonList());
        if (reponse.getPersonList().size() == 0) {
            this.eventBus.fireEvent(new StatusChangeEvent("No person found"));
        } else if (reponse.getPersonList().size() == 1) {
            this.eventBus.fireEvent(new StatusChangeEvent("Found one person"));
        } else {
            this.eventBus.fireEvent(new StatusChangeEvent("Found " + Integer.toString(reponse.getPersonList().size()) + " persons"));
        }
    }).onFailed(failedResponse -> {
        DomGlobal.window.alert("PANIC!!!!!!");
    }).send();
    this.eventBus.fireEvent(new SelectEvent(SelectEvent.Select.LIST));
}
Also used : PersonServiceFactory(de.gishmo.example.devk.shared.model.service.PersonServiceFactory) PersonSearch(de.gishmo.example.devk.shared.model.dto.PersonSearch) StatusChangeEvent(de.gishmo.example.devk.client.event.StatusChangeEvent) HTMLElement(elemental2.dom.HTMLElement) Routes(de.gishmo.example.devk.client.Routes) DomGlobal(elemental2.dom.DomGlobal) SelectEvent(de.gishmo.example.devk.client.event.SelectEvent) Controller(com.github.nalukit.nalu.client.component.annotation.Controller) AbstractComponentController(com.github.nalukit.nalu.client.component.AbstractComponentController) ApplicationContext(de.gishmo.example.devk.client.ApplicationContext) Person(de.gishmo.example.devk.shared.model.dto.Person) AcceptParameter(com.github.nalukit.nalu.client.component.annotation.AcceptParameter) PersonSearch(de.gishmo.example.devk.shared.model.dto.PersonSearch) StatusChangeEvent(de.gishmo.example.devk.client.event.StatusChangeEvent) SelectEvent(de.gishmo.example.devk.client.event.SelectEvent)

Example 3 with Person

use of de.gishmo.example.devk.shared.model.dto.Person in project nalu-examples by NaluKit.

the class DetailController method start.

@Override
public void start() {
    if (this.id == 0) {
        this.router.route(Routes.ROUTE_SEARCH);
    }
    PersonServiceFactory.INSTANCE.get(Long.toString(id)).onSuccess(response -> {
        this.person = response.getPerson();
        super.<PersonComposite>getComposite("personComposite").edit(this.person);
        super.<AddressComposite>getComposite("AddressComposite").edit(this.person);
        this.eventBus.fireEvent(new StatusChangeEvent("Edit person data with id: " + this.person.getId()));
        this.eventBus.fireEvent(new SelectEvent(SelectEvent.Select.DETAIL));
    }).onFailed(failedResponse -> DomGlobal.window.alert("Panic!")).send();
}
Also used : PersonServiceFactory(de.gishmo.example.devk.shared.model.service.PersonServiceFactory) IsComponentCreator(com.github.nalukit.nalu.client.component.IsComponentCreator) AddressComposite(de.gishmo.example.devk.client.ui.application.content.detail.composite.address.AddressComposite) Routes(de.gishmo.example.devk.client.Routes) DomGlobal(elemental2.dom.DomGlobal) SelectEvent(de.gishmo.example.devk.client.event.SelectEvent) Controller(com.github.nalukit.nalu.client.component.annotation.Controller) AbstractComponentController(com.github.nalukit.nalu.client.component.AbstractComponentController) Person(de.gishmo.example.devk.shared.model.dto.Person) AcceptParameter(com.github.nalukit.nalu.client.component.annotation.AcceptParameter) Composite(com.github.nalukit.nalu.client.component.annotation.Composite) ParameterConstraint(com.github.nalukit.nalu.client.constraint.annotation.ParameterConstraint) RoutingInterceptionException(com.github.nalukit.nalu.client.exception.RoutingInterceptionException) IdRule(de.gishmo.example.devk.client.constraint.IdRule) StatusChangeEvent(de.gishmo.example.devk.client.event.StatusChangeEvent) HTMLElement(elemental2.dom.HTMLElement) PersonComposite(de.gishmo.example.devk.client.ui.application.content.detail.composite.person.PersonComposite) Composites(com.github.nalukit.nalu.client.component.annotation.Composites) ApplicationContext(de.gishmo.example.devk.client.ApplicationContext) StatusChangeEvent(de.gishmo.example.devk.client.event.StatusChangeEvent) SelectEvent(de.gishmo.example.devk.client.event.SelectEvent)

Example 4 with Person

use of de.gishmo.example.devk.shared.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(1L, new Person(1, "Simpsons", "Homer", address01));
    persons.put(2L, new Person(2, "Simpsons", "Marge", address01));
    persons.put(3L, new Person(3, "Simpsons", "Bart", address01));
    persons.put(4L, new Person(4, "Simpsons", "Maggie", address01));
    persons.put(5L, new Person(5, "Simpsons", "Lisa", address01));
    Address address02 = new Address(2, "Blumenweg Nr. 13", "", "Entenhausen");
    persons.put(6L, new Person(6, "Duck", "Donald", address02));
    persons.put(7L, new Person(7, "Duck", "Trick", address02));
    persons.put(8L, new Person(8, "Duck", "Tick", address02));
    persons.put(9L, new Person(9, "Duck", "Tack", address02));
    Address address03 = new Address(2, "Am Goldberg Nr. 1", "", "Entenhausen");
    persons.put(10L, new Person(10, "Duck", "Dagobert", address03));
}
Also used : Address(de.gishmo.example.devk.shared.model.dto.Address) Person(de.gishmo.example.devk.shared.model.dto.Person)

Example 5 with Person

use of de.gishmo.example.devk.shared.model.dto.Person in project nalu-examples by NaluKit.

the class PersonService method insert.

public Person 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(maxKey, person);
    return person;
}
Also used : Person(de.gishmo.example.devk.shared.model.dto.Person)

Aggregations

Person (de.gishmo.example.devk.shared.model.dto.Person)6 HTMLElement (elemental2.dom.HTMLElement)3 AbstractComponentController (com.github.nalukit.nalu.client.component.AbstractComponentController)2 AcceptParameter (com.github.nalukit.nalu.client.component.annotation.AcceptParameter)2 Controller (com.github.nalukit.nalu.client.component.annotation.Controller)2 ApplicationContext (de.gishmo.example.devk.client.ApplicationContext)2 Routes (de.gishmo.example.devk.client.Routes)2 SelectEvent (de.gishmo.example.devk.client.event.SelectEvent)2 StatusChangeEvent (de.gishmo.example.devk.client.event.StatusChangeEvent)2 PersonServiceFactory (de.gishmo.example.devk.shared.model.service.PersonServiceFactory)2 DomGlobal (elemental2.dom.DomGlobal)2 AbstractComponent (com.github.nalukit.nalu.client.component.AbstractComponent)1 IsComponentCreator (com.github.nalukit.nalu.client.component.IsComponentCreator)1 Composite (com.github.nalukit.nalu.client.component.annotation.Composite)1 Composites (com.github.nalukit.nalu.client.component.annotation.Composites)1 ParameterConstraint (com.github.nalukit.nalu.client.constraint.annotation.ParameterConstraint)1 RoutingInterceptionException (com.github.nalukit.nalu.client.exception.RoutingInterceptionException)1 IdRule (de.gishmo.example.devk.client.constraint.IdRule)1 AddressComposite (de.gishmo.example.devk.client.ui.application.content.detail.composite.address.AddressComposite)1 PersonComposite (de.gishmo.example.devk.client.ui.application.content.detail.composite.person.PersonComposite)1