This file is indexed.

/usr/share/doc/libzeep-dev/libzeep/webapp.html is in libzeep-dev 3.0.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Creating a Web Application</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="../index.html" title="libzeep 3.0">
<link rel="up" href="../index.html" title="libzeep 3.0">
<link rel="prev" href="soap.html" title="Creating a SOAP and REST server">
<link rel="next" href="../index/s05.html" title="Reference">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="soap.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../index/s05.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="libzeep.webapp"></a><a class="link" href="webapp.html" title="Creating a Web Application">Creating a Web Application</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="webapp.html#libzeep.webapp.intro">Introduction</a></span></dt>
<dt><span class="section"><a href="webapp.html#libzeep.webapp.basics">The building blocks</a></span></dt>
<dt><span class="section"><a href="webapp.html#libzeep.webapp.hello">Hello world!</a></span></dt>
<dt><span class="section"><a href="webapp.html#libzeep.webapp.forms">Using forms</a></span></dt>
<dt><span class="section"><a href="webapp.html#libzeep.webapp.el">Using <code class="computeroutput"><span class="identifier">el</span></code>
      script</a></span></dt>
<dt><span class="section"><a href="webapp.html#libzeep.webapp.processing_tags">Processing Tags</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="libzeep.webapp.intro"></a><a class="link" href="webapp.html#libzeep.webapp.intro" title="Introduction">Introduction</a>
</h3></div></div></div>
<p>
        This section will guide you through all the code you have to write to create
        an interactive web application using libzeep. The way this works in libzeep
        looks a lot like popular frameworks found for Java. If you're familiar with
        JSP and e.g. Struts, you'll notice the similarities.
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="libzeep.webapp.basics"></a><a class="link" href="webapp.html#libzeep.webapp.basics" title="The building blocks">The building blocks</a>
</h3></div></div></div>
<p>
        It is very inconvenient to write HTML code in C++ directly using string concatenations
        and streams. Therefore, a separation has been made. All HTML is put into
        XHTML template files. These template files can use special tags to generate
        HTML tags based on data provided by the server application. A script language
        that looks a lot like JSP 'Expression Language' (or <code class="literal">el</code>
        in short) is used to program conditional constructs. Communication between
        this <code class="literal">el</code> script and the server application is done via
        <code class="literal">el::object</code> data objects.
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="libzeep.webapp.hello"></a><a class="link" href="webapp.html#libzeep.webapp.hello" title="Hello world!">Hello world!</a>
</h3></div></div></div>
<p>
        Let's start with a simple hello world example. We first create a template
        file, save this file as <code class="literal">hello.xhtml</code>.
      </p>
<pre class="programlisting">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/1999/xhtml"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
  &lt;title&gt;Hello&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;p&gt;Hello, world!&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>
        This is a very simple, strict XHTML 1.1 file. We will serve it with our server:
      </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">zeep</span><span class="special">/</span><span class="identifier">http</span><span class="special">/</span><span class="identifier">webapp</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bind</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">;</span>

<span class="keyword">class</span> <span class="identifier">MyWebApp</span> <span class="special">:</span> <span class="keyword">public</span> <code class="computeroutput"><a class="link" href="../zeep/http/webapp.html" title="Class webapp">zeep::http::webapp</a></code>
<span class="special">{</span>
  <span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">MyWebApp</span><span class="special">();</span>

    <span class="keyword">void</span> <span class="identifier">handle_welcome</span><span class="special">(</span><span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/request.html" title="Struct request">zeep::http::request</a></code><span class="special">&amp;</span> <span class="identifier">request</span><span class="special">,</span>
           <span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code><span class="special">&amp;</span> <span class="identifier">scope</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="../zeep/http/reply.html" title="Class reply">zeep::http::reply</a></code><span class="special">&amp;</span> <span class="identifier">reply</span><span class="special">);</span>
<span class="special">};</span>

<span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">MyWebApp</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">mount</span><span class="special">(</span><span class="string">""</span><span class="special">,</span>      <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">handle_welcome</span><span class="special">,</span> <span class="keyword">this</span><span class="special">,</span> <span class="identifier">_1</span><span class="special">,</span> <span class="identifier">_2</span><span class="special">,</span> <span class="identifier">_3</span><span class="special">));</span>
<span class="special">}</span>

<span class="keyword">void</span> <span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">handle_welcome</span><span class="special">(</span><span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/request.html" title="Struct request">zeep::http::request</a></code><span class="special">&amp;</span> <span class="identifier">request</span><span class="special">,</span>
           <span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code><span class="special">&amp;</span> <span class="identifier">scope</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="../zeep/http/reply.html" title="Class reply">zeep::http::reply</a></code><span class="special">&amp;</span> <span class="identifier">reply</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">create_reply_from_template</span><span class="special">(</span><span class="string">"hello.xhtml"</span><span class="special">,</span> <span class="identifier">scope</span><span class="special">,</span> <span class="identifier">reply</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">MyWebApp</span> <span class="identifier">server</span><span class="special">;</span>
  <span class="identifier">server</span><span class="special">.</span><span class="identifier">bind</span><span class="special">(</span><span class="string">"0.0.0.0"</span><span class="special">,</span> <span class="number">80</span><span class="special">);</span>
  <span class="identifier">server</span><span class="special">.</span><span class="identifier">run</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
        By calling <code class="computeroutput"><span class="identifier">mount</span></code> with the
        empty string, we tell libzeep to redirect all access to the base URL to handle_welcome.
        This means that visiting the URL <a href="http://localhost/" target="_top">http://localhost/</a>
        should now return a page containing the string 'Hello, world!'.
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="libzeep.webapp.forms"></a><a class="link" href="webapp.html#libzeep.webapp.forms" title="Using forms">Using forms</a>
</h3></div></div></div>
<p>
        Now lets create a form to pass some data from the browser to the server and
        back. Save the following file as <code class="literal">form.xhtml</code>.
      </p>
<pre class="programlisting">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/1999/xhtml"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:zeep="http://www.cmbi.ru.nl/libzeep/ml"&gt;
&lt;head&gt;
  &lt;title&gt;Form example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;zeep:if test="${name}"&gt;
    &lt;p&gt;Hello ${name}!&lt;/p&gt;
  &lt;/zeep:if&gt;
  &lt;p&gt;Please enter your name and press the Submit button&lt;/p&gt;
  &lt;form id="myForm" action="salute" method="get"&gt;
    &lt;label&gt;Name: &lt;input id="name" type="text" name="name" value="${name}"/&gt;&lt;/label&gt;
    &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>
        We add the zeep prefix to our html tag, it has the value <code class="literal">"http://www.cmbi.ru.nl/libzeep/ml"</code>
        which is the same as the default value for the <code class="computeroutput">ns</code> parameter
        in the <code class="computeroutput"><a class="link" href="../zeep/http/webapp.html" title="Class webapp">zeep::http::webapp</a></code>
        constructor. Note that the input tag has an attribute with value '${data}'.
        This is a piece of expression language script. This will be explained below:
      </p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">zeep</span><span class="special">/</span><span class="identifier">http</span><span class="special">/</span><span class="identifier">webapp</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">zeep</span><span class="special">/</span><span class="identifier">http</span><span class="special">/</span><span class="identifier">webapp</span><span class="special">/</span><span class="identifier">el</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">bind</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>

<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">;</span>

<span class="keyword">class</span> <span class="identifier">MyWebApp</span> <span class="special">:</span> <span class="keyword">public</span> <code class="computeroutput"><a class="link" href="../zeep/http/webapp.html" title="Class webapp">zeep::http::webapp</a></code>
<span class="special">{</span>
  <span class="keyword">public</span><span class="special">:</span>
    <span class="identifier">MyWebApp</span><span class="special">();</span>

    <span class="keyword">void</span> <span class="identifier">handle_welcome</span><span class="special">(</span><span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/request.html" title="Struct request">zeep::http::request</a></code><span class="special">&amp;</span> <span class="identifier">request</span><span class="special">,</span>
           <span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code><span class="special">&amp;</span> <span class="identifier">scope</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="../zeep/http/reply.html" title="Class reply">zeep::http::reply</a></code><span class="special">&amp;</span> <span class="identifier">reply</span><span class="special">);</span>
    <span class="keyword">void</span> <span class="identifier">handle_salute</span><span class="special">(</span><span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/request.html" title="Struct request">zeep::http::request</a></code><span class="special">&amp;</span> <span class="identifier">request</span><span class="special">,</span>
           <span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code><span class="special">&amp;</span> <span class="identifier">scope</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="../zeep/http/reply.html" title="Class reply">zeep::http::reply</a></code><span class="special">&amp;</span> <span class="identifier">reply</span><span class="special">);</span>
<span class="special">};</span>

<span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">MyWebApp</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">mount</span><span class="special">(</span><span class="string">""</span><span class="special">,</span>       <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">handle_welcome</span><span class="special">,</span> <span class="keyword">this</span><span class="special">,</span> <span class="identifier">_1</span><span class="special">,</span> <span class="identifier">_2</span><span class="special">,</span> <span class="identifier">_3</span><span class="special">));</span>
  <span class="identifier">mount</span><span class="special">(</span><span class="string">"salute"</span><span class="special">,</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">bind</span><span class="special">(&amp;</span><span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">handle_salute</span><span class="special">,</span> <span class="keyword">this</span><span class="special">,</span> <span class="identifier">_1</span><span class="special">,</span> <span class="identifier">_2</span><span class="special">,</span> <span class="identifier">_3</span><span class="special">));</span>
<span class="special">}</span>

<span class="keyword">void</span> <span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">handle_welcome</span><span class="special">(</span><span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/request.html" title="Struct request">zeep::http::request</a></code><span class="special">&amp;</span> <span class="identifier">request</span><span class="special">,</span>
           <span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code><span class="special">&amp;</span> <span class="identifier">scope</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="../zeep/http/reply.html" title="Class reply">zeep::http::reply</a></code><span class="special">&amp;</span> <span class="identifier">reply</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">create_reply_from_template</span><span class="special">(</span><span class="string">"form.xhtml"</span><span class="special">,</span> <span class="identifier">scope</span><span class="special">,</span> <span class="identifier">reply</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">void</span> <span class="identifier">MyWebApp</span><span class="special">::</span><span class="identifier">handle_salute</span><span class="special">(</span><span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/request.html" title="Struct request">zeep::http::request</a></code><span class="special">&amp;</span> <span class="identifier">request</span><span class="special">,</span>
           <span class="keyword">const</span> <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code><span class="special">&amp;</span> <span class="identifier">scope</span><span class="special">,</span> <code class="computeroutput"><a class="link" href="../zeep/http/reply.html" title="Class reply">zeep::http::reply</a></code><span class="special">&amp;</span> <span class="identifier">reply</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">zeep</span><span class="special">::</span><span class="identifier">http</span><span class="special">::</span><span class="identifier">parameter_map</span> <span class="identifier">params</span><span class="special">;</span>
  <span class="identifier">get_parameters</span><span class="special">(</span><span class="identifier">scope</span><span class="special">,</span> <span class="identifier">params</span><span class="special">);</span>

  <span class="identifier">string</span> <span class="identifier">name</span> <span class="special">=</span> <span class="identifier">params</span><span class="special">.</span><span class="identifier">get</span><span class="special">(</span><span class="string">"name"</span><span class="special">,</span> <span class="string">""</span><span class="special">).</span><span class="identifier">as</span><span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;();</span>

  <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code> <span class="identifier">sub</span><span class="special">(</span><span class="identifier">scope</span><span class="special">);</span>
  <span class="identifier">sub</span><span class="special">.</span><span class="identifier">put</span><span class="special">(</span><span class="string">"name"</span><span class="special">,</span> <span class="identifier">name</span><span class="special">);</span>

  <span class="identifier">create_reply_from_template</span><span class="special">(</span><span class="string">"form.xhtml"</span><span class="special">,</span> <span class="identifier">sub</span><span class="special">,</span> <span class="identifier">reply</span><span class="special">);</span>
<span class="special">}</span>

<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
  <span class="identifier">MyWebApp</span> <span class="identifier">server</span><span class="special">;</span>
  <span class="identifier">server</span><span class="special">.</span><span class="identifier">bind</span><span class="special">(</span><span class="string">"0.0.0.0"</span><span class="special">,</span> <span class="number">80</span><span class="special">);</span>
  <span class="identifier">server</span><span class="special">.</span><span class="identifier">run</span><span class="special">(</span><span class="number">1</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
        This time, we add a new handler for the 'salute' page. The form has an action
        that points to this salute page. As can be seen in the <code class="computeroutput"><span class="identifier">handle_salute</span></code>
        method, we first collect the parameters passed in. Parameters are accessed
        by name. We then create a sub scope of the scope passed in. In this sub scope
        we put the value of the parameter so that the XHTML processor can access
        it. And then we return a reply based on the contents of the <code class="literal">form.xhtml</code>
        template and the contents of the sub scope we created.
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="libzeep.webapp.el"></a><a class="link" href="webapp.html#libzeep.webapp.el" title="Using el script">Using <code class="computeroutput"><span class="identifier">el</span></code>
      script</a>
</h3></div></div></div>
<p>
        <code class="computeroutput"><span class="identifier">el</span></code> means <span class="emphasis"><em>Expression
        Language</em></span>. It is a script language that tries to be like <a href="http://en.wikipedia.org/wiki/Unified_Expression_Language" target="_top">http://en.wikipedia.org/wiki/Unified_Expression_Language</a>.
        The objects can be created in the C++ server code using the <code class="computeroutput"><a class="link" href="../zeep/http/el/object.html" title="Class object">zeep::http::el::object</a></code>
        class. Object created this way are then stored in an <code class="computeroutput"><a class="link" href="../zeep/http/el/scope.html" title="Class scope">zeep::http::el::scope</a></code>
        object and passed along to the XHTML processing code.
      </p>
<p>
        <code class="computeroutput"><a class="link" href="../zeep/http/el/object.html" title="Class object">zeep::http::el::object</a></code> objects can contain
        simple data and arrays. E.g., to create an array you could write:
      </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">zeep</span><span class="special">::</span><span class="identifier">http</span><span class="special">;</span>

<span class="identifier">vector</span><span class="special">&lt;</span><span class="identifier">el</span><span class="special">::</span><span class="identifier">object</span><span class="special">&gt;</span> <span class="identifier">ints</span><span class="special">;</span>
<span class="keyword">for</span> <span class="special">(</span><span class="keyword">int</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special">&lt;</span> <span class="number">10</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span><span class="special">)</span>
<span class="special">{</span>
	<span class="identifier">el</span><span class="special">::</span><span class="identifier">object</span> <span class="identifier">int_object</span><span class="special">;</span>
	<span class="identifier">int_object</span><span class="special">[</span><span class="string">"value"</span><span class="special">]</span> <span class="special">=</span> <span class="identifier">i</span><span class="special">;</span>
	<span class="identifier">ints</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">int_object</span><span class="special">);</span>
<span class="special">}</span>

<span class="identifier">scope</span><span class="special">.</span><span class="identifier">put</span><span class="special">(</span><span class="string">"ints"</span><span class="special">,</span> <span class="identifier">el</span><span class="special">::</span><span class="identifier">object</span><span class="special">(</span><span class="identifier">ints</span><span class="special">));</span>
</pre>
<p>
        And then you can access this in the XHTML:
      </p>
<pre class="programlisting">1: ${ints[1].value}, 2: ${ints[2].value}
</pre>
<p>
        Which should output "1: 1, 2: 2"
      </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="libzeep.webapp.processing_tags"></a><a class="link" href="webapp.html#libzeep.webapp.processing_tags" title="Processing Tags">Processing Tags</a>
</h3></div></div></div>
<p>
        The method <code class="computeroutput"><span class="identifier">create_reply_from_template</span></code>
        takes the name of a template file and a scope to generate the output XHTML.
        We've already seen that <code class="computeroutput"><span class="identifier">el</span></code>
        scripts are processed by this method. But there is more, several special
        tags in the template are processed in a special way. These tags are in a
        separate XML namespace. You can change this name space using the <code class="computeroutput"><span class="identifier">ns</span></code> parameter in the <code class="computeroutput"><a class="link" href="../zeep/http/webapp.html" title="Class webapp">zeep::http::webapp</a></code> constructor, the default
        is <code class="literal">http://www.cmbi.ru.nl/libzeep/ml</code>.
      </p>
<p>
        In the template for the form example above you might have noticed the <code class="literal">&lt;zeep:if&gt;</code>
        tag. This tag takes one attribute called <code class="computeroutput"><span class="identifier">test</span></code>
        and the value of this tag is interpreted as a <code class="computeroutput"><span class="identifier">el</span></code>
        script. If the script evaluates to something other than empty, zero or false,
        the content of the <code class="literal">&lt;zeep:if&gt;</code> tag is included, otherwise
        it is discarded in the output.
      </p>
<p>
        There are several predefined processing tags which are summarized below.
        You can also add your own processing tags using the <code class="computeroutput"><a class="link" href="../zeep/http/webapp.html#idp7720512-bb">zeep::http::webapp::add_processor</a></code> method. This
        method takes a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span></code> parameter for the name of the tag
        and a <code class="computeroutput"><span class="identifier">processor_type</span></code> parameter
        which is a call back function.
      </p>
<div class="table">
<a name="libzeep.webapp.processing_tags.list_of_predefined_processing_tags"></a><p class="title"><b>Table&#160;1.&#160;List of predefined processing tags</b></p>
<div class="table-contents"><table class="table" summary="List of predefined processing tags">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  tag name (without prefix)
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
<th>
                <p>
                  Example
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  include
                </p>
              </td>
<td>
                <p>
                  Takes one parameter named <code class="computeroutput"><span class="identifier">file</span></code>
                  and replaces the tag with the processed content of this file
                </p>
              </td>
<td>
                <p>
                  <code class="literal">&lt;zeep:include file="menu.xhtml"/&gt;</code>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  if
                </p>
              </td>
<td>
                <p>
                  Takes one parameter named <code class="computeroutput"><span class="identifier">test</span></code>
                  containing an <code class="computeroutput"><span class="identifier">el</span></code>
                  script. This script is evaluated and if the result is not empty,
                  zero or false, the content of the <code class="computeroutput"><span class="keyword">if</span></code>
                  tags is inserted in the output. Otherwise, the content is discarded.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:if test="${not empty name}"&gt;
  Hello ${name}
&lt;/zeep:if&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  iterate
                </p>
              </td>
<td>
                <p>
                  Takes two parameters, <code class="computeroutput">collection</code> which contains an
                  <code class="computeroutput">el</code> script that evaluates to an array <code class="computeroutput">el::object</code>
                  and a name in <code class="computeroutput">var</code>. The content of the <code class="computeroutput">iterate</code>
                  tag is included for each value of <code class="computeroutput">collection</code> and
                  <code class="computeroutput">var</code> will contain the current value.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;ul&gt;&lt;zeep:iterate collection="${names}" var="name"&gt;
  &lt;li&gt;${name}&lt;/li&gt;
&lt;/zeep:iterate&gt;&lt;/ul&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  for
                </p>
              </td>
<td>
                <p>
                  Takes three parameters. The parameters <code class="computeroutput">begin</code> and
                  <code class="computeroutput">end</code> should evaluate to a number. The parameter <code class="computeroutput">var</code>
                  contains a name that will be used to hold the current value when
                  inserting the content of the <code class="computeroutput">for</code> tag in each iteration
                  of the for loop between <code class="computeroutput">begin</code> and <code class="computeroutput">end</code>.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:for begin="1" end="3" var="i"&gt;
  ${i},
&lt;/zeep:for&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  number
                </p>
              </td>
<td>
                <p>
                  Format the number in the <code class="computeroutput">n</code> parameter using the <code class="computeroutput">f</code>
                  format. This is limited to the formats <code class="literal">'#.##0'</code>
                  and <code class="literal">'#.##0B'</code> for now. The first formats an integer
                  value using thousand separators, the second tries to format the
                  integer value in a power of two multiplier (kibi, mebi, etc.) with
                  a suffix of <code class="computeroutput">B</code>, <code class="computeroutput">M</code>, <code class="computeroutput">G</code>, etc.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:number n="1024" f="0.00#B"/&gt;
Will output 1K
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  options
                </p>
              </td>
<td>
                <p>
                  This tag will insert multiple <code class="literal">&lt;option&gt;</code>
                  tags for each element in the <code class="computeroutput">collection</code> parameter.
                  This <code class="computeroutput">collection</code> paramter can contain an array of strings
                  or it can contain an array of <code class="computeroutput">el::object</code>. In the latter
                  case, you can specify a <code class="computeroutput">value</code> and <code class="computeroutput">label</code>
                  parameter to name the value and label fields of these objects.
                  A <code class="computeroutput">selected</code> parameter can be used to select the current
                  value of the options.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:options collection="${names}"
  value="id" label="fullName" selected="1" /&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  option
                </p>
              </td>
<td>
                <p>
                  Generate a single <code class="literal">&lt;option&gt;</code> tag with a
                  value as specified in the <code class="computeroutput">value</code> parameter. If <code class="computeroutput">selected</code>
                  evaluates to the same value as <code class="computeroutput">value</code>, the option is
                  selected. The content of the <code class="literal">&lt;option&gt;</code>
                  tag is inserted in the final tag.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:option value="1" selected="${user}"&gt;
  John Doe
&lt;/zeep:option&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checkbox
                </p>
              </td>
<td>
                <p>
                  Create an <code class="literal">&lt;input&gt;</code> tag with type <code class="computeroutput">checkbox</code>.
                  The parameter <code class="computeroutput">name</code> is used as name attribute and the
                  parameter <code class="computeroutput">checked</code> is evaluated to see if the checkbox
                  should be in checked mode.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:checkbox name='cb1' checked='${true}'&gt;
  Check me
&lt;/zeep:checkbox&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  url
                </p>
              </td>
<td>
                <p>
                  The url processing tag creates a new variable in the current scope
                  with the name as specified in the <code class="computeroutput">var</code> parameter. It
                  then creates a list of all original HTTP parameters for the current
                  page. You can override these parameter, and add new ones, by adding
                  <code class="literal">&lt;param&gt;</code> tags in the <code class="literal">&lt;url&gt;</code>
                  tag.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:url var="next"&gt;
  &lt;zeep:param name='page' value='${page + 1}'/&gt;
&lt;zeep:url&gt;
&lt;a href="${next}"&gt;Next page&lt;/a&gt;
</pre>
<p>
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  param
                </p>
              </td>
<td>
                <p>
                  see <code class="literal">url</code> above.
                </p>
              </td>
<td class="auto-generated">&#160;</td>
</tr>
<tr>
<td>
                <p>
                  embed
                </p>
              </td>
<td>
                <p>
                  This tag takes the content of the <code class="computeroutput">var</code> parameter which
                  should contain valid XML and puts the processed value in the document.
                </p>
              </td>
<td>
                <p>
</p>
<pre class="programlisting">&lt;zeep:embed var="&amp;lt;em&amp;gt;hello, world!&amp;lt;/em&amp;gt;"/&gt;
</pre>
<p>
                </p>
              </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2012 Maarten L. Hekkelman<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="soap.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="../index/s05.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>