Hello,
the components defined in a <%def> are internal subcomponents and are
not directly reachable from mappings. They can be called from other
components using <&..>.
You can of course do some more sophisticated mapping to make them
callable e.g.:
<mapping>
<target>$1@foobar</target>
<url>^/(.*)\.(.*)</url>
<pathinfo>$1.$2</pathinfo>
</mapping>
Here you specify a mapping rule, where you can pass a component and a
extension to the component. In the component you can then use "<&
(request.getPathInfo()) >" to call the sub component e.g.:
<!DOCTYPE html>
<html>
<body>
<h1>foobar</h1>
<& (request.getPathInfo()) qparam >
</body>
</html>
<%def castamio>
Hi there
</%def>
Now calling the url "/foobar.castamio" will call the outer component and
put the content of the subcomponent into the body.
Note that the "qparam" at the end tells tntnet to pass all query
parameters to the subcomponent.
Tommi
Am 27.09.2016 um 05:27 schrieb nerdux:
> Hello, I'm a newhie with tntnet, please be patient...
>
> I am unsuccesfully trying to call a local subcomponent with ajax, it
> just can't find it. The mapping section in tntnet.xml is the default
> one, including:
>
> <!-- map /comp to comp@inmo -->
> <mapping>
> <target>$1@inmo</target>
> <url>^/(.*)</url>
> </mapping>
>
> In the file inmo.ecpp I've got (relevant pieces of code):
>
> <div id="testsec"></div>
>
> <script
> src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
>
> <script type="text/javascript">
> $(document).ready(function(){
> $("#testsec").load("castamio");
> });
> </script>
>
> And just after closing the </html> tag, the subcomponent definition:
>
> <%def castamio>
> <p>testing paragraph</p>
> </%def>
>
> However, the application complains about not finding this subcomponent:
> 2016-09-26 23:58:33.35716 [5729.140511674988288] INFO tntnet.worker -
> request GET /castamio from client 192.168.0.14 (...)
> 2016-09-26 23:58:33.35724 [5729.140511674988288] WARN tntnet.worker -
> http-Error: 404 Not Found: vhost: 192.168.0.100:8000 /castamio
>
> What coukd I be doing weong?
>
> Regards,
> Mario
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Tntnet-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tntnet-general
------------------------------------------------------------------------------
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general