multiple a4j:include and multiple transactions
jovincen Dec 5, 2010 4:45 AMHi All,
I'm (trying ;P) to build an AJAX heavy website and am having some difficulties with a4j:include. I'm quite new to J2EE and Seam so the answer is probably obvious :/
Is it possible to build a single page from many a4j:include's? where each is independent of the others?
Essentially I have a single template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j">
<ui:composition template="layout/template.xhtml">
<ui:define name="body">
<a:form>
<a:outputPanel ajaxRendered="true">
<a:include viewId="commonTemplate.xhtml">
<ui:param name="uniqueID" value="one" />
<ui:param name="backingBean" value="#{myFirstBean}" />
</a:include>
</a:outputPanel>
</a:form>
<a:form>
<a:include viewId="anotherTemplate.xhtml"></a:include>
</a:form>
<br /><br />
<a:form>
<a:outputPanel ajaxRendered="true">
<a:include viewId="commonTemplate.xhtml">
<ui:param name="uniqueID" value="two" />
<ui:param name="backingBean" value="#{mySecondBean}" />
</a:include>
</a:outputPanel>
</a:form>
</ui:define>
</ui:composition>
</html>Each of the nested templates features a call similar to:
<a:commandLink
value="edit"
action="#{backingBean.beginEdit}"
immediate="false"
>
<s:conversationId />
</a:commandLink>This backingBean beginEdit() is annotated with @Begin(nested=true).
What I'm finding is that after each post all templates on the client are taking the conversation of the latest.
Eg.
If I edit the first bean it is part of conversation 3
If I edit the second bean then both the first and second are part of conversation 4
And the final edit pushes all under the conversation 5.
Seems like the client is re-rendering the <s:conversationid /> with each of the responses.
I have tried nesting these under a single transaction, I think it might be an issue with a4j:include.
Am I doing something fundamentally wrong?
Seems a shame if a4j:include doesn't support this.
Cheers,
Jono