javascript - Cannot execute body onload function in <body> from Sitemesh -
i trying create simple application includes sitemesh decorating resulting page.
following simple page trying create.
<%@ include file="/web-inf/jsp/include.jsp" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <title>creating simple map</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=aizasyaxwlpzttcgidurbkce345xdxtfws5gues"></script> <script type="text/javascript" src="<c:url value=" /resources/js/keydragzoom_packed.js " />"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> function init() { alert("hi"); } </script> <style> html, body { width: 100%; height: 100%; margin: 0; padding: 0; } </style> </head> <body onload="init();"> <h1>smart farm application</h1> <p>time right : <c:out value="${now}" /> </p> <table border="1" style="width: 1000px; height: 800px;"> <tr> <th>google map api</th> <th>google chart section</th> </tr> <tr> <td rowspan="2"> <div id="google_map_area" style="width: 500px; height: 800px;"></div> </td> <td> <div id="scatter_chart_area" style="width: 500px; height: 400px;"></div> </td> </tr> </table> </body> </html>
and following decorator page:
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@page contenttype="text/html; charset=utf-8" %> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>https://bharatonjava.wordpress.com | <decorator:title default="sitemesh example" /> </title> <link rel="stylesheet" type="text/css" src="<c:url value=" /resources/assets/css/style.css " />"> <decorator:head /> </head> <body> <table class="maintable" id="page-container" cellpadding="5" cellspacing="0" border="1" align="center"> <tr> <td colspan="2" id="page-header"> <%@ include file="/web-inf/includes/header.jsp" %> </td> </tr> <tr> <td id="nav-container" colspan="2"> <%@ include file="/web-inf/includes/navigation.jsp" %> </td> </tr> <tr> <td id="left-nav-container"> <%@ include file="/web-inf/includes/navigationleft.jsp" %> </td> <td id="content-container"> <decorator:body onload="<decorator:getproperty property='body.onload' />"> </decorator:body> </td> </tr> <tr> <td colspan="2" id="page-footer"> <%@ include file="/web-inf/includes/footer.jsp" %> </td> </tr> </table> <table align="center"> <tr> <td align="center"> <br /><a href='https://test.com'>test</a> </td> </tr> </table> </body> </html>
however not getting decorated @ all. when request page browser see following error :
java.lang.runtimeexception: org.apache.jasper.jasperexception: /web-inf/decorators/layout.jsp(37,12) attribute onload invalid tag body according tld com.opensymphony.sitemesh.webapp.decorator.basewebappdecorator.render(basewebappdecorator.java:39) com.opensymphony.sitemesh.webapp.sitemeshfilter.dofilter(sitemeshfilter.java:84)
i can't figure out wrong code above. have spent hours trying figure without going anywhere. has faced before ?
in fact it's onload="init();"
instead of onload="init();"
, that's raises exception, take @ onload event.
or can try this:
window.addeventlistener("load", init, false);
or
body.addeventlistener("load", init, false);
more information @ element.addeventlistener.
Comments
Post a Comment