掲示板

retrieving data from data base into a text box in portlet

12年前 に sandeep tripathi によって更新されました。

retrieving data from data base into a text box in portlet

Regular Member 投稿: 100 参加年月日: 11/10/19 最新の投稿
Hi everyone ,

i had created a portlet which has a search functionality it has a text box which should take location in country , i want to create a auto suggestion for that field data

if any one have any idea how to make so .

Regards
Sandeep
thumbnail
12年前 に Swapnil Jadhav によって更新されました。

RE: retrieving data from data base into a text box in portlet

New Member 投稿: 23 参加年月日: 11/03/04 最新の投稿
Hi Sandeep,

There are many ways for creating auto suggest text box. You can use only Java Script or you can use AJAX with Javascript etc. But the Best Possible way of creating this by using the Alloy UI Autocomplete text box. You can go through this Demo which is present on the Alloy UI Site. Only you need to do some changes as per your requirement.

Regards
Swapnil
thumbnail
12年前 に Mayur Patel によって更新されました。

RE: retrieving data from data base into a text box in portlet

Expert 投稿: 358 参加年月日: 10/11/17 最新の投稿
Hi Sandeep,

you can try it out with different samples provided for Alloy,

http://www.liferay.com/community/liferay-projects/alloy-ui/demo?title=community-liferay-projects-alloy-ui-demos-autocomplete

There are many ways you can create serverresource url and populate data through json.
http://hiteshmethani.blogspot.com/2011/06/using-serveresource-with-aui-io-request.html

HTH,
Mayur
12年前 に sandeep tripathi によって更新されました。

RE: retrieving data from data base into a text box in portlet

Regular Member 投稿: 100 参加年月日: 11/10/19 最新の投稿
Hi Mayur,

thanks for that help but I need to retrieve a data which are fetch from database use in our application .
i had use getdata.jsp which is use for getting the result set from the database and in view.jsp i had call that jsp using a javascript but it does not populate the data .

can you help me in this .

Regards
Sandeep
thumbnail
12年前 に Mayur Patel によって更新されました。

RE: retrieving data from data base into a text box in portlet

Expert 投稿: 358 参加年月日: 10/11/17 最新の投稿
Sure,If you can share what have you done for implementation in your view.jsp o'wise its difficult to catch your problem
12年前 に sandeep tripathi によって更新されました。

RE: retrieving data from data base into a text box in portlet

Regular Member 投稿: 100 参加年月日: 11/10/19 最新の投稿
hi mayur ,

srry for the late reply i need to confirm with my team lead before sharing any doc .i will get back to it soon .

Regards
Sandeep
thumbnail
12年前 に Mayur Patel によって更新されました。

RE: retrieving data from data base into a text box in portlet

Expert 投稿: 358 参加年月日: 10/11/17 最新の投稿
you can give us the hints of the error, any javascript errors are you getting?? or what all issues r u facing?? , Is it making ajax call and r u getting the response??
11年前 に sandeep tripathi によって更新されました。

RE: retrieving data from data base into a text box in portlet

Regular Member 投稿: 100 参加年月日: 11/10/19 最新の投稿
hi

need help in autosuggestion i am not getting any error in error console but the autosuggestion is not working for me .
in my view .jsp page

<div class="search-padd10">
<span class="rightClm">
<input type="text" class="search-job-key default-value" value="Locations" id="locationAutoSuggest" tabindex="8" name="locationAutoSuggest" />
</span>
</div>

<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#locationAutoSuggest").autocomplete("<%=request.getContextPath()%>/getdata.jsp");
jQuery('.default-value').each(function() {
var default_value = this.value;
jQuery(this).focus(function() {
if(this.value == default_value) {
this.value = '';
}
});
jQuery(this).blur(function() {
if(this.value == '') {
this.value = default_value;
}
});
});
});
</script>
and in getdata.jsp
there is database call so that i can fetch data from database .

can some 1 help me out.
11年前 に sandeep tripathi によって更新されました。

RE: retrieving data from data base into a text box in portlet

Regular Member 投稿: 100 参加年月日: 11/10/19 最新の投稿
hi everyone

i am able to get the data into div with the help of alloy-aui. But instead of associating autocomplete with the div element,I want to associate with my input text field.

but it is not working pls help me out .

<div id="demo">
<input type="text" class="search-job-key default-value" value="Locations" id="locationAutoSuggest1" tabindex="8" name="locationAutoSuggest1" />
</div>

<script>
AUI().ready('aui-autocomplete', function(A)
{
var states = new Array();
<%
LocationSearch locSrch = new LocationSearch();
List locationlist = locSrch.selectLocationArea();
String[] retrivingArray;
for(int i=0; i < locationlist.size() ; i++){
retrivingArray = (String[]) locationlist.get(i);

%>
var tmpArray = ['<%=retrivingArray[0]%>','<%=retrivingArray[1]%>'];
states.push(tmpArray);
<%
}
%>


var autoComplete = new A.AutoComplete(
{ contentBox: '#demo',input: '#<portlet:namespace/>locationAutoSuggest1' dataSource:states , delimChar: ',', matchKey: 'name', typeAhead: true, schema: { resultFields: ['key', 'name'] } } ) .render(); });

</script>
11年前 に sandeep tripathi によって更新されました。

RE: retrieving data from data base into a text box in portlet

Regular Member 投稿: 100 参加年月日: 11/10/19 最新の投稿
hi everyone

finally was able to create autosuggest in textbox in portlet here are the step

1) in view.jsp the text box & script for getting data from database
<div id="demo">
<input type="text" class="search-job-key default-value" value="Locations" id="locationAutoSuggest1" tabindex="8" name="locationAutoSuggest1" />
</div>

<script type="text/javascript">

jQuery(function() {
var states = new Array();
<%
LocationSearch locSrch = new LocationSearch();
List locationlist = locSrch.selectLocationArea();
String[] retrivingArray;
for(int i=0; i < locationlist.size() ; i++){
retrivingArray = (String[]) locationlist.get(i);

%>

states[<%=i%>] = "<%=retrivingArray[1]%>";

<%
}
%>

jQuery("#locationAutoSuggest").autocomplete({
source:states
});


});
</script>

2) in theme include the jquery in head section

<script type="text/javascript" src="$javascript_folder/jquery-1.5.min.js"></script>
<script type="text/javascript" src="$javascript_folder/jquery-ui.min.js"></script>

regards
Sandeep