Reputation: 81
I'm running a tomcat 8/spring 5.4.1/Tapestry 5.4.1 setup. I have a simple template with a component for layout. The template calls a spring service that gets the count of people. Simple. What's odd is that the Index template is being loaded twice and it seems that it's due to the t:type="layout" tag in the index.tml page which references the layout component. If I remove this, it's called only once.
This is the log from tomcat clearly showing that index is called twice.
> 2016-07-01 09:47:39 INFO PageLoader:213 - Loaded page 'Index' (en) in 302.278 ms
> 2016-07-01 09:47:39 INFO Index:25 - [Index] onActivate
> 2016-07-01 09:47:39 INFO Index:20 - [Index] setupRender
> 2016-07-01 09:47:39 INFO Index:31 - [Layout] setupRender
> 2016-07-01 09:47:39 INFO Index:30 - [Index] getPersonCount
> 2016-07-01 09:47:40 INFO QueryTranslatorFactoryInitiator:47 - HHH000397: Using ASTQueryTranslatorFactory
> Hibernate: select count(*) as col_0_0_ from person person0_
> 2016-07-01 09:47:40 INFO Index:25 - [Index] onActivate
> 2016-07-01 09:47:40 INFO Index:20 - [Index] setupRender
> 2016-07-01 09:47:40 INFO Index:31 - [Layout] setupRender
> 2016-07-01 09:47:40 INFO Index:30 - [Index] getPersonCount
> Hibernate: select count(*) as col_0_0_ from person person0_
Index.tml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html t:type="layout" t:pageTitle="Admin Main" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd" xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title></title>
</head>
<body>
${personCount}
</body>
</html>
Layout.tml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title></title>
<link rel="stylesheet" type="text/css" href="dev/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="dev/css/main.css"/>
<script src="dev/js/jquery-2.2.4.js"></script>
<script src="dev/js/bootstrap.js"></script>
</head>
<!-- Page Body -->
<body>
<div id="mainContainer" class="container">
<t:body/>
</div>
</body>
</html>
Upvotes: 0
Views: 124
Reputation: 31
May be you are trying to return HomePage after Hibernate call is executed. If you observe after Hibernate call execution your page is again loading
Upvotes: 0