isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Haywood <...@haywood-associates.co.uk>
Subject Re: autoComplete on parameter working in 1.12.1?
Date Thu, 05 May 2016 06:39:19 GMT
Meantime, the work-around is to use a view model, eg:


import org.apache.isis.applib.annotation.Title;

@javax.xml.bind.annotation.XmlRootElement(name = "address")
@javax.xml.bind.annotation.XmlType(propOrder = { "name" } )
public class Address implements org.apache.isis.applib.services.dto.Dto {

    public static Address of(String name) {
        final Address address = new Address();
        address.setName(name);
        return address;
    }

    private String name;

    @Title
    public String getName() { return name; }
    public void setName(final String name) { this.name = name; }

}


and then:


    final ArrayList<Address> addresses = Lists.newArrayList(
            Address.of("Strawberry fields"),
            Address.of("Penny Lane"),
            Address.of("Abbey Road"),
            Address.of("Octopuses Garden"),
            Address.of("Blackburn, Lancashire"),
            Address.of("Georgia"),
            Address.of("Eiffel Tower"),
            Address.of("Isle of Wight"));

    public void updateStreetAddress(String field1, String field2, Address
field3) {

    }
    public List<Address> autoComplete2UpdateStreetAddress(@MinLength(1)
final String search) {
        return
                Lists.newArrayList(
                        FluentIterable.from(addresses).filter(x ->
x.getName().contains(search)).toList()
                );
    }


nb: need to wrap the returned list in an ArrayList, else I get a "Loading
Failed" exception.  But that's a side issue.


I wonder if there's a ticket for this missing feature... I probably
should've checked JIRA first.  Anyway, if you can't find one, go ahead and
create a new one.

Dan






On 5 May 2016 at 07:19, Dan Haywood <dan@haywood-associates.co.uk> wrote:

> I see the same behaviour (ie no drop-down) on 1.11.1; the validate doesn't
> seem to be relevant:
>
>     final ArrayList<String> addresses = Lists.newArrayList(
>             "Strawberry fields", "Penny Lane","Abbey Road","Octopuses
> Garden","Blackburn, Lancashire","Georgia","Eiffel Tower","Isle of Wight");
>
>     public void updateStreetAddress(String field1, String field2, String
> field3) {
>
>     }
>     public List<String> autoComplete2UpdateStreetAddress(@MinLength(3)
> final String search) {
>         return
>                 FluentIterable.from(addresses).filter(x ->
> x.contains(search)).toList();
>     }
>
>
> Conversely, a choices field works fine for both 1.11.1 and 1.12.1:
>
>     public List<String> choices2UpdateStreetAddress() {
>         return addresses;
>     }
>
>
> Perhaps this never worked.  Have you seen this work in any earlier
> versions?
>
>
>
>
>
>
> On 5 May 2016 at 06:57, Dan Haywood <dan@haywood-associates.co.uk> wrote:
>
>> Hmm, I can't see a mistake here.  Investigating...
>>
>> On 5 May 2016 at 03:41, Stephen Cameron <steve.cameron.62@gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> I am trying to use autoCompleteNXxxx() for the first time and not having
>>> any success with 1.12.1, it just doesn't seem to fire my routine at all.
>>> I
>>> have the following two methods an autoComplete and a validate, the first
>>> doesn't get used but the second does.
>>>
>>>     public List<String> autoComplete2UpdateStreetAddress(@MinLength(3)
>>> String search) {
>>>         return suburbs.listSuburbNamesLike(search);
>>>     }
>>>
>>>     public String validate2UpdateStreetAddress(String name) {
>>>         Suburb s = suburbs.suburbForName(name);
>>>         if (s != null) {
>>>             return null;
>>>         } else
>>>             return "Unknown suburb, please check spelling and use proper
>>> case";
>>>     }
>>>
>>> If someone can confirm its working for them in 1.12.1 or else tell me I
>>> have made a mistake.
>>>
>>> Steve Cameron
>>>
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message