struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: <sj:autocompleter> dependable
Date Thu, 27 Aug 2015 12:30:33 GMT
based on your other emails it appears you are missing your Struts action class
you are also probably missing struts.xml which defines the Struts Action class and results
and any configuration params
whats more the jsp you are using probably does not have sj="/struts-jquery-tags" declaration

so its best you start with a complete download of 
base the basic struts-jquery-tags with a working Struts Action class

download from
https://github.com/struts-community-plugins/struts2-jquery
download zip

once you have the base struts2-jquery plugin war built and deployed to your container
(if you have any problems packaging or deploying you can ping users@maven.apache.org)

then you can add in the sj:autocompleter example from: 
http://struts.jgeppert.com/struts2-jquery-showcase/index.action
to your main jsp

its important that you have a complete Struts Action class deployed and working before adding
in the sj:autocompleter code

Nota Bene:
list="%{customers}" where variable customers should be populated from Action
if the variables are NOT populated in action you can always use hardcoded values 
list="[Mary, Lukasz, Dave]"
then once you get familiar with Beans and how to use populate accessors and mutators with
bean contents to customers then you can switch back to populating your list
list="%{customers}" 

you can also use also use this shortcut to convert array of strings to 'customers'
private List<String customers;
public List<String> getCustomers() {
    return Arrays.asList("Mary", "Lukasz", "Dave");
}

HTH
Martin 
______________________________________________ 



> From: zyxrm@hotmail.com
> To: user@struts.apache.org
> Subject: RE: <sj:autocompleter> dependable
> Date: Wed, 26 Aug 2015 22:07:57 -0400
> 
> Thanks, for trying to help me on this. I did add the subscribe java script functions
as you've suggested. Still not working. Please need help.
>  
> 		<sj:autocompleter
> 
> id="publisherNameId"
> 
> name="publisherName"
> 
> list="%{publishers}"
> 
> listValue="name"
> 
> listKey="code"
> 
> listLabel="code"
> 
> selectBox="true"
> 
> selectBoxIcon="true"
> 
> key="label.publisherName"
> 
> onChangeTopics="autocompleteChange"
> 
> onFocusTopics="autocompleteFocus"
> 
> onSelectTopics="autocompleteSelect"
> 
> size="34"
> 
> maxlength="34"
> 
> />
> 
> 
> 		<sj:autocompleter
> 
> id="publisherCodeId"
> 
> name="publisherCode"
> 
> list="%{publishers}"
> 
> listValue="code"
> 
> listKey="name"
> 
> selectBox="true"
> 
> selectBoxIcon="true"
> 
> key="label.publisherCode"
> 
> size="20"	
> 
> maxlength="20"
> 
> onChangeTopics="autocompleteChange"
> 
> onFocusTopics="autocompleteFocus"
> 
> onSelectTopics="autocompleteSelect"	
> 
> />
> 
> 
> <script type="text/javascript" >
> 
> $(document).ready(function() {
> 
> 
> 
> $.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>');
> });
> 
> 
> $.subscribe('autocompleteFocus', function(event, data) {
> 
> var ui = event.originalEvent.ui;
> 
> var message = ui.item.value;
> 
> if(ui.item.key) {
> 
> message = '( '+ ui.item.key +' ) '+message;
> 
> }
> $('#topics').html('<u>'+message+'</u>');
> });
> 
> 
> 
>   $.subscribe('autocompleteSelect', 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>');
> });
> 
> });	
> </script>
>  
> 
>  
> > From: mgainty@hotmail.com
> > To: user@struts.apache.org
> > Subject: RE: <sj:autocompleter> dependable
> > Date: Wed, 26 Aug 2015 20:36:27 -0400
> > 
> > MG>follow the example to the letter
> > 
> > 
> > > From: zyxrm@hotmail.com
> > > To: user@struts.apache.org
> > > Subject: RE: <sj:autocompleter> dependable
> > > Date: Wed, 26 Aug 2015 13:21:13 -0400
> > > 
> > > 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"                      
> > > .....
> > > />
> > >  
> > MG> <!-- handle publisherDescChange first with subscribe statement below -->
> > $.subscribe('publisherDescChange', 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>');
> > 	});>  
> > MG>
> > 
> > MG><!-- handle publisherDescSelect  with subscribe statement below -->
> > $.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>');
> > 	});
> > MG>
> > 
> > http://struts.jgeppert.com/struts2-jquery-showcase/autocompleter-json.action;jsessionid=CE13A626C1A38AC66A47344D139993DE
> > 
> > MG>Now when you select the list is the javascript function for second subscribe('publisherDescSelect'
... called ?
> > MG>Now when you change the list is the javascript function for first subscribe('publisherDescChange'
... called ?
> > MG>its important you implement everything you see in the autocompleter example
> > MG>if you do not your results will be 'undefined'
> > >  
> > > > From: zyxrm@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: mgainty@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: zyxrm@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"
> > > > > >  		 	   		  
> > > > >  		 	   		  
> > > >  		 	   		  
> > >  		 	   		  
> >  		 	   		  
>  		 	   		  
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message