This content has been marked as final.
Show 6 replies
-
1. Re: suggestionbox and onselect
damianharvey Apr 10, 2007 9:13 AM (in response to liuliu)You shouldn't need to use a4j:support. Are you using the rich:suggestionBox? If so you create a bean action called by the suggestionAction eg:
<rich:suggestionBox suggestionAction="#{searchScheduleHelper.suggest}" ...etc
An example of using a Database to populate the suggestionAction looks like this:public List suggest(Object in) { String pref = in.toString().toLowerCase() + "%"; Query q = entityManager.createQuery("select u from UnLocode u where lower(u.nameWoDiacritics) like :pref") .setParameter("pref", pref) .setMaxResults(10); ArrayList results = (ArrayList)q.getResultList(); return results; }
-
2. Re: suggestionbox and onselect
liuliu Apr 10, 2007 11:00 AM (in response to liuliu)hello,
thanks to your reply. i think i have not explain my problem clearly.
what i search is when the user select a value in the list, i should rebuild some other list. suggestionAction is make for when we are typing in the text box. my problem is i have no way to know which line is selected by user. -
3. Re: suggestionbox and onselect
ilya_shaikovsky Apr 11, 2007 4:13 AM (in response to liuliu)<h:inputText value="#{bean.property}" id="test"/> <rich:suggestionbox for="test" width="200" height="200" suggestionAction="#{bean.autocomplete}" var="cap"> <a4j:support event="onselect" reRender="output"/> <h:column> <h:outputText value="#{cap.text}"/> </h:column> </rich:suggestionbox>
As far as you have the input and suggestion in one region bean.property will be submitted on ajax request from support. So you may use bean.getProperty to get this value. -
4. Re: suggestionbox and onselect
liuliu Apr 11, 2007 5:12 AM (in response to liuliu)
yes, you are right. i have bean.property,but sometimes we want the id not the description. i noticed the component htmlsuggestionbox has getrowdata, why not pass the rowdata to method onselect?
l -
5. Re: suggestionbox and onselect
ilya_shaikovsky Apr 11, 2007 5:22 AM (in response to liuliu)But having one of the objects property you may get another for this object i think..
-
6. Re: suggestionbox and onselect
sijk Apr 19, 2007 7:47 AM (in response to liuliu)"liuliu" wrote:
yes, you are right. i have bean.property,but sometimes we want the id not the description. i noticed the component htmlsuggestionbox has getrowdata, why not pass the rowdata to method onselect?
Have you found a solution for this problem?
I would also like to pass the selected id to the bean so other information on the page could be updated.