I probably need to add a ResponseBuilder.insertComponents() call pretty
soon, but the basic reason why it's not updating is because the "counter"
and "B" elements probably don't exist on your rendered page already. For it
to update them it needs an element that it can find with something simple
like this javascript:
document.getElementById("counter")
This is usually solved by doing something like:
<span jwcid="[EMAIL PROTECTED]" >
<countercomponent here/>
</span>
You also shouldn't need to specify which form to submit (in 4.1.2 at least).
On 5/3/07, Paul Stanton <[EMAIL PROTECTED]> wrote:
Hi All,
I'm trying to do something very basic with ajax. I simply want a value
to increment when an onchange event is triggered for another component.
The listener is being called via ajax etc. but I cannot get my component
to update. I understand I'm missing the logic which identifies and
updates the component, but have no idea where I need to do it, or what I
need to do.
I have my counter component 'AjaxCount' and my page 'AjaxDemo'.
Hopefully the code explains what I'm trying to do:
The error I'm getting:
"No node could be found to update content in with id counter"
AjaxCount.html:
<h1>Update Count</h1>
<p><span jwcid="@Insert" value="ognl:count">5</span></p>
AjaxCount.java:
@ComponentClass(allowInformalParameters = false)
public abstract class AjaxCount extends ApplicationComponent
{
private int count;
public int getCount()
{
return count;
}
public void setCount(int count)
{
this.count = count;
}
public void increment()
{
setCount(getCount() + 1);
}
}
AjaxDemo.java:
public abstract class AjaxDemo extends ApplicationPage implements
PageBeginRenderListener
{
@InjectComponent("counter")
public abstract AjaxCount getCounter();
@EventListener(targets = "A", events = "onchange", submitForm =
"form")
public void changeA(IRequestCycle cycle)
{
System.out.println("changeA()");
modelB = this.getModelB();
AjaxCount counter = getCounter();
counter.increment();
cycle.getResponseBuilder().updateComponent("B");
cycle.getResponseBuilder().updateComponent("counter");
}
...
}
AjaxDemo.html:
...
<span jwcid="[EMAIL PROTECTED]"/>
...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Jesse Kuhnert
Tapestry/Dojo team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com