You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by chumbobumbo <ch...@hotmail.com> on 2009/03/06 04:15:58 UTC

Struts + Dojo problem

This is more of a dojo related question but since struts and dojo combination
is relatively common I thought someone may be able to tell me what's going
on here. 

The problem is that dojo.event.connect doesn't like the element that is
referred in a second .jsp 
(namely the line: 
	
	dojo.event.connect(ListB, 'onChange', 'listBEvent'); 
	
does not work as ListB comes in from listb.jsp, that is referred from
lista.jsp) - subsequently the 'listB' never fires listBEvent.
	
Is there anything that I am missing here or something that I may have
overlooked?	

Any help is greatly appreciated.

99-L Blue



Here is my setup:

struts.xml:

<!DOCTYPE struts PUBLIC 
	"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
	"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
	<constant name="struts.objectFactory" value="spring" />
	<package name="default" extends="struts-default">
	
		<action name="listAAction" class="defaultAction" method="execute">
			<result name="success">jsp/lista.jsp</result>
			<result name="error">jsp/error.jsp</result>
		</action>
		<action name="listBAction" class="defaultAction" method="getListB">
			<result name="success">jsp/listb.jsp</result> 
			<result name="error">jsp/error.jsp</result>
		</action>
		<action name="listCAction" class="defaultAction" method="getListC">
			<result name="success">jsp/listc.jsp</result>
			<result name="error">jsp/error.jsp</result>
		</action>
	</package>
</struts>


lista.jsp:

<script>
	
	function listAEvent(event) {
		alert("listAEvent [" + event.target.name + "]");
		dojo.event.topic.publish("listAEvent");
	}
	function listBEvent(event) {
		alert("listBEvent [" + event.target.name + "]");
		dojo.event.topic.publish("listBEvent");
	}
	
	function init() 
	{
		
		var ListA = dojo.byId('ListA');
        	dojo.event.connect(ListA, 'onchange', 'listAEvent');
        
       	 	var ListB = dojo.byId('ListB');
       		dojo.event.connect(ListB, 'onChange', 'listBEvent');
	}
	
	dojo.addOnLoad(init);	
	
</script>

<tr>
	<td><s:label value="ListA" /></td>
	<td colspan="4"><s:select id="ListA" list="listAList" listKey="listACode" 
			listValue="listADesc" name="model.listACode"/></td>
</tr>

<tr>
	<td><s:label value="ListB" /></td>
	<td colspan="4">
		<s:url id="d_url" action="listBAction.action" /> 
		<s:div showLoadingText="false" id="listBAct" href="%{d_url}" theme="ajax"
			listenTopics="listAEvent" formId=demo"/>
	</td>
</tr>
<tr>
	<td><s:label value="ListC" /></td>
	<td colspan="4">
		<s:url id="c_url" action="listCAction.action" /> 
		<s:div showLoadingText="false" id="listCAct" href="%{c_url}" theme="ajax"
			listenTopics="listBEvent" formId="demo"/>
	</td>
</tr>

listb.jsp:

<%@ taglib prefix="s" uri="/struts-tags"%>
<s:if test="listBList != null">
	<s:select id="ListB" list="listBList"
		name="model.listBCode"/>
</s:if>

listc.jsp:

<%@ taglib prefix="s" uri="/struts-tags"%>
<s:if test="listCList != null">
	<s:select id="ListC" list="listCList" 
		name="model.listCCode"/>
</s:if>

resulting html:

<tr>
	<td><label id="demo_ListA">ListA</label></td>
	
	<td colspan="4">
		<select name="model.listACode" id="ListA">
		    <option value="AC" selected="selected">Selected Code</option>
		    <option value="AM">Another Code</option>
		</select>
	</td>
</tr>

<tr>
	<td><label id="demo_ListB">ListB</label></td>
	<td colspan="4"> 				 
   		<div 	dojoType="struts:BindDiv" 
   			id="listBAct"  
   			formId="demo" 	
   			href="/Eval/listBAction.action"    
   			listenTopics="listAEvent"    
   			showError="true"    
   			showLoading="false">
   		</div>

	</td>
</tr>
<tr>
	<td><label id="demo_ListC">ListC</label></td>
	<td colspan="4">	 
   		<div 	dojoType="struts:BindDiv"
  			id="listCAct"  	
  			formId="demo"  	
  			href="/Eval/listCAction.action"    
  			listenTopics="listBEvent"    
  			showError="true"    
  			showLoading="false">
		</div>
	</td>
</tr>



-- 
View this message in context: http://www.nabble.com/Struts-%2B-Dojo-problem-tp22365550p22365550.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org