Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_pt
CreateActions_pt




JSPWiki v2.2.33

[RSS]


Hide Menu

ValidationAndList_pt


Difference between version 8 and version 6:

At line 73 changed 1 line.
Para ativar validação cliente (client-side) em nosso personForm.jsp, uma tag javascript JSP e um script são obrigatórios na parte inferior do personForm.jsp. O seguinte código já deverá existir (graças ao appgen) - só necessitamos retirar os comentários dele. A razão pela qual este código está comentada é porque o Validator dispara uma exceção se um nome de formulário for especificado e nenhuma validação existir para ele.
A validação do lado cliente é habilitada por padrão no personForm.jsp. Existe uma tag JSP <html:javascript> e um script na parte inferior da página que habilita isso. O seguinte código já deve existir (graças ao AppGen) - mas pode ser necessário retirar os comentários se estes foram feitos no último tutorial.
At line 75 removed 2 lines.
;:''Pessoalmente, eu considero isto [um bug|http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27316], mas a equipe de desenvolvedores do Struts não concorda.''
At line 283 changed 1 line.
Open the personList.jsp file in ''web/pages''. At the top of the file is a &lt;bean:struts&gt; tags that exposes the edit screen's forward as a page-scoped variable. This should already have a value of "editPerson".
Devemos abrir o arquivo personList.jsp em ''web/pages''. Na parte superior do arquivo existe uma tag &lt;bean:struts&gt; que expõe o envio à tela de edição como uma variável de escopo de página. Esta variável já deve estar com o valor de "editPerson".
At line 287 changed 1 line.
<%-- For linking to edit screen --%>
<%-- Para ligar com a tela de edição --%>
At line 291 changed 1 line.
Add this to the metadata/web/global-forwards.xml, as well as one for viewing the list. This way, they will get included in our struts-config.xml file.
Adicione o seguinte conteúdo ao arquivo metadata/web/global-forwards.xml, contendo envios globais tanto para a tela de edição quanto para a tela de listagem. Desta forma, eles serão incluídos em nosso arquivo struts-config.xml.
At line 299 changed 1 line.
Another thing you'll probably want to change is the plural form of the items you're listing. The generated name in this example is "persons" and it should probably be people. At or near line 31, you should have the following line:
Outra coisa que provavelmente devemos mudar é o plural dos itens que estamos listando. O nome gerado no exemplo é "persons" e provavelmente deve ser pessoas (ou people, se estiver utilizando i18n). Perto ou na linha 31, devemos ter a seguinte linha:
At line 303 changed 1 line.
Change it to:
Devemos mudar para:
At line 305 changed 1 line.
{{{<display:setProperty name="paging.banner.items_name" value="people"/>}}}
{{{<display:setProperty name="paging.banner.items_name" value="pessoas"/>}}}
At line 307 changed 1 line.
Finally, add the title and heading keys (personList.title and personList.heading) to web/WEB-INF/classes/ApplicationResources.properties. Open this file and add the following:
Finalmente, devemos adicionar as chaves de título e de cabeçalho (personList.title e personList.heading) ao arquivo web/WEB-INF/classes/ApplicationResources.properties (no nosso caso, web/WEB-INF/classes/ApplicationResources_pt.properties). Devemos abrir este arquivo e adicionar o seguinte:
At line 310 changed 3 lines.
# -- person list page --
personList.title=Person List
personList.heading=All People
# -- página da lista de pessoas --
personList.title=Lista de Pessoas
personList.heading=Todas as Pessoas
At line 315 changed 2 lines.
As a reminder, the {{personList.title}} is what ends up in the brower's title bar (the &lt;title&gt; tag) and
{{personList.heading}} will be put into an &lth1&gt; tag before any page content.
Como um lembrete, o {{personList.title}} é o que está na barra de título do navegador (a tag &lt;title&gt;) e {{personList.heading}} será colocado em uma tag &lth1&gt; antes de qualquer conteúdo da página.
At line 318 changed 1 line.
At this point, you should be able to run __ant clean deploy__, start Tomcat and view this page in your browser at [http://localhost:8080/appfuse/editPerson.html?method=Search].
Neste ponto, já seremos capazes de rodar __ant clean deploy__, iniciar o Tomcat e ver a página no navegador em [http://localhost:8080/appfuse/editPerson.html?method=Search].
At line 320 changed 1 line.
Now that we have a List Screen, let's change the pages that are displayed after adding and deleting a new Person. In src/web/**/action/PersonAction.java, change the ''mapping.findForward("mainMenu")'' in the ''save'', ''delete'' and ''cancel'' methods to be:
Agora que temos uma tela de listagem, vamos mudar as páginas que são mostradas após adicionar e remover uma nova pessoa. Em src/web/**/action/PersonAction.java, devemos mudar o ''mapping.findForward("mainMenu")'' nos métodos ''save'', ''delete'' e ''cancel'' para:
At line 327 changed 1 line.
You will also need to change ''verifyForward("mainMenu")'' to be ''verifyForward("viewPeople")'' in the testRemove method of test/web/**/action/PersonActionTest.java. Lastly, the Canoo tests "AddPerson" and "DeletePerson" need to be updated. Open test/web/web-tests.xml and change the following line in the "AddPerson" target:
Devemos também modificar ''verifyForward("mainMenu")'' para ''verifyForward("viewPeople")'' no método testRemove do arquivo test/web/**/action/PersonActionTest.java. Por último, os testes Canoo "AddPerson" e "DeletePerson" devem ser atualizados. Devemos abrir o arquivo test/web/web-tests.xml e modificar a seguinte linha do alvo (''target'') "AddPerson":
At line 329 changed 1 line.
{{{<verifytitle description="Main Menu appears if save successful"
{{{<verifytitle description="O Menu Principal aparece se o save ocorreu com sucesso"
At line 332 changed 1 line.
to:
para:
At line 334 changed 1 line.
{{{<verifytitle description="Person List appears if save successful"
{{{<verifytitle description="A lista de pessoas aparece se salvou com sucesso"
At line 337 changed 1 line.
Then in the "DeletePerson" target, change the following line:
E no alvo (''target'') "DeletePerson", devemos mudar as seguintes linhas:
At line 339 changed 1 line.
{{{<verifytitle description="display Main Menu"
{{{<verifytitle description="mostra o Menu Principal"
At line 343 changed 1 line.
to:
para:
At line 345 changed 1 line.
{{{<verifytitle description="display Person List" text=".*${personList.title}.*" regex="true"/>}}}
{{{<verifytitle description="mostra a Lista de Pessoas" text=".*${personList.title}.*" regex="true"/>}}}
At line 347 changed 1 line.
We use "viewPeople" instead of "list" so that the search method will be executed, rather than simply forwarding to the personForm.jsp (which the "list" forward points to).
Utilizamos "viewPeople" ao invés de "list" para que o método de pesquisa seja executado, ao invés de simplesmente enviar para a página personForm.jsp (que o envio "list" aponta).
At line 349 changed 1 line.
To test that displaying this page works, create a new JSP test in test/web/web-tests.xml:
Para testar esta página, devemos criar um novo teste JSP no arquivo test/web/web-tests.xml:
At line 353 changed 1 line.
<!-- Verify the people list screen displays without errors -->
<!-- Verifica se a tela de listagem de pessoas aparece sem erros -->
At line 355 changed 1 line.
description="Tests search for and displaying all people">
description="Testa a procura e mostra todas as pessoas">
At line 361 changed 2 lines.
<invoke description="click View People link" url="/editPerson.html?method=Search"/>
<verifytitle description="we should see the personList title"
<invoke description="clicando no link Mostrar Pessoas" url="/editPerson.html?method=Search"/>
<verifytitle description="devemos ver o título da lista de pessoas"
At line 370 changed 1 line.
You'll also want to add the "SearchPeople" target to the "PersonTests" target so it will be executed along with all the other person-related tests.
Devemos também adicionar o alvo (''target'') "SearchPeople" ao alvo "PersonTests" para que ele seja executado juntamente com os outros testes relacionados à pessoa.
At line 374 changed 1 line.
<!-- runs person-related tests -->
<!-- roda os testes relacionados à pessoa -->
At line 377 changed 2 lines.
description="Call and executes all person test cases (targets)">
<echo>Successfully ran all Person JSP tests!</echo>
description="Chama e executa todos os casos de teste (targets) relacionados à pessoa">
<echo>Rodou todos os testes JSP de Pessoa com sucesso!</echo>
At line 382 changed 1 line.
Now you can run __ant test-canoo -Dtestcase=SearchPeople__ (or ''ant test-jsp'' if Tomcat isn't running) and hopefully it will result in "BUILD SUCCESSFUL". If so - ''nice work!''
Agora podemos rodar __ant test-canoo -Dtestcase=SearchPeople__ (ou ''ant test-jsp'' se o Tomcat não está rodando) e se tudo der certo isto resultará em um "BUILD SUCCESSFUL". Se este foi o resultado - ''bom trabalho!!''
At line 385 changed 1 line.
The last step is to make the list, add, edit and delete functions visible to the user. The simplest way is to add a new link to the list of links in web/pages/mainMenu.jsp:
O último passo é fazer as funções de listagem, adição, edição e remoção visíveis ao usuário. O meio mais simples é adicionar um novo link para a lista de links no arquivo web/pages/mainMenu.jsp:
At line 387 changed 1 line.
%%note __NOTE:__ The other links in mainMenu.jsp don't use <html:link> so this JSP can be shared among the various web framework implementations in AppFuse (i.e. Spring MVC and WebWork).%%
%%note __NOTA:__ Os outros links em mainMenu.jsp não utilizam <html:link> então o JSP pode ser compartilhado entre os vários frameworks web existentes no appfuse (i.e. como o Spring MVC e o WebWork).%%
At line 398 changed 1 line.
Where ''menu.viewPeople'' is an entry in web/WEB-INF/classes/ApplicationResources.properties.
Onde ''menu.viewPeople'' é uma entrada em web/WEB-INF/classes/ApplicationResources.properties (no nosso caso, web/WEB-INF/classes/ApplicationResources_pt.properties).
At line 400 changed 1 line.
menu.viewPeople=View People
menu.viewPeople=Mostrar Pessoas
At line 403 changed 1 line.
The other (more likely) alternative is that you'll want to add it to the menu. To do this, add the following to web/WEB-INF/menu-config.xml:
A outra (mais eficiente) alternativa é que adicionemos isto ao menu. Para fazê-lo, devemos adicionar o seguinte conteúdo ao arquivo web/WEB-INF/menu-config.xml:
At line 410 changed 1 line.
Make sure the above XML is inside the &lt;Menus&gt; tag, but not within another &lt;Menu&gt;. Then add this new menu to web/common/menu.jsp - which should now look as follows:
Devemos nos certificar que o XML acima esteja dentro da tag &lt;Menus&gt;, mas não dentro de outra tag &lt;Menu&gt;. Então devemos adicionar este novo menu à página web/common/menu.jsp - a qual deve agora estar da seguinte forma:
At line 428 changed 1 line.
Now if you run __ant clean deploy__ start Tomcat and go to [http://localhost:8080/appfuse/mainMenu.html], you should see something like the screenshot below.
Agora se rodarmos __ant clean deploy__ , iniciarmos o Tomcat e acessarmos [http://localhost:8080/appfuse/mainMenu.html], veremos algo como a tela abaixo.
At line 434 changed 1 line.
Notice that there is a new link on the left side (from mainMenu.jsp) and on the right in our menu (from menu.jsp).
Devemos notar que existe um novo link do lado esquerdo (do mainMenu.jsp) e do lado direito no nosso menu (from menu.jsp).
At line 436 changed 2 lines.
!!That's it!
You've completed the full lifecycle of developing a set of master-detail pages with AppFuse and Struts - __Congratulations__! Now the real test is if you can run all the tests in your app without failure. To test, stop tomcat and run __ant clean test-all__. This will run all the unit tests within your project. As a reminder, it should be easy to setup and test AppFuse from scratch using __ant setup-db setup-tomcat test-all__. Also, if you're looking for more robust examples - checkout [Struts Resume|StrutsResume].
!!É isso!
Você completou o ciclo de vida completo de desenvolvimento de um conjunto de páginas master-detail com o AppFuse e Struts - __Parabéns__! Agora o teste real é se você puder rodar todos os testes em sua aplicação sem falhas. Para testar, pare o Tomcat e rode __ant clean test-all__. Isto rodará todos os testes unitários de seu projeto. Como um lembrete, é fácil de instalar e testar o Appfuse do zero utilizando __ant setup-db setup-tomcat test-all__. Ainda assim, se você estiver procurando exemplos mais robustos, veja o [Struts Resume|StrutsResume].
At line 439 changed 1 line.
''__Happy Day!__''
''__Tena um Bom Dia!__''

Back to ValidationAndList_pt, or to the Page History.