I tried doing this onSelectTopics of first autocompleter to select value of the second autocompleter but didn't work. Any suggessions? First autocompleter <sj:autocompleter ........ onChangeTopics="publisherDescChange" onSelectTopics="publisherDescSelect" ..... /> Second autocompleter <sj:autocompleter id="publisherCodeId" ......... listenTopics="publisherDescChange" /> $.subscribe('publisherDescSelect', function(event, data) {
var ui = event.originalEvent.ui; var message = ui.item.value; if(ui.item.key) { message = '( '+ ui.item.key +' ) '+message; } $('#topics').html('<i>'+message+'</i>'); $("#publisherCodeId option[value='" + ui.item.text + "']"); $("#publisherCodeId option[text='" + ui.item.message + "']"); $("#publisherCodeId option[val='" + ui.item.text + "']").attr("selected","selected"); }); > From: zy...@hotmail.com > To: user@struts.apache.org > Subject: RE: <sj:autocompleter> dependable > Date: Wed, 26 Aug 2015 09:55:53 -0400 > > As mentioned earlier have 2 autocompleters with same list of Managers. Only > difference being the Manger.description is shown as drop down in one and > Manager.code is shown in the drop down in another. > > > In the first autocompleter when Manager.description is selected it should > automatically select the second autocompleter with corresponding Manager.code > value and vise versa. > > > How to do this? > > > I am new to both struts2 and jquery. Please need help with this. > > I tried adding the subscribe mentioned below that didn't auto select the > option in the second autocompleter. > > > > From: mgai...@hotmail.com > > To: user@struts.apache.org > > Subject: RE: <sj:autocompleter> dependable > > Date: Tue, 25 Aug 2015 07:09:12 -0400 > > > > you will notice in the autocompleter tutorial posted at > > http://struts.jgeppert.com/struts2-jquery-showcase/autocompleter-json.action;jsessionid=CE13A626C1A38AC66A47344D139993DE > > > > there exists a <sj:autocompleter with > > onChangeTopics="autocompleteChange"but there is no (jquery) function > > subscribed to listen to autocompleteChange topic .. > > if you look at bottom of tutorial you will see: > > $.subscribe('autocompleteChange', function(event, data) { > > var ui = event.originalEvent.ui; > > var message = ui.item.value; > > if(ui.item.key) { > > message = '( '+ ui.item.key +' ) '+message; > > } > > $('#topics').html('<b>'+message+'</b>'); > > }); > > > > when you publish an event topic you will also need to subscribe listener > > for the same event topic > > HTH > > Martin > > > > > From: zy...@hotmail.com > > > To: user@struts.apache.org > > > Subject: <sj:autocompleter> dependable > > > Date: Mon, 24 Aug 2015 15:59:49 -0400 > > > > > > I am new to struts2 and need help with the struts2 jquery autocompleter > > > tag > > > > > > > > > > > > Have an object > > > > > > Publisher > > > > > > code > > > > > > description > > > > > > > > > > > > > > > In Action > > > > > > getPublishers() > > > > > > > > > > > > I am trying to use 2 dependable sj:autocompleter tags. In both it should > > > display the Publishers list but > > > > > > in one it should display the description of publisher and in another it > > > should display the code > > > > > > > > > If the user changes discription in one of the autocompleter then it > > > should change the code and vise versa on the second autocompleter. > > > > > > > > > > > > I am not not sure how the selected value goes to the action class. I'll > > > want the selected publisher to be set to corresponding Publisher object > > > selected to the selectedPublisherOfPublisherDescription attribute. > > > > > > > > > How will it change the second autocompleter code on change of the first > > > one. But, it's not working. Your help is appreciated. > > > > > > > > > I tried the below > > > > > > <sj:autocompleter > > > > > > id="publisherDescriptionId" > > > > > > name="publisherDescription" > > > > > > > > > value="%{selectedPublisherOfPublisherDescription}" > > > > > > list="%{publishers}" > > > > > > listValue="description" > > > > > > listKey="code" > > > > > > selectBox="true" > > > > > > selectBoxIcon="true" > > > > > > label="Publisher Description" > > > > > > onChangeTopics="publisherChange" > > > > > > /> > > > > > > > > > > > > <sj:autocompleter > > > > > > id="publisherCodeId" > > > > > > name="publisherCode" > > > > > > value="%{selectedPublisherOfMPublisherCode}" > > > > > > list="%{publishers}" > > > > > > listValue="code" > > > > > > listKey="description" > > > > > > selectBox="true" > > > > > > selectBoxIcon="true" > > > > > > label="Publisher Code" > > > > > > listenTopics="publisherChange" > > > > > >