On 31. des. 2013 07:40, Olaf Radicke wrote:
>> "Carsten A. Arnholm" <[email protected]> hat am 31. Dezember 2013 um 03:44
>> The result is that the image fills the whole browser window, everything
>> else is gone. Somehow, the image data is supposed be placed where the
>> img-tag is, like you explained. But it isn't in this case, and what if
>> there were several img-tags in the page? Where is the image supposed to
>> go then?
>>
>> Somehow there must be a match between the name of the image in html and
>> the "name" of the data returned, but the exact technique eludes me.
>
> I have a question: Do you have two components?  Components A) is shipping
> the image file - Right? And components B) is calling components  A) in a
> HTML site with img tag? Right?

Hi Olaf!

What I have now is a single application (with a main program) containing 
an integrated component ("hello"). All of the Tntnet related work is 
done in this application.

But I also have a shared object which is completely independent of 
Tntnet, it actually has a class that provides the image data. I wanted 
to check that I could separate general shared images (*.so) and provode 
a "Web GUI" layer using Tntnet. My test shows that this is working as I 
hoped.

So my Application contains the Tntnet component "hello" (the only 
component). There is a hello.ecpp containing the html code I showed.


hello.ecpp
=========

<%pre>
// put your includes here
#include <iostream>
#include "filepicker/file_collection.h"
</%pre>
<%args>
// define the query parameters
     int arg1 = -1;
</%args>
<%session>
// define your session scope variables here
// std::string mySessionState;
</%session>
<%cpp>
// put your C++ code here
    file_collection collection;

    collection.collect_files("/tmp/Kontor");
    std::string image_data;

    if(arg1 > -1) {
       if(collection.get_file_data(arg1,image_data)) {
          reply.setContentType("image/jpeg");
          reply.out() << image_data;
          cout << " image data sent" << endl;
       }
    }
</%cpp>
<html>
   <head>
   <title>Tntnet-application hello</title>
  </head>
   <body bgcolor="black" text="White" link="yellow" Vlink="yellow">
   <h1>hello</h1>
   <p>Hello Tntnet world!</p>
     <table>
       <tr> <td>
             <form>
              <input type="text" name="arg1" value="<$arg1$>">
            </form>
       </td> </tr>
       <tr> <td> <img src="/theimage.jpg"> </td> </tr>
     </table>
   </body>
</html>

===

The essential part of main is;

    try {
       tnt::Tntnet app;
       app.listen("0.0.0.0", port);
       app.mapUrl("^/$", "hello").setPathInfo("/hello");
       app.mapUrl("^/(.*)$", "$1");

       std::cout << "The web application is found at http://localhost:"; 
<< port << "/hello" << std::endl;
       app.run();
    }
    catch (const std::exception& e)
    {
       std::cerr << e.what() << std::endl;
    }

====

Happy new year to you all!

Best regards
Carsten Arnholm



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to