You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by am...@yahoo.com on 2005/12/06 18:43:01 UTC

ajax question

Hi, 

I have a screen with many tabs, I would like the tabs to be populated when the
user selects the tab asynchronously. The basic idea is that when a user clicks
on a link, the tab gets populated.

I have looked at the tacos examples and I am having a hard time trying to
figure what I need to do. The closest thing I found is in the PartialPrototype
example, but in this example the link that toggles the dynamic content is in
context of a PartialFor component. I tried to use the example as a starting
point but it's not working. I get this error:

06 Dec 2005 09:20:40 WARN Header with key X-Requested-With and expected value
XMLHttpRequest did not exist, performing non-ajax http response.


Any help that would point me in the right direction would be appreciated.

Thanks,
Amir


Here is my .html:

<a jwcid="linkToggle" class="toggle">
	<span jwcid="@Insert" value="ognl:displayServices ? 'Hide' : 'Details'"/>
</a>

<div id="status"></div>

<div jwcid="selectedCountries@Any" id="selectedCountries">
<table>
	<thead>
		<tr>
			<th>Mobile Id</th>
			<th>ESN/MEID</th>
			<th>Fraud</th>
		</tr>
	</thead>
	<tbody>
		<tr jwcid="@For" keyExpression="mobileId" source="ognl:services"
value="ognl:service" element="tr">
			<td><span jwcid="@Insert" value="ognl:service.mobileId">(925)
555-1212</span></td>	
			<td><span jwcid="@Insert" value="ognl:service.esn">AE230WDXZ</span></td>
			<td><span jwcid="@Insert" value="ognl:service.fraud">true</span></td>	
		</tr>
	</tbody>
</table>

Here is the .page:
<page-specification>
    <component id="linkToggle" type="Tacos:AjaxDirectLink">
        <binding name="listener" value="listener:toggleDisplayServices"/>
        <binding name="updateComponents" value="ognl:{'selectedCountries'}"/>
        <binding name="effects"
            value="template:{highlight:{selectedCountries:'[255,255,184], 500,
500'}"/>
        <binding name="statusElement" value="literal:status"/>
    </component>
</page-specification>

Here is the code:

	public abstract List<ServiceForm> getServices();
	
	public abstract void setServices(List<ServiceForm> services);
	
	public abstract ServiceForm getService();
	
	public abstract boolean getDisplayServices();
	
	public abstract void setDisplayServices(boolean displayServices);
	
	public void toggleDisplayServices(IRequestCycle cycle) {
		setDisplayServices(!getDisplayServices());
		if(getDisplayServices()) {
			final List<ServiceForm> services = new ArrayList<ServiceForm>();
			services.add(new ServiceForm("(925) 555-1214", "ZE5304984", true));
			services.add(new ServiceForm("(925) 555-1215", "ZE5304984", false));
			setServices(services);
		} else {
			setServices(null);
		}
        AjaxWebRequest ajax = 
            (AjaxWebRequest)cycle.getAttribute(AjaxWebRequest.AJAX_REQUEST);
        if (ajax != null) ajax.addStatusResponse("Display services: " +
getDisplayServices());
	}


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


Re: ajax question

Posted by am...@yahoo.com.
Doh! I did'nt include the dojo javascript file.. it seems to be working now :)

--- amirsguard-tapestry@yahoo.com wrote:

> Hi, 
> 
> I have a screen with many tabs, I would like the tabs to be populated when
> the
> user selects the tab asynchronously. The basic idea is that when a user
> clicks
> on a link, the tab gets populated.
> 
> I have looked at the tacos examples and I am having a hard time trying to
> figure what I need to do. The closest thing I found is in the
> PartialPrototype
> example, but in this example the link that toggles the dynamic content is in
> context of a PartialFor component. I tried to use the example as a starting
> point but it's not working. I get this error:
> 
> 06 Dec 2005 09:20:40 WARN Header with key X-Requested-With and expected value
> XMLHttpRequest did not exist, performing non-ajax http response.
> 
> 
> Any help that would point me in the right direction would be appreciated.
> 
> Thanks,
> Amir
> 
> 
> Here is my .html:
> 
> <a jwcid="linkToggle" class="toggle">
> 	<span jwcid="@Insert" value="ognl:displayServices ? 'Hide' : 'Details'"/>
> </a>
> 
> <div id="status"></div>
> 
> <div jwcid="selectedCountries@Any" id="selectedCountries">
> <table>
> 	<thead>
> 		<tr>
> 			<th>Mobile Id</th>
> 			<th>ESN/MEID</th>
> 			<th>Fraud</th>
> 		</tr>
> 	</thead>
> 	<tbody>
> 		<tr jwcid="@For" keyExpression="mobileId" source="ognl:services"
> value="ognl:service" element="tr">
> 			<td><span jwcid="@Insert" value="ognl:service.mobileId">(925)
> 555-1212</span></td>	
> 			<td><span jwcid="@Insert" value="ognl:service.esn">AE230WDXZ</span></td>
> 			<td><span jwcid="@Insert" value="ognl:service.fraud">true</span></td>	
> 		</tr>
> 	</tbody>
> </table>
> 
> Here is the .page:
> <page-specification>
>     <component id="linkToggle" type="Tacos:AjaxDirectLink">
>         <binding name="listener" value="listener:toggleDisplayServices"/>
>         <binding name="updateComponents" value="ognl:{'selectedCountries'}"/>
>         <binding name="effects"
>             value="template:{highlight:{selectedCountries:'[255,255,184],
> 500,
> 500'}"/>
>         <binding name="statusElement" value="literal:status"/>
>     </component>
> </page-specification>
> 
> Here is the code:
> 
> 	public abstract List<ServiceForm> getServices();
> 	
> 	public abstract void setServices(List<ServiceForm> services);
> 	
> 	public abstract ServiceForm getService();
> 	
> 	public abstract boolean getDisplayServices();
> 	
> 	public abstract void setDisplayServices(boolean displayServices);
> 	
> 	public void toggleDisplayServices(IRequestCycle cycle) {
> 		setDisplayServices(!getDisplayServices());
> 		if(getDisplayServices()) {
> 			final List<ServiceForm> services = new ArrayList<ServiceForm>();
> 			services.add(new ServiceForm("(925) 555-1214", "ZE5304984", true));
> 			services.add(new ServiceForm("(925) 555-1215", "ZE5304984", false));
> 			setServices(services);
> 		} else {
> 			setServices(null);
> 		}
>         AjaxWebRequest ajax = 
>             (AjaxWebRequest)cycle.getAttribute(AjaxWebRequest.AJAX_REQUEST);
>         if (ajax != null) ajax.addStatusResponse("Display services: " +
> getDisplayServices());
> 	}
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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