When I added the AJAX support, I created the custom components because
I felt the view should handle the AJAX zones, not the business logic.

With that in mind:

ajaxCommandLink:
Attribute for "ajaxZone"
On "broadcast", check if the type is an action event for the current component
if so, use AAUtils to add the zone from the attribute

ajaxTree:
Attribute for ajaxZone
custom toggle expansion method (override) that will add the "ajaxZone"
property value to AAUtils's zones to refresh when executed.

If you don't mind putting view code in your action methods, you can
add it there, or create action listeners. Since the AAUtils methods
are static, you could use a parameter and a action listener to do
this:

<t:commandLink>
 <f:actionListener type="customAjaxListener" />
 <f:param name="ajaxZone" value="myzone1, myzone2" />
</t:commandLink>

This is more clunky in the UI, but then you don't have to code the
components (which really isn't that hard to do.

Hope that helps,
Andrew

On 7/6/06, Todd Patrick <[EMAIL PROTECTED]> wrote:
Thanks, I did understand your blog note.

Just the elements in the XHTML example threw me off.

I've been reviewing the AjaxAnywhere demo examples and I believe I can
use a combination of your guide with a MyFaces Tomahawk tree2 that I am
currently using below.

The only thing I am somewhat confused on is where would I put the
following Ajax Request check for my tree2:

if (AAUtils.isAjaxRequest(getRequest())) {
        AAUtils.addZonesToRefresh(getRequest(), "categoryList");
}

private HttpServletRequest getRequest() {
        return (HttpServletRequest)
FacesContext.getCurrentInstance().getExternalContext().getRequest();
}


I believe it should go in each of my ActionEvents that my tree uses?

Thanks,

--Todd


<t:tree2
    id="commandTree"
    value="#{tbrowser.commandTreeModel}"
    var="node"
    varNodeToggler="c"
    showRootNode="false"
    clientSideToggle="false"
    preserveToggle="true"
    showLines="true"
    showNav="true">
    <f:facet name="command-index">
        <h:panelGroup>
            <f:facet name="expand">
                <t:graphicImage value="resources/yellow-folder-open.png"
rendered="#{c.nodeExpanded}" border="0"/>
            </f:facet>
            <f:facet name="collapse">
                <t:graphicImage
value="resources/yellow-folder-closed.png" rendered="#{!c.nodeExpanded}"
border="0"/>
            </f:facet>
            <h:outputText value="#{node.description}"
styleClass="NodeFolder"/>
        </h:panelGroup>
    </f:facet>
    <f:facet name="commands">
        <h:panelGroup>
            <t:commandLink immediate="true"
actionListener="#{tbrowser.expandElement}">
                <t:graphicImage value="resources/document.png"
rendered="#{c.nodeExpanded}" border="0"/>
                <t:graphicImage value="resources/document.png"
rendered="#{!c.nodeExpanded}" border="0"/>
                <h:outputText styleClass="#{t.nodeSelected ?
'Documentselected':'Document'}" value="#{node.description}"/>
                <t:updateActionListener property="#{tbrowser.elementid}"
value="#{node.identifier}" />
            </t:commandLink>
        </h:panelGroup>
    </f:facet>
</t:tree2>

-----Original Message-----
From: Andrew Robinson [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 06, 2006 11:14 AM
To: MyFaces Discussion
Subject: Re: What is the my:ajaxTree element in the MyFaces Tree2 -
Creating a lazy loading tree guide?

It is an example. For my company, I extended Tree2 and added built in
AjaxAnywhere compatibility. Since it is a commercial application, I
cannot share this code. As in my blog, I mentioned that "AJAX'ing" the
tree is a whole different topic. I may looking into helping the
community out by creating a new tomahawk/sandbox component that is an
extension of tree2 with AJAX support, but I am not sure if I will have
the time.

As for ajaxCommandLink, it is once again an extension (this one of
commandLink) that works with AjaxAnywhere. (note: ajax4jsf has built in
support for components such as these, but not the tree).

-Andrew

On 7/6/06, Todd Patrick <[EMAIL PROTECTED]> wrote:
> What is the my:ajaxTree element in the  MyFaces Tree2 - Creating a
> lazy loading tree guide?
>
> Below, there is a reference to my:ajaxTree and my:ajaxCommandLink. I
> did a Google search and nothing is referenced for these.
>
> Thanks,
>
> --Todd
>
>
> <aa:zoneJSF id="contentMgmtTreeZone">
> <my:ajaxTree
> value="#{contentMgmtBean.treeModel}"
> ajaxZone="contentMgmtTreeZone"
> var="_node"
> clientSideToggle="false"
> varNodeToggler="t"
> showRootNode="false">
> <f:facet name="folder">
> <t:panelGroup>
> <t:graphicImage
> styleClass="treeNodeIcon"
> url="#{_node.expanded ?
> '/images/contentMgmt/openfolder.gif' :
> '/images/contentMgmt/closedfolder.gif'}" /> <t:outputText
> styleClass="folderNodeText"
> value="#{_node.name}" />
> </t:panelGroup>
> </f:facet>
> <f:facet name="file">
> <my:ajaxCommandLink
> ajaxZone="contentMgmtTreeZone,myResultZone"
> actionListener="#{contentMgmtBean.nodeSelected}"
> styleClass="fileNodeLink#{
> contentMgmtBean.currentFileName eq _node.name ?
> ' selectedNode' : ''}">
> <t:updateActionListener
> property="#{contentMgmtBean.currentFileName}"
> value="#{_node.name}" />
> <t:graphicImage
> styleClass="treeNodeIcon"
> url="/images/contentMgmt/file.gif" />
> <t:outputText
> styleClass="fileNodeText"
> value="#{_node.name}" />
> </ost:ajaxCommandLink>
> </f:facet>
> </my:ajaxTree>
> </aa:zoneJSF>
>

Reply via email to