Hi Gerard,

Thanks for you pointer to the wiki.
I must have overlooked the documentation in wiki, 
because indeed with that information I will be able to get it working.

With kind regards,
  Marco



-----Original Message-----
From: Gerald Müllan [mailto:[EMAIL PROTECTED] 
Sent: woensdag 17 januari 2007 13:57
To: MyFaces Discussion
Subject: Re: How to use inputSuggest(Ajax)

Hi,

you can find any information about inputSuggestAjax on the
corresponding wiki site:

http://wiki.apache.org/myfaces/InputSuggestAjax

You should use this component if you need something like autoSuggest
functionality. The typed string into the input is passed to the
suggestedItems method. It was designed to give the user a dynamically
retrieved list of suggested Strings back.

If you need something like the selectItems approach, it is not the
right choice for you.

cheers,

Gerald

On 1/16/07, Beelen, Marco <[EMAIL PROTECTED]> wrote:
>
>
>
> Hello,
>
> I would like to use some inputSuggest functionality in my application, but
> can't get the inputSuggest or inputSuggestAjax component working properly.
>
> What I can't appair to get correct is return types on the methods on my
> managed-bean which provided the available options and the handling of a
> submitted value.
>
> In my application I have a class Product with an id and a name and my DAO
> provides me with a List<Product>.
>
> Prior to my attempts to use inputSuggest I was using:
>
> <h:selectOneMenu value="#{managedBean.selectedProductId}">
>         <t:selectItems
>                 value="#{managedBean.products}"
>                 var="product"
>                 itemLabel="#{product.name}"
>                 itemValue="#{p.id}"
>         />
>  </h:selectOneMenu>
>
> And during the handling of the form I would lookup the proper Product by
> it's id.
>
> My assumption was that <s:inputSuggest> also could work with <t:selectItems>
> so I wrote the xhtml like this:
> <s:inputSuggest value="#{managedBean.name}" required="true">
>         <t:selectItems
>                  value="#{managedBean.products}"
>                 var="product"
>                 itemLabel="#{product.description}"
>                  itemValue="#{product.description}"
>         />
> </s:inputSuggest>
>
>  But that causes a ClassCastException during rendering.
>
> java.lang.ClassCastException: [Ljavax.faces.model.SelectItem;
>         at
> org.apache.myfaces.custom.suggest.InputSuggestRenderer.getChoices(InputSuggestRenderer.java:224)
>         at
> org.apache.myfaces.custom.suggest.InputSuggestRenderer.encodeBegin(InputSuggestRenderer.java:100)
>         at
> javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:512)
>         at
> com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSupport.java:232)
>         at ..
>
> So I switched to:
>
> <s:inputSuggest  value="#{mangedBean.name}" required="true">
>         <f:selectItems value="#{managedBean.productSuggests}"/>
> </s:inputSuggest>
>
> Where the managedBean.getProductSuggests() returns a Map<String, String>
> Now the page get rendered and I can enter a product name with suggestion.
>   ( Although with some style issues with the suggestions being underneath
> other form elements, but that a minor issue for later. )
>
> In method called by the action of my commandButton on the from I would like
> to get the appropreate Product-object, so I wanted to perform a lookup based
> upon the field name of the managedBean. Only the value of that field wasn't
> the exact value of the suggestion but something like
> "m:_id100_choicePRODUCTNAME"
>
> I don't know where the prefix 'm:_id100_choice" comes from, but I don't
> suppose mu managedBean should be responsible for stripping it.
>
> Is this a bug or am I doing something wrong?
>
>
> As an alternative I was looking at <s:inputSuggestAjax> so I changed the
> xhtml to:
> <s:inputSuggestAjax
>         suggestedItemsMethod="#{managedBean.productSuggests}"
>         value="#{mangedBean.name}" charset="utf-8" />
>
>
>
> I tried to implement productSuggests-method with returning: Map<String,
> String>, List<String>, List<SelectItem>, but nothing worked.
>
> In all cases the page does get rendered, but no inputSuggest is available
> due to JavaScript-errors. ('Can't "move focus to the control because it is
> invisible, not enalbed or of a type that doesn't accept focus")
>
>
> Any (input)suggestion on how to work with these components is greatly
> appreciated.
>
> With kind regards,
>     Marco Beelen
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
>  Notice: This e-mail message, together with any attachments, contains
>  information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
>  New Jersey, USA 08889), and/or its affiliates (which may be known
>  outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
>  and in Japan, as Banyu - direct contact information for affiliates is
>  available at http://www.merck.com/contact/contacts.html)
> that may be
>  confidential, proprietary copyrighted and/or legally privileged. It is
>  intended solely for the use of the individual or entity named on this
>  message. If you are not the intended recipient, and have received this
>  message in error, please notify us immediately by reply e-mail and then
>  delete it from your system.
>
>
> ------------------------------------------------------------------------------


-- 
http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces




------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,
New Jersey, USA 08889), and/or its affiliates (which may be known
outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD
and in Japan, as Banyu - direct contact information for affiliates is 
available at http://www.merck.com/contact/contacts.html) that may be 
confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this 
message. If you are not the intended recipient, and have received this 
message in error, please notify us immediately by reply e-mail and then 
delete it from your system.

------------------------------------------------------------------------------

Reply via email to