my dog learned polymorphism*
The moose likes JSF and the fly likes PartialSubmit on inputText and selectOneChoice does not work... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "PartialSubmit on inputText and selectOneChoice does not work..." Watch "PartialSubmit on inputText and selectOneChoice does not work..." New topic
Author

PartialSubmit on inputText and selectOneChoice does not work...

Elia Gaglio
Greenhorn

Joined: Aug 15, 2011
Posts: 2
Hi everyone,
i try to create a simple filter with autocompletion.... A user put some text in an inputText and when its lenght is greater than two words i use a DAO to query the database in order to get a lot of suggestions to the user.... So i'd like to refresh this suggestion (i use a selectonechoice component) when i've got the result from the query and then to refresh the inputText when the user select one of that choice...

My jsf page follows (i put only some components in this example):

<h:form>
<tr:panelFormLayout rows="11">
<tr:inputText label="Fornitore" binding="#{FilterOrder.fornitore}" id="fornitore" immediate="true"
partialTriggers="fornitore suggestion" valueChangeListener="#{FilterOrder.searchGoogleLike}" autoSubmit="true"/>
<tr:selectOneChoice
label="Forse cerchi..."
id="suggestion"
autoSubmit="true"
immediate="true"
partialTriggers="suggestion fornitore"
valueChangeListener="#{FilterOrder.setSuggestionAsChoice}"
binding="#{FilterOrder.forseCercaviSelect}">
<f:selectItems value="#{FilterOrder.suggestions}" />
</tr:selectOneChoice>
</tr:panelFormLayout>
</h:form>



An these are the backing bean methods that i invoke (i don't put the query in this example):

private SelectItem[] suggestions;

public void setSuggestions(SelectItem[] suggestions) {
this.suggestions = suggestions;
}

public SelectItem[] getSuggestions() {
return suggestions;
}

public void searchGoogleLike(ValueChangeEvent valueChangeEvent) {
if (((String)valueChangeEvent.getNewValue()).length() > 2) {
SupplierLikeFilterDAO suppLikeDAO = new SupplierLikeFilterDAO();
List<SupplierLikeFilterOrder> queryResult = new ArrayList<SupplierLikeFilterOrder>();
queryResult.addAll(suppLikeDAO.listSupplierLike((String)valueChangeEvent.getNewValue()));
suggestions = new SelectItem[queryResult.size()];
for(int i=0; i<queryResult.size(); i++) {
SelectItem si = new SelectItem();
si.setValue(queryResult.get(i).getSupName());
si.setLabel(queryResult.get(i).getSupName());
suggestions[i] = si;
}
}
}

public void setSuggestionAsChoice(ValueChangeEvent valueChangeEvent) {
this.fornitore.resetValue();
this.fornitore.setValue(valueChangeEvent.getNewValue());
}



With this code components refresh does not work.... any idea please???

thanks a lot!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PartialSubmit on inputText and selectOneChoice does not work...
 
Similar Threads
PPR with two tr:selectOneChoice problem
af:selectOneChoice - setting default selected value other than the first in line
PartialTrigger with two inputDate does not work properly...
Trinidad commandButton needs clicked twice to fire bean
valueChangeListener does not work if i give rendered property.