Rev 1576 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1576 | Rev 1577 | ||
---|---|---|---|
1 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
1 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
2 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
2 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
3 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
3 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
4 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
4 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
5 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
5 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
6 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
6 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
7 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
7 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
8 | - | ||
- | 8 | <div class="container-fluid"> |
|
9 | 9 | ||
10 | <h1>Teste aos Controladores de Widgets de Exemplo</h1> |
10 | <h1>Teste aos Controladores de Widgets de Exemplo</h1> |
11 | 11 | ||
12 | <h2>Ficheiros biblioteca, não são para alterar</h2> |
12 | <h2>Ficheiros biblioteca, não são para alterar</h2> |
13 | <ul> |
13 | <ul> |
14 | <li>conf/WEB-INF/struts/tiles-jsonwidget.xml (Layouts de Respostas JSON)</li> |
14 | <li>conf/WEB-INF/struts/tiles-jsonwidget.xml (Layouts de Respostas JSON)</li> |
15 | <li>conf/WEB-INF/struts/struts-jsonwidget.xml (Global Forwards de Respostas JSON)</li> |
15 | <li>conf/WEB-INF/struts/struts-jsonwidget.xml (Global Forwards de Respostas JSON)</li> |
16 | <li>classe para extender controladores pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController</li> |
16 | <li>classe para extender controladores pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController</li> |
17 | </ul> |
17 | </ul> |
18 | 18 | ||
19 | <h2>Ficheiro de Configuração de exemplo para novos Controladores de Widgets</h2> |
19 | <h2>Ficheiro de Configuração de exemplo para novos Controladores de Widgets</h2> |
20 | <ul> |
20 | <ul> |
21 | <li>conf/WEB-INF/struts/examples/struts-example/jsonwidget.xml</li> |
21 | <li>conf/WEB-INF/struts/examples/struts-example/jsonwidget.xml</li> |
22 | </ul> |
22 | </ul> |
23 | 23 | ||
24 | <h2>Controladores e form de Exemplo</h2> |
24 | <h2>Controladores e form de Exemplo</h2> |
25 | <ul> |
25 | <ul> |
26 | <li>classe de Exemplo pt.estgp.estgweb.web.controllers.examples.jsonwidget.JsonWidgetExampleForm</li> |
26 | <li>classe de Exemplo pt.estgp.estgweb.web.controllers.examples.jsonwidget.JsonWidgetExampleForm</li> |
27 | <li>classe de Exemplo pt.estgp.estgweb.web.controllers.examples.jsonwidget.WidgetExampleController</li> |
27 | <li>classe de Exemplo pt.estgp.estgweb.web.controllers.examples.jsonwidget.WidgetExampleController</li> |
28 | </ul> |
28 | </ul> |
29 | 29 | ||
30 | <h2>Chamadas de Exemplo do Serviço AJAX/JSON</h2> |
30 | <h2>Chamadas de Exemplo do Serviço AJAX/JSON</h2> |
31 | <p>Os exemplos de chamada das bibliotecas JavaScript são um nível de abstração acima destes exemplos</p> |
31 | <p>Os exemplos de chamada das bibliotecas JavaScript são um nível de abstração acima destes exemplos</p> |
32 | <ul> |
32 | <ul> |
33 | <li> |
33 | <li> |
34 | <a href="<%=request.getContextPath()%>/widgetWithValidationExample.do?dispatch=executeService&serviceJson=serviceClean&nome=teste"> |
34 | <a href="<%=request.getContextPath()%>/widgetWithValidationExample.do?dispatch=executeService&serviceJson=serviceClean&nome=teste"> |
35 | Teste de um servico sem erros e com validacao |
35 | Teste de um servico sem erros e com validacao |
36 | </a> |
36 | </a> |
37 | </li> |
37 | </li> |
38 | <li> |
38 | <li> |
39 | <a href="<%=request.getContextPath()%>/widgetWithValidationExample.do?dispatch=executeService&serviceJson=serviceClean"> |
39 | <a href="<%=request.getContextPath()%>/widgetWithValidationExample.do?dispatch=executeService&serviceJson=serviceClean"> |
40 | Teste de um servico com erros e com validacao onde foi omitido o campo nome que é obrigatório |
40 | Teste de um servico com erros e com validacao onde foi omitido o campo nome que é obrigatório |
41 | </a> |
41 | </a> |
42 | </li> |
42 | </li> |
43 | <li> |
43 | <li> |
44 | <a href="<%=request.getContextPath()%>/widgetExample.do?dispatch=executeService&serviceJson=serviceException"> |
44 | <a href="<%=request.getContextPath()%>/widgetExample.do?dispatch=executeService&serviceJson=serviceException"> |
45 | Teste de um servico com uma excepção |
45 | Teste de um servico com uma excepção |
46 | </a> |
46 | </a> |
47 | </li> |
47 | </li> |
48 | <li> |
48 | <li> |
49 | <a href="<%=request.getContextPath()%>/widgetExample.do?dispatch=executeSimpleServiceOkFail&serviceJson=serviceSimpleOkExample"> |
49 | <a href="<%=request.getContextPath()%>/widgetExample.do?dispatch=executeSimpleServiceOkFail&serviceJson=serviceSimpleOkExample"> |
50 | Teste de um servico Tipo Ok ou Fail Simples |
50 | Teste de um servico Tipo Ok ou Fail Simples |
51 | </a> |
51 | </a> |
52 | </li> |
52 | </li> |
53 | <li> |
53 | <li> |
54 | <a href="<%=request.getContextPath()%>/widgetExample.do?dispatch=executeSimpleServiceOkFail&serviceJson=serviceSimpleFailExample"> |
54 | <a href="<%=request.getContextPath()%>/widgetExample.do?dispatch=executeSimpleServiceOkFail&serviceJson=serviceSimpleFailExample"> |
55 | Teste de um servico Tipo Ok ou Fail Simples com FALHA |
55 | Teste de um servico Tipo Ok ou Fail Simples com FALHA |
56 | </a> |
56 | </a> |
57 | </li> |
57 | </li> |
58 | </ul> |
58 | </ul> |
59 | 59 | ||
60 | 60 | ||
61 | <h2>Como usar as bilbiotecas de chamada AJAX</h2> |
61 | <h2>Como usar as bilbiotecas de chamada AJAX</h2> |
62 | <p> |
62 | <p> |
63 | Bibliotecas de alto nível. Libertam o developer para a colocação de mensagens e para a interpretação do estado de resposta a um pedido, |
63 | Bibliotecas de alto nível. Libertam o developer para a colocação de mensagens e para a interpretação do estado de resposta a um pedido, |
64 | bastando haver um div com a class web-messages dentro do Form. O developer apenas tem de programar os handlers de sucesso e de falha.</p> |
64 | bastando haver um div com a class web-messages dentro do Form. O developer apenas tem de programar os handlers de sucesso e de falha.</p> |
65 | <p>Existem dois tipos de chamadas possiveis, as que devolvem um objecto json e as simples que apenas devolvem ok ou fail através da invocação do handler respectivo</p> |
65 | <p>Existem dois tipos de chamadas possiveis, as que devolvem um objecto json e as simples que apenas devolvem ok ou fail através da invocação do handler respectivo</p> |
66 | 66 | ||
67 | <div class="web-messages"><div class="alert alert-info">Exemplo Div para mensagens WEB mas nao é afectado pelo form</div> </div> |
67 | <div class="web-messages"><div class="alert alert-info">Exemplo Div para mensagens WEB mas nao é afectado pelo form</div> </div> |
68 | <p>Form de Struts com Auto preenchimento de Campos mas invoca um Widget Controller</p> |
68 | <p>Form de Struts com Auto preenchimento de Campos mas invoca um Widget Controller</p> |
69 | <html:form styleClass="form-horizontal" action="/widgetWithValidationExample" onsubmit="return false;"> |
69 | <html:form styleClass="form-horizontal" action="/widgetWithValidationExample" onsubmit="return false;"> |
70 | <div class="web-messages">Aqui vão aparecer as mensagens de Erro ou de Feedback do Widget</div> |
70 | <div class="web-messages">Aqui vão aparecer as mensagens de Erro ou de Feedback do Widget</div> |
71 | <div class="form-group"> |
71 | <div class="form-group"> |
72 | <label>Nome</label> |
72 | <label class="col-md-2">Nome</label> |
- | 73 | <div class="col-md-8"> |
|
73 | <html:text styleClass="form-control" property="nome"/> |
74 | <html:text styleClass="form-control" property="nome"/> |
- | 75 | </div> |
|
74 | </div> |
76 | </div> |
75 | 77 | ||
76 | <div> |
78 | <div> |
77 | <script> |
79 | <script> |
78 | function widgetCallClean(form) |
80 | function widgetCallClean(form) |
79 | { |
81 | { |
80 | widgetCall('serviceClean',form, |
82 | widgetCall('serviceClean',form, |
81 | function(response) |
83 | function(response) |
82 | { |
84 | { |
83 | alert("Accao de resposta terminada: " + response.dataExample); |
85 | alert("Accao de resposta terminada: " + response.dataExample); |
84 | }); |
86 | }); |
85 | } |
87 | } |
86 | function widgetCallWithErrors(form) |
88 | function widgetCallWithErrors(form) |
87 | { |
89 | { |
88 | widgetCall('serviceWithErrors',form, |
90 | widgetCall('serviceWithErrors',form, |
89 | function(response) |
91 | function(response) |
90 | { |
92 | { |
91 | alert("Accao de resposta terminada: " + response.dataExample); |
93 | alert("Accao de resposta terminada: " + response.dataExample); |
92 | }, |
94 | }, |
93 | function(response) |
95 | function(response) |
94 | { |
96 | { |
95 | alert("Accao Falhou mas as resposta foi esta: " + response.dataExample); |
97 | alert("Accao Falhou mas as resposta foi esta: " + response.dataExample); |
96 | }); |
98 | }); |
97 | } |
99 | } |
98 | function widgetCallExceptionTest(form) |
100 | function widgetCallExceptionTest(form) |
99 | { |
101 | { |
100 | widgetCall('serviceException',form, |
102 | widgetCall('serviceException',form, |
101 | function(response) |
103 | function(response) |
102 | { |
104 | { |
103 | alert("Accao de resposta terminada: " + response.dataExample); |
105 | alert("Accao de resposta terminada: " + response.dataExample); |
104 | }); |
106 | }); |
105 | } |
107 | } |
106 | 108 | ||
107 | function widgetChamadaSimples(form) |
109 | function widgetChamadaSimples(form) |
108 | { |
110 | { |
109 | widgetSimpleCall('serviceSimpleOkExample',form, |
111 | widgetSimpleCall('serviceSimpleOkExample',form, |
110 | function() |
112 | function() |
111 | { |
113 | { |
112 | alert("OK"); |
114 | alert("OK"); |
113 | }, |
115 | }, |
114 | function() |
116 | function() |
115 | { |
117 | { |
116 | alert("Fail"); |
118 | alert("Fail"); |
117 | }); |
119 | }); |
118 | } |
120 | } |
119 | function widgetChamadaFalha(form) |
121 | function widgetChamadaFalha(form) |
120 | { |
122 | { |
121 | widgetSimpleCall('serviceSimpleFailExample',form, |
123 | widgetSimpleCall('serviceSimpleFailExample',form, |
122 | function() |
124 | function() |
123 | { |
125 | { |
124 | alert("OK"); |
126 | alert("OK"); |
125 | }, |
127 | }, |
126 | function() |
128 | function() |
127 | { |
129 | { |
128 | alert("Fail"); |
130 | alert("Fail"); |
129 | }); |
131 | }); |
130 | } |
132 | } |
131 | 133 | ||
132 | 134 | ||
133 | </script> |
135 | </script> |
134 | <p>(Pode usar ou nao o campo "nome" para ver o resultado da validação do Form. Quando a validacao do form nao passa apenas vem uma falha e uma lista de erros, quando a falha é propositada dentro do controller com a adicao de erros é possivel enviar o objecto json como resposta)</p> |
136 | <p>(Pode usar ou nao o campo "nome" para ver o resultado da validação do Form. Quando a validacao do form nao passa apenas vem uma falha e uma lista de erros, quando a falha é propositada dentro do controller com a adicao de erros é possivel enviar o objecto json como resposta)</p> |
135 | <button class="btn btn-success" type="button" onclick="widgetCallClean(this.form)">Submeter Simulacao Servico OK</button> |
137 | <button class="btn btn-success" type="button" onclick="widgetCallClean(this.form)">Submeter Simulacao Servico OK</button> |
136 | <button class="btn btn-warning" type="button" onclick="widgetCallWithErrors(this.form)">Submeter Simulacao Servico Com Erros</button> |
138 | <button class="btn btn-warning" type="button" onclick="widgetCallWithErrors(this.form)">Submeter Simulacao Servico Com Erros</button> |
137 | <button class="btn btn-danger" type="button" onclick="widgetCallExceptionTest(this.form)">Submeter Simulacao Servico Com Excepção</button> |
139 | <button class="btn btn-danger" type="button" onclick="widgetCallExceptionTest(this.form)">Submeter Simulacao Servico Com Excepção</button> |
138 | <button class="btn btn-success" type="button" onclick="widgetChamadaSimples(this.form)">Submeter Simulacao Servico SIMPLES OK/FAIL TUDO OK</button> |
140 | <button class="btn btn-success" type="button" onclick="widgetChamadaSimples(this.form)">Submeter Simulacao Servico SIMPLES OK/FAIL TUDO OK</button> |
139 | <button class="btn btn-warning" type="button" onclick="widgetChamadaFalha(this.form)">Submeter Simulacao Servico SIMPLES OK/FAIL FALHA</button> |
141 | <button class="btn btn-warning" type="button" onclick="widgetChamadaFalha(this.form)">Submeter Simulacao Servico SIMPLES OK/FAIL FALHA</button> |
140 | </div> |
142 | </div> |
141 | </html:form> |
143 | </html:form> |
142 | 144 | ||
143 | 145 | ||
- | 146 | </div> |
|
144 | 147 | ||
- | 148 | Generated by GNU Enscript 1.6.5.2. |
|
- | 149 | ||
- | 150 |