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: [email protected]
> To: [email protected]
> 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"
>