You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Giovanni Azua <gi...@imc.nl> on 2007/09/25 11:53:12 UTC

help with autocompleter ...

hi all,

I would like to display an autocompleter associated with a 
application-defined Javabean and have it picking up the right key and 
value out of the bean properties (getters). I have hard time following 
the examples as I cant find any that provides the code required on the 
Action side. I would prefer staying away from magical encodings etc just 
to have it pull the Id and Value out of the bean property as shown below.

Say I have e.g.:

********************************************************
@Immutable
class Customer {
    private String id;
    private String name;
    public Customer(String id, String name) {
           this.id=id;
           this.name=name;
    }
    public String getName {
          return name;
    }
    public String getId {
          return id;
    }
}
**********************************************************
public MyAction extends ActionSupport {
    List<Customer> customers = new ArrayList<Customer>();
    @Override
    public String execute() throws Exception {
        super.execute();
        customers.clear();
        customers.addAll(findSomeCustomers());
        return SUCCESS;
    }
    public List<Customer> getCustomers() {
        return this.customers;
    }
}
**********************************************************
example.jsp
**********************************************************
<s:head theme="ajax"/>       
<s:form action="Something.action" method="post" theme="%{currentTheme}">
     <s:autocompleter name="customer" list="customers" />       
</s:form>

I cant find THE way to say:

autocompleter VALUE is Customer.name
autocompleter KEY is Customer.id

TIA,
regards,
Giovanni

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: help with autocompleter ...

Posted by Giovanni Azua <gi...@imc.nl>.
Ohh just found it ... it is using listKey and listValue

**********************************************************
example.jsp
**********************************************************
<s:head theme="ajax"/>      
<s:form action="Something.action" method="post" theme="%{currentTheme}">
    <s:autocompleter name="customer" list="customers" listKey="id" 
listValue="name" />      
</s:form>

regards,
Giovanni

Giovanni Azua wrote:
> hi all,
>
> I would like to display an autocompleter associated with a 
> application-defined Javabean and have it picking up the right key and 
> value out of the bean properties (getters). I have hard time following 
> the examples as I cant find any that provides the code required on the 
> Action side. I would prefer staying away from magical encodings etc 
> just to have it pull the Id and Value out of the bean property as 
> shown below.
>
> Say I have e.g.:
>
> ********************************************************
> @Immutable
> class Customer {
>    private String id;
>    private String name;
>    public Customer(String id, String name) {
>           this.id=id;
>           this.name=name;
>    }
>    public String getName {
>          return name;
>    }
>    public String getId {
>          return id;
>    }
> }
> **********************************************************
> public MyAction extends ActionSupport {
>    List<Customer> customers = new ArrayList<Customer>();
>    @Override
>    public String execute() throws Exception {
>        super.execute();
>        customers.clear();
>        customers.addAll(findSomeCustomers());
>        return SUCCESS;
>    }
>    public List<Customer> getCustomers() {
>        return this.customers;
>    }
> }
> **********************************************************
> example.jsp
> **********************************************************
> <s:head theme="ajax"/>       <s:form action="Something.action" 
> method="post" theme="%{currentTheme}">
>     <s:autocompleter name="customer" list="customers" />       </s:form>
>
> I cant find THE way to say:
>
> autocompleter VALUE is Customer.name
> autocompleter KEY is Customer.id
>
> TIA,
> regards,
> Giovanni
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org