{"id":7,"date":"2009-02-02T18:12:00","date_gmt":"2009-02-02T18:12:00","guid":{"rendered":"http:\/\/www.juniovitor.com\/?p=7"},"modified":"2011-10-27T15:26:24","modified_gmt":"2011-10-27T15:26:24","slug":"adf-criando-uma-aplicacao-simples-crud-baseada-em-uma-tabela","status":"publish","type":"post","link":"https:\/\/www.juniovitor.com\/?p=7","title":{"rendered":"ADF &#8211; Criando uma aplicacao simples (CRUD) baseada em uma tabela"},"content":{"rendered":"<div style=\"text-align: justify;\"><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">1 &#8211; <\/span>Abra o JDeveloper crie uma nova aplica\u00e7\u00e3o: <span style=\"color: #3366ff;\">&nbsp;<\/span><\/span><\/span><br \/><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"color: #3366ff;\">&nbsp;&#8211; File<\/span><\/span><\/span><br \/><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"color: #3366ff;\">&nbsp;&nbsp;&nbsp; &#8211; New<\/span><\/span><\/span><br \/><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"color: #3366ff;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211; New Application.<\/span><\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">2 &#8211; <\/span>D\u00ea o nome para a sua aplica\u00e7\u00e3o de <span style=\"color: #3d85c6;\">CadEquipamentos<\/span>, informe os prefixos dos pacotes e selecione o template <span style=\"color: #3366ff;\">Fusion Web Application (ADF).<\/span> Clique em Next.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">3 &#8211; <\/span>Caso queira outro local para a sua aplica\u00e7\u00e3o, altere o diret\u00f3rio. Clique em <span style=\"color: #3366ff;\">Next<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">4 &#8211; <\/span>Voc\u00ea pode alterar o caminho ou os pacotes se desejar. Clique em <span style=\"color: #3366ff;\">Next<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">5 &#8211; <\/span>Aceite os valores defaults. Clique em <span style=\"color: #3366ff;\">Next<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">6 &#8211; <\/span>Clique em <span style=\"color: #3366ff;\">Finish<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><\/span><\/span><br \/><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">7 &#8211; <\/span>Ir\u00e1 exibir a Tela de controle da aplica\u00e7\u00e3o.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">8 &#8211; <\/span>Criando uma conex\u00e3o com o banco de dados.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">9 &#8211; <\/span>Informe os dados de conex\u00e3o: usu\u00e1rio, senha, host, porta e SID do banco de dados. Ap\u00f3s informar os dados, teste a conex\u00e3o, se der <span style=\"color: #3366ff;\">Success<\/span>! Clique em <span style=\"color: #3366ff;\">Ok<\/span>. Se n\u00e3o, revise os dados.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">10 &#8211; <\/span>O pr\u00f3ximo passo \u00e9 criar os objetos do projeto <span style=\"color: #3366ff;\">Model<\/span>. Clique com o bot\u00e3o direito em cima do projeto Model, selecione <span style=\"color: #3366ff;\">ADF Business Components<\/span>, no lado direto selecione <span style=\"color: #3366ff;\">Business Components from Tables<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">11 &#8211; <\/span>Selecione a conex\u00e3o que criamos anteriormente.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">12 &#8211;<\/span> Para gerar o <span style=\"color: #3366ff;\">Entity Objects<\/span>, busque a tabela que servir\u00e1 de base para a nossa aplica\u00e7\u00e3o, ap\u00f3s encontrar, selecione e <span style=\"color: #3366ff;\">Add (CTRL+D)<\/span>, passando-a para o lado direito do formul\u00e1rio. Clique em <span style=\"color: #3366ff;\">Next<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\">Se n\u00e3o criou uma tabela espec\u00edfica para o teste, crie a seguinte tabela:<\/span><\/span><\/p>\n<p><span style=\"color: #990000; font-size: xx-small;\"><span style=\"font-family: courier new;\">CREATE TABLE TESTE_ADF_3<\/span><\/span><br \/><span style=\"color: #990000; font-size: xx-small;\"><span style=\"font-family: courier new;\">(<\/span><\/span><br \/><span style=\"color: #990000; font-size: xx-small;\"><span style=\"font-family: courier new;\">&nbsp;COD_EQUIPAMENTO NUMBER<\/span><\/span><br \/><span style=\"color: #990000; font-size: xx-small;\"><span style=\"font-family: courier new;\">,DESCRICAO       VARCHAR2 (50)<\/span><\/span><br \/><span style=\"color: #990000; font-size: xx-small;\"><span style=\"font-family: courier new;\">,DTA_AQUISICAO   DATE<\/span><\/span><br \/><span style=\"color: #990000; font-size: xx-small;\"><span style=\"font-family: courier new;\">,OBSERVACAO      VARCHAR2 (200)<\/span><\/span><br \/><span style=\"color: #990000; font-size: 100%;\"><span style=\"font-family: courier new; font-size: xx-small;\">);<\/span><span style=\"font-family: courier new;\"><\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">13 &#8211; <\/span>Agora selecione o \u201c<span style=\"color: #3366ff;\">pr\u00e9-view<\/span>\u201d gerado automaticamente, selecione e <span style=\"color: #3366ff;\">Add (CTRL+D),<\/span> passando-o para o lado direito do formul\u00e1rio para <span style=\"color: #3366ff;\">Updatable View Objetcs<\/span> e clique em <span style=\"color: #3366ff;\">Finish<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">14 &#8211;<\/span> O pr\u00f3ximo passo \u00e9 criar uma pagina JSF. Clique com o bot\u00e3o direito do mouse sobre o projeto <span style=\"color: #3366ff;\">ViewController<\/span>, selecione <span style=\"color: #3366ff;\">New<\/span>. Clique em <span style=\"color: #3366ff;\">JSF <\/span>e no lado direito selecione <span style=\"color: #3366ff;\">JSP page<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">15 &#8211;<\/span> D\u00ea um nome para a sua p\u00e1gina de <span style=\"color: #3366ff;\">CadEquipamentos <\/span>. <span style=\"color: #3366ff;\">Marque a op\u00e7\u00e3o Create as XML Document<\/span> e clique em <span style=\"color: #3366ff;\">OK<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">16 &#8211; <\/span>Pronto, a sua p\u00e1gina foi criada e o editor JSF ser\u00e1 carregado! Agora o pr\u00f3ximo passo \u00e9 montar a sua p\u00e1gina utilizando os componentes necess\u00e1rios.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">17 &#8211; <\/span>Abra a aba <span style=\"color: #3366ff;\">Data Controls<\/span>, selecione <span style=\"color: #3366ff;\">TesteAdf3View<\/span>(este nome \u00e9 gerado automaticamente, vai depender do nome da tabela que est\u00e1 utilizando) e arraste para dentro da p\u00e1gina JSP. No menu flutuante que ir\u00e1 aparecer, selecione <span style=\"color: #3366ff;\">Forms<span style=\"color: black;\">,<\/span> ADF Form.<\/span><\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">18 &#8211;<\/span> Marque a op\u00e7\u00e3o <span style=\"color: #3366ff;\">Include Navigation Controls<\/span>(bot\u00f5es: First, Next, Previous, Last) e clique em OK.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">19 &#8211; <\/span>Agora vamos incluir no formul\u00e1rio os bot\u00f5es para inserir registro, dar rollback e comitar. Na aba <span style=\"color: #3366ff;\">DataControls<\/span> expanda a \u00e1rvore do <span style=\"color: #3366ff;\">TesteAdf3View<\/span>(este nome \u00e9 gerado automaticamente, vai depender do nome da tabela que est\u00e1 utilizando), expanda a \u00e1rvore <span style=\"color: #3366ff;\">Operations<\/span>, selecione <span style=\"color: #3366ff;\">CreateInsert<\/span>, <span style=\"color: #3366ff;\">Find <\/span>e o <span style=\"color: #3366ff;\">Execute<\/span>(um de cada vez)e arraste para o JSP.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">OBS:<\/span> toda vez que voc\u00ea arrastar o componente, ser\u00e1 exibido o menu flutuante, basta escolher Operations \u00e0 <span style=\"color: #3366ff;\">ADF Button<\/span>.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">20 &#8211;<\/span> Os bot\u00f5es <span style=\"color: #3366ff;\">Commit <\/span>e <span style=\"color: #3366ff;\">Rollback <\/span>est\u00e3o mais abaixo do <span style=\"color: #3366ff;\">AppModuleDataControl<\/span>, na outra \u00e1rvore. Clique e arraste para dentro do JSP, um de cada vez, seguindo os mesmos passos anteriores.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">21 &#8211;<\/span> <span style=\"font-weight: bold;\">PRONTO!<\/span> Agora vamos rodar a aplica\u00e7\u00e3o, clique com o bot\u00e3o direito sobre o JSP e selecione <span style=\"color: #3366ff;\">Run (Ctrl + F11). <\/span>Se voc\u00ea fez tudo certo como nos passos anteriores o browser ser\u00e1 aberto com a p\u00e1gina que n\u00f3s criamos com o nosso formul\u00e1rio.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"><span style=\"font-weight: bold;\">Observa\u00e7\u00f5es: <\/span><\/span><\/span><br \/><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"> &#8211; Ao rodar a aplica\u00e7\u00e3o pela primeira vez, o tempo para inicializa\u00e7\u00e3o do servidor demora um pouco!<\/span><\/span><br \/><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\"> &#8211;  Ao clicar sobre o objeto, \u00e0 direita ficam todas as propriedades dele, portanto modifique \u00e0 vontade para ver os resultados.<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\">N\u00e3o tem segredo&#8230; D\u00favidas, entre em contato!<\/span><\/span><\/p>\n<p><span style=\"font-size: 100%;\"><span style=\"font-family: arial;\">Abra\u00e7o!<\/span><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>1 &#8211; Abra o JDeveloper crie uma nova aplica\u00e7\u00e3o: &nbsp;&nbsp;&#8211; File&nbsp;&nbsp;&nbsp; &#8211; New&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211; New Application. 2 &#8211; D\u00ea o nome para [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[50,52,53],"class_list":["post-7","post","type-post","status-publish","format-standard","hentry","category-oracle","tag-adf","tag-developer","tag-framework"],"_links":{"self":[{"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=\/wp\/v2\/posts\/7"}],"collection":[{"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7"}],"version-history":[{"count":4,"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions"}],"predecessor-version":[{"id":371,"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=\/wp\/v2\/posts\/7\/revisions\/371"}],"wp:attachment":[{"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.juniovitor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}