-
1. Re: commandButton's action not executed inside a rich:suggestionbox
ilya_shaikovsky Aug 2, 2010 6:47 AM (in response to zlatko99)1 of 1 people found this helpfulIt's not intended to works in that way. I do not see the use-case for using buttons in autocomplete component list. Actually we have such open requests in jira https://jira.jboss.org/browse/RF-6577 - but them not planned for now and look like not native functionality for the component.
-
2. Re: commandButton's action not executed inside a rich:suggestionbox
zlatko99 Aug 3, 2010 8:17 PM (in response to ilya_shaikovsky)Thanks for the response, Ilya.
I partly agree with you that the functionality I'm looking for is perhaps out of context of the rich:suggestionbox component. But, take the following use-case in mind:
You have a social network application with many registered users. You log in to the app, go to the "Search for friends..." text field, enter a few characters of the first name of the person you're looking for, the suggestion box gives you all the available options for the entered name, and directly in the suggestion row you click on the button "Send a friend request" for the appropriate person. Isn't this functionality convenient?
For everyone that think so, I have found a pretty clean workaround. The trick is to declare an a4j:jsFunction component outside the rich:suggestionbox and call the javascript from inside the h:column using plain old <input type="button".../> component. See the example below:
<h:form> <a4j:jsFunction name="addAsFriendJS" action="#{searchUserManager.addAsFriend()}" oncomplete="showInfoMessage();" reRender="friendSuggestions, addedAsFriends, addedAsFriendCount" immediate="true"> <a4j:actionparam name="friendId" assignTo="#{searchUserManager.friendId}"/> </a4j:jsFunction> <h:inputText id="userSearcher" title="Search for users..." style="width:100%"/> <rich:suggestionbox suggestionAction="#{searchUserManager.findUsers}" var="searchUser" for="userSearcher" fetchValue="#{searchUser.firstName} #{searchUser.lastName}" width="300" minChars="3" nothingLabel="No users found" ignoreDupResponses="true" immediate="true" eventsQueue="searchUserQueue" > <h:column> <img src="resource/image?id=#{searchUser.thumbnail}&type=normal" border="0" /> </h:column> <h:column> <h4 align="left">#{searchUser.firstName} #{searchUser.lastName}</h4> <a4j:outputPanel layout="block" rendered="#{searchUser.mutualFriendCount gt 0}"> <h:outputText value="#{searchUser.mutualFriendCount} mutual friend#{searchUser.mutualFriendCount gt 1 ? 's' : ''}" styleClass="text"/> </a4j:outputPanel> </h:column> <h:column > <a4j:outputPanel layout="none" rendered="#{searchUser.addable}"> <div align="right"> <input type="button" value="#{messages['add_as_friend']}" onclick="javascript:addAsFriendJS('#{searchUser.userId}')"/> </div> </a4j:outputPanel> </h:column> </rich:suggestionbox> </h:form>
I would be interested in any thoughts one might have on this one.
Thanks,
Zlatko
-
3. Re: commandButton's action not executed inside a rich:suggestionbox
ilya_shaikovsky Aug 4, 2010 4:55 AM (in response to zlatko99)yes.. I thought about such case Probably there are some separate popup component needed which will works just as panel and not as input extension.
But your workaround looks really cool.. Why I do not thought about that Thanks for your update! Good thread for users knowledgebase.