aspose file tools*
The moose likes Struts and the fly likes Struts2 - linked autocompleter problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 - linked autocompleter problem" Watch "Struts2 - linked autocompleter problem" New topic
Author

Struts2 - linked autocompleter problem

Bill Luhtala
Greenhorn

Joined: Feb 20, 2009
Posts: 5
Hello,

I have 2 autocompleters on my form. After changing the value of 1st combobox (call is cb1) , the values of 2nd combo box should be changed.

This works great when I use the drop down control to change the value of cb1. The options in cb2 are changed. Problem is that when I type in the value into cb1, the ajax call to re-populate cb2 doesn't fire. It only fires if I use the drop down control to change the value in cb1. Am I missing something obvious?

Here's what my setup looks like. Thanks for any help you can give.

<s:url var="jsonList" value="/AjaxPopMyCycle.action"></s:url>
<form id="selectForm">
<sx:autocompleter
name="marketCode"
list="{'M01','M02','M03','M04','M05','M06'}"
value="M01"
valueNotifyTopics="/Changed"
forceValidOption="true"
autoComplete="true"
loadOnTextChange="true"
/>
</form>
<sx:autocompleter
name="cycleDate"
href="%{jsonList}"
autoComplete="false"
formId="selectForm"
listenTopics="/Changed"
forceValidOption="true"

/>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Did you try setting the "loadOnMinimumCount" attribute? IIRC it defaults to 3; maybe there's an off-by-one error or something?
Bill Luhtala
Greenhorn

Joined: Feb 20, 2009
Posts: 5
I added that, and now I undestand that it is really meant for a single autocompleter only, so that the list of values to choose from for the current list is reduced with each key stroke. So when you get to the end of the characters in the value, there is no need to perform the ajax query, since you've obviously already four your value. I can see the call to the server with first M, then M0

But for what I'm trying to do, I'm not autocompleting cb1, but setting up the values in cb2. The user wants to be able to either type in the value or select from the drop down, in each of the two combo boxes.

Any other ideas?

Thanks,
Bill
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh, right; my bad.

Hmm, not sure--you might be able to use one of the notifyTopics variations on autocompleter #1 and link it to a listenTopic on autocompleter #2, at least that's the approach I'd try first. The Dojo 0.4.mumble docs might help (they're a minor PITA to find, but they're still available) but... they might not--they're not on the same level as more recent Dojo versions.
Bill Luhtala
Greenhorn

Joined: Feb 20, 2009
Posts: 5
David,

I'm using struts2-dojo-plugin-2.1.6.jar.

Is this still 0.4 or is it 1.0?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

0.4.mumble--the upgrade to Dojo 1.0 was too massive, and the ROI too low. The Dojo tags have all been deprecated, in fact, as ultimately it's more reasonable to just use straight Dojo.

There may be a limited-functionality set of Ajax tags in future releases, hopefully supporting a wider range of JS libraries.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 - linked autocompleter problem