How To: Check and modify the values from h:inputTexts when t
konstantin_spirov Jul 21, 2009 12:32 PMThis thread is created to find a sollution for the issues, raised in the comments of https://jira.jboss.org/jira/browse/RF-7527. Let's summarize briefly:
Imagine you liked the following example from RichFaces Demo -RichInput:SuggestionBox:ObjectsUsageExample.
Now you want to add such "combobox-like" component in and application, where a field is validated (or changed) each time, when the focus goes to some other field. Example: seam-gen generated application.
See an example source code:
<h:form id="form">
<a4j:queue/>
<a4j:outputPanel id="XXXXX">
<h:panelGrid columns="2">
<h:outputText value="Input with states names suggestions"/>
<h:panelGrid columns="2" border="0" cellpadding="0" cellspacing="0">
<h:inputText style="margin:0px;" id="statesinput" value="#{userBean.name}">
<a4j:support event="onblur" reRender="XXXXX" bypassUpdates="true" ajaxSingle="true"/>
</h:inputText>
<h:graphicImage value="/images/icons/arrow.png"
onclick="#{rich:component('suggestion')}.callSuggestion(true)"
alt=""/>
</h:panelGrid>
</h:panelGrid>
<rich:suggestionbox height="200" width="200"
suggestionAction="#{capitalsBean.autocomplete}" var="cap"
for="statesinput" fetchValue="#{cap.name}" id="suggestion" tokens=",">
<h:column>
<h:graphicImage value="#{cap.stateFlag}"/>
</h:column>
<h:column>
<h:outputText value="#{cap.name}"/>
</h:column>
</rich:suggestionbox>
</a4j:outputPanel>
</h:form>
Unfortunately, this implementation (the only obvious) doesn't run flawlessly, see: http://www.youtube.com/watch?v=3lQR5iAv_8k
In the comments, connected with the issue, Mr. Shaikovsky gave explanation why this happens. But now the question is what to do.
I's obvoius, that we need solution that will allow us:
1) To validate the field from the server each time the focus is lost
2) To correct(change) the field from the server (and to make user able to see the changes)
3) This (1 and 2) should work
A) for fields manually entered (without using suggestionbox)
B) For fields entered from suggestion box (permited navigation: with keyboard or with mouse).
Otherwise this approach with suggestion box will be usable only with applications, where the validation is made with "submit" button - we are limiting the scope of this good component.
So let's think what to do.