-
1. Re: autocomplete render other components
apanag Apr 26, 2012 3:32 PM (in response to apanag)I found a workaround to my problem. Thus, the outputText field "out1" gets properly updated with each ajax call of the autocomplete method.
<h:form id="myform">
<a4j:jsFunction name="updateOutput" render="out1" /><h:outputText id="out1" value="#{mybean.value}" />
<rich:autocomplete
mode="ajax"
value="#{bean.criteria}"
minChars="1"
autocompleteMethod="#{action.method}"
fetchValue="#{result.name}"
var="result"oncomplete="updateOutput();"
render="myform:out2">
<h:column>
<h:outputText value="#{result.value}" />
</h:column>
</rich:autocomplete>
<h:outputText id="out2" value="#{mybean.value}" />
</h:form> -
2. Re: after autocomplete - render other components
apanag Apr 27, 2012 11:28 AM (in response to apanag)My first workaround doesn't solve the problem 100%: when the is no character left in the input field, the rich:autocomplete doesn't send any ajax request.
Even if you set the minChars to 0, the value taken by the element is 1. It is a design decision. Maybe the RichFaces guys want to evaluate it.
I ended up with a little more complex workaround that works for all cases:
<h:form id="myform"> <h:outputText id="out1" value="#{mybean.value}" /> <a4j:jsFunction name="updateOutputFunction" render="out1,out2" action="#{mybean.updateValue()}"> <a4j:param name="bufferParam" assignTo="#{mybean.bufferParam}" /> </a4j:jsFunction> <rich:autocomplete id="myAutocompleteBox" mode="ajax" value="#{bean.criteria}" minChars="1" autocompleteMethod="#{action.method}" fetchValue="#{result.name}" var="result" onkeyup="updateOutputFunction(document.getElementById('myform:myAutocompleteBoxInput').value);" > <h:column> <h:outputText value="#{result.value}" /> </h:column> </rich:autocomplete> <h:outputText id="out2" value=" #{mybean.value}" /> </h:form>
Mybean.java
...
private String bufferParam; public String getBufferParam(){ return bufferParam; } public String setBufferParam(String bufferParam){ this.bufferParam = bufferParam; } public void updateValue(){ value = bufferParam; }