-
1. rich:autocomplete: How to set two hiddenfield?
nbelaevski Mar 29, 2011 2:28 PM (in response to fred-at-coding)Hi Fred,
Have you checked rich:select component? It allows you to place selected object into model without any additional application code required.
-
2. rich:autocomplete: How to set two hiddenfield?
fred-at-coding Apr 1, 2011 1:15 PM (in response to nbelaevski)Hi Nick,
thanks a lot for your reply.
This is a good "workaround" i can use, but it's true that I wanted to try a code like 'a4j:ajax' with the 'oncomplete' event to get the ID retreive and to "store" it in a bean property. If this is not possible, I'll certainly use rich:select.
This may be consuming (in memory) if my rich:select is hosting 10000 entries.
What do you think about it ?
Originaly, I wanted to use autocomplete AJAX because of the "asynchronous" / 'lite' memory consuming.
Thanks again for your reply,
Fred
-
3. rich:autocomplete: How to set two hiddenfield?
boy18nj Apr 2, 2011 11:05 AM (in response to fred-at-coding)just trying to understand your problem, you are trying to retrieve the id property of autocompleteSearchEditor. if yes can you post its code.
-
4. Re: rich:autocomplete: How to set two hiddenfield?
fred-at-coding Apr 3, 2011 7:55 AM (in response to boy18nj)Hi,
Sorry if i'm not clear.
What i Want to do is simple : searching an editor by it s name, but When selected, store its name in a input text and its ID In an other field.
The autocompleteSearchEditor just return a list of object 'teditor' that is a POJO annoted @entity describing the teditor data in the database.
So when returned, I am able to find the ID from the object returned.
To traduce this in code:
In a form, i have some input fields. One of them is an input tex t and the other is an hidden field.
When searching entering first char of an editor, i ve got a list of selected editors. I can select my editor's name. All is cool.
What is missing, as a functionnality for me, is to be able to store the ID of the editor in a other variable, and when a send my form for processing I can get the editor object from database by its ID.
Am I more clear now ?
Thanks
Fred
PS: here is the code (since I was not on my MAC the first time I wrote my answer)
/**
* autocompleteEditor
* @param pattern
* @return
*/
public List<Teditor> autocompleteSearchEditor(String pattern)
{
try {
List<Teditor> list = editorEJB.listEditors(pattern);
if (list==null)
return new ArrayList<Teditor>();
else
return list;
} catch (Exception e) {
return new ArrayList<Teditor>();
}
}
-
5. rich:autocomplete: How to set two hiddenfield?
boy18nj Apr 3, 2011 11:37 PM (in response to fred-at-coding)cool I understood this thing. I assume when you say ID it is an property of object/entity teditor.
Already you are using this to get the name of selected editor-
<h:outputText value="#{autocomplete_editor.name}"/>
Why not output the ID value also?
<h:outputText value="#{autocomplete_editor.ID}"/>
And you can make it hidden also if you want.
-
6. rich:autocomplete: How to set two hiddenfield?
fred-at-coding Apr 5, 2011 1:14 PM (in response to boy18nj)because <h:outputText value="#{autocomplete_editor.name}"/> has only a means between the "rich:column" definition.
however, i'll try your idea. If it works, i'll feedback the full solution.