New issue 799 by tis...@gmail.com: Jquery script is not working when the
page is included in Struts2 tiles. But its functioning when I invoke the
page directly
http://code.google.com/p/struts2-jquery/issues/detail?id=799
(This is for feature requests and bugs in Struts2 jQuery Plugin - for
getting help, please use the User Group.
http://groups.google.com/group/struts2-jquery )
What steps will reproduce the problem?
1. Code from my JSP.
File name: test.jsp
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<sj:head />
<s:url id="ajax" value="/exchangeRate.action">
</s:url>
<sj:div id="resultnormal" href="%{ajax}" indicator="indicator"
onBeforeTopics="beforeDiv" onCompleteTopics="completeDiv"
onErrorTopics="errorDiv"
cssClass="result ui-widget-content ui-corner-all">
Loading..
</sj:div>
<br /> <strong>Div with invalid URL:</strong>
<sj:div id="resulterror" href="/not_exist.html" indicator="indicator"
onCompleteTopics="completeDiv" onErrorTopics="errorDiv"
cssClass="result ui-widget-content ui-corner-all">
Loading
</sj:div>
2. Invoked test.jsp directly it worked fine.
3. I have included test.jsp in a tiles definition
<definition name="baseLayout" template="/pages/common/BaseLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="body" value="" />
<put-attribute name="header" value="/pages/common/test.jsp" />
</definition>
in web.xml
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
4. Invoked by an action
What is the expected output? What do you see instead?
a. In div id "resultnormal" the result displayed but there was not Alert.
But Alert should come first and then the result.
b. in div id "resulterror" its still showing "loading" text. But
Expecting "Error request Not Found completed with error.
Status: 404"
Which struts2 version?
2.3.1.2
Which struts2-jquery plugin version?
3.3.0
Please provide any additional information below.
I also tried putting <sj:head/> on the basicLayout.jsp but still javascript
methods are not getting called when the page is part of a tiles definition.
It perfectly works fine when the page is invoked directly.
Please advice what's wrong with my settings..
Sorry I have missed the script to copy..
<script type="text/javascript">
$.subscribe('beforeDiv', function(event, data) {
alert('Before request ');
});
$.subscribe('completeDiv', function(event, data) {
if (event.originalEvent.status == "success") {
$('#resultnormal').append(
'<br/><br/><strong>Completed request '
+ event.originalEvent.request.statusText
+ ' completed with ' + event.originalEvent.status
+ '.</strong><br/>Status: '
+ event.originalEvent.request.status);
}
});
$.subscribe('errorDiv', function(event, data) {
$('#resulterror').html(
'<br/><br/><strong>Error request '
+ event.originalEvent.request.statusText
+ ' completed with ' + event.originalEvent.status
+ '.</strong><br/>Status: '
+ event.originalEvent.request.status);
});
$.subscribe('completediv2', function(event, data) {
alert(event.originalEvent.status);
setTimeout(function() {
$.publish('reloaddiv2');
}, 10000);
});
</script>