we are currently migrating to PrimeFaces and we encountered an issue at the moment with the autocomplete component. The problem is, that only the query string is passed to the oncomplete-method as seen in the following source code snippet of PrimeFaces.
AutoComplete.java
Code: Select all
public void broadcast(javax.faces.event.FacesEvent event) throws javax.faces.event.AbortProcessingException {
super.broadcast(event);
FacesContext facesContext = FacesContext.getCurrentInstance();
MethodExpression me = getCompleteMethod();
if(me != null && event instanceof org.primefaces.event.AutoCompleteEvent) {
suggestions = (List) me.invoke(facesContext.getELContext(), new Object[] {((org.primefaces.event.AutoCompleteEvent) event).getQuery()});
...
Consider the following: There are several autocomplete components on the mask. Each one stands for a different data group, but the backend logic is always the same (same oncomplete method). In the markup it's possible to tell the component which is the relevant group key; a group key can be understood as "Barca, Real, Munich". So by switching on the group key value in the oncomplete method you'd be able to deliver the players for the desired club.
Using IceFaces this was possible by adding some f:attributes to their autocomplete component and later on fetch these values from the FacesEvent. I figured out that the AutoCompleteEvent contains my attributes but I'm not able to read them since the event is "thrown away" during the reflection.
So, could it be possible to add an option (addEvent, e.g.) to enable something like this: myBean.oncomplete(org.primefaces.event.AutoCompleteEvent event)? I'd still am able to fetch the query and in addition access my attributes:
enhancement AutoComplete.java
Code: Select all
if(me != null && event instanceof org.primefaces.event.AutoCompleteEvent) {
suggestions = (getAddEvent()) ? (List) me.invoke(facesContext.getELContext(), new Object[] {(org.primefaces.event.AutoCompleteEvent) event) : (List) me.invoke(facesContext.getELContext(), new Object[] {((org.primefaces.event.AutoCompleteEvent) event).getQuery()});
...
Regards Dennis