Am Samstag 08 Mai 2010 08:28:40 schrieb Ralf M.:
> Hi,
> I would like to display on a web page vector-data of a single record
> as in the C++ example below, and when the user pushes Next button
> display the next record and when he pushes Prev button display
> the previous record.
> So this means IMHO dynamically generating the web page, isn't it?
> Can this be done in tntnet?
Of course you need dynamic web pages for that and of course with tntnet you
can do that. If you have a std::vector in your session scope and a iterator or
the number of the current record, you can just increment or decrement the
current record if the user presses the next or previous button. Something like
this:
----------------------------------------------------
<%pre>
#include <vector>
</%pre>
<%session>
std::vector<int> myVector;
std::vector::size_type currentPos = 0;
</%session>
<%args>
first;
last;
next;
previous;
</%args>
<%cpp>
if (myVector.empty())
{
// initialize with some test data
myVector.push_back(17);
myVector.push_back(18);
myVector.push_back(21);
myVector.push_back(3);
}
if (!first.empty())
{
currentPos = 0;
}
else if (!last.empty())
{
currentPos = myVector().size() - 1;
}
else if (!next.empty())
{
if (currentPos + 1 < myVector.size())
++currentPos;
}
else if (!previous.empty())
{
if (currentPos > 0)
--currentPos;
}
if (currentPos >= myVector.size())
return HTTP_OK;
</%cpp>
<p>content of record <$ currrentPos $>: <$ myVector[currentPos] $></p>
<form>
<input type="submit" name="first" value="first">
<input type="submit" name="previous" value="previous">
<input type="submit" name="next" value="next">
<input type="submit" name="last" value="last">
</form>
----------------------------------------------------
Tommi
------------------------------------------------------------------------------
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general