Hi Juan,

(two requests: could you send just to users@ rather than to both users@ and
also dev@; also could you subscribe to users@ so that I don't have to
approve your posting and can make sure you get any replies.  Thanks).

OK, this is easy to achieve enough to achieve.  Several ways to accomplish
it, in fact.

given:

public class Clients {
 public Client create(final @Named("Nombre") String name, final
@Named("Apellido") String surname, final @Named("Direccion") String
address, final @Named("Pais") Country country) {
 final Client client = newTransientInstance(Client.class);
client.setName(name);
client.setSurname(surname);
 client.setAddress(address);
client.setCountry(country);
persist(client);
 return client;
}

  ...
}


Option 1 [1]: if the list of Countrys is bounded and immutable (which it
probably is), then just add @Bounded as an annotation to Country class:

@Bounded
public class Country { ... }

~~~

Option 2 [2]:  if the list of Countries is the same in every context, but
is quite long and you want to filter by name, then provide an autoComplete
repository method:

@AutoComplete(repository=Customers.class)
public class Country {
    ...
}


public class Countries {
    ...
    @Hidden
    public List<Property> autoComplete(String searchPhrase) {
        return ...
    }
}


~~~
Option 3 [3]: if the list of Countries varies by context, and you don't
want to filter by name, then provide a supporting choices method:


public class Clients {
 public Client create(final @Named("Nombre") String name, final
@Named("Apellido") String surname, final @Named("Direccion") String
address, final @Named("Pais") Country country) { ... }

        public Collection<Country> choices3Create() {
             ...
        }

        ...
}

~~~

Option 4 [4]: if the list of Countries varies by context and you want to
filter by name, then provide a supporting autoComplete method:

public class Clients {
 public Client create(final @Named("Nombre") String name, final
@Named("Apellido") String surname, final @Named("Direccion") String
address, final @Named("Pais") Country country) { ... }

        public Collection<Country> choices3AutoComplete(String
searchPhrase) {
             ...
        }

        ...
}


Let us know how you get on,

Dan


PS: I saw you had @ActionSemantics(Of.SAFE) for some actions - like create
- that produce side-effects, ie are not safe.  Recommend you change
accordingly.  (In the REST API, the @ActionSemantics is translated into
either an HTTP GET, PUT or POST).


[1]
http://isis.apache.org/how-tos/how-to-03-030-How-to-specify-that-a-class-of-objects-has-a-limited-number-of-instances.html
[2]
http://isis.apache.org/how-tos/how-to-03-040-How-to-find-an-entity-(for-an-action-parameter-or-property)-using-auto-complete.html
[3]
http://isis.apache.org/how-tos/how-to-03-020-How-to-specify-a-set-of-choices-for-an-action-parameter.html
[4]
http://isis.apache.org/how-tos/how-to-03-025-How-to-specify-an-autocomplete-for-an-action-parameter.html






On 3 June 2014 23:17, Juan Martin Buireo <[email protected]> wrote:

> Hi, I am with a problem trying to implement something on Apache Isis.
> Here is what I want to do:
> I have a class Country that has a String with the name of the country.
> Also I have a class called Client which represents a client with the
> following variables: String name, String surname, String address, Country
> country. I made the setters and getters for all the properties. I also have
> the classes Countries and Clients. Both of this classes have the methods
> create and listAll. My problem is: I want to create a new Client and when I
> create it, I want to have a select with the countries that I already
> persisted. The problem is that I can't achieve this. I send the classes
> done on attachment to understand how I am doing it. But basically is that
> what I want, that when I create a new client, this one has a name, surname
> and address to complete and a select with the countries that I already
> persisted.
> Thank you
>

Reply via email to