That solution may not work. I just downloaded the last A4J release and
UIAjaxCommandLink is not a UICommand:

java.lang.Object
 extended by javax.faces.component.UIComponent
     extended by javax.faces.component.UIComponentBase
         extended by org.ajax4jsf.framework.ajax.AjaxActionComponent
             extended by org.ajax4jsf.ajax.UIAjaxCommandLink

That means that it would not be compatible with that API. However,
with a little messy use of the decorator pattern, you could create a
UICommand component that delegates all methods to an internal
UIAjaxCommandLink class instance. This way the link that would be
rendered to the HTML would be the AJAX one instead of the standard
one. It wouldn't be the prettiest code, but it should function quite
well. Since the command link would be the A4J one, you wouldn't have
to do any more work. So the process would be:

1) extend UITreeData
2) override getExpandControl()
3) Create a decorator of UICommand that houses UIAjaxCommandLink
4) delegate all methods of the UICommand to the UIAjaxCommandLink for
those methods that are requried (you may not have to decorate them
all).
5) Register your new UITreeData in the faces config, and register the
component in taglib.xml for facelets or create a TLD and tag file for
JSP

This should work assuming the decoration of UICommand to wrap a
UIAjaxCommandLink doesn't present any unforseen issues.

-Andrew


On 9/22/06, Andrew Robinson <[EMAIL PROTECTED]> wrote:
The way that AjaxAnywhere works is that it builds a Set<String> of
"zones" during the processing of a request. JavaScript can start that
Set and then there is an API on the server
(AAUtils.addZonesToRefresh(ServletRequest, String) method) that one
can use.

So in my approach, I let aa.js submit normally (no zones on the
client), then I extend UITreeData & overload the toggleExpanded
function. In that function, I check the "ajaxZone" attribute of my
extended tree component and use that addZonesToRefresh method to make
my tree re-rendered

If you look in the HtmlTreeRenderer class, you will see the following
in the server-side rendering:

UICommand expandControl = tree.getExpandControl();

This means, that if in your extended UITreeData class, you override
the "getExpandControl()" method, you can return an A4J command link
instead of the "standard" one. In there you also have access to the ID
of the tree (since your code is the tree component), so setting the
re-render attribute should be very easy.

This way you can still use the built in navigation icons of the tree.
If I get a chance, maybe I can play around with it sometime and create
a new jsf-comp like the one I did for AA but for A4J. If this email is
enough, please feel free to write a blog or the component yourself.

-Andrew




On 9/22/06, William Huang <[EMAIL PROTECTED]> wrote:
> I dont quite understand the first paragraph..
>
>              "Andrew Robinson"
>              <andrew.rw.robins
>              [EMAIL PROTECTED]>                                              
To
>                                        "MyFaces Discussion"
>              09/22/2006 11:31          <[email protected]>
>              AM                                                         cc
>
>                                                                    Subject
>              Please respond to         Re: ajax4jsf + tree2?
>                  "MyFaces
>                 Discussion"
>              <[EMAIL PROTECTED]
>                  ache.org>
>
>
>
>
>
>
> Doesn't A4J have a server-side API to tell it to include panels during
> the process action phase? That is how I accomplish the AJAX with
> AjaxAnywhere, I would be dissappointed with A4J if that server-side
> Java API was not available.
>
> I tried to look into it at one time briefly, but the documentation for
> A4J is quite horrible (actually there was none when I looked) in
> reference to building custom AJAX components and how to leverage the
> A4J API.
>
> On 9/21/06, William Huang <[EMAIL PROTECTED]> wrote:
> > I use my own plus and minus image instead of hardcoding the tomahawk
> > images.  Is also better to turn off the by adding attribute showLines=
> > "false".   Also I am not sure if reRender="tree".  I had to wrap the tree
> > with a <h:panelGroup id="treePanel"> or <a4j:outputPanel id="treePanel">
> > and reRender="treePanel".  see below
> >
> >      <t:tree2 value="#{dao.treeModel}" id="tree" var="node"
> >               showNav="false" clientSideToggle="false"
> >               showLines="false"
> >               varNodeToggler="t">
> >
> >        <f:facet name="content">
> >          <h:panelGroup>
> >            <a4j:commandLink action="#{t.toggleExpanded}" reRender="tree"
> >                             rendered="#{!node.leaf}">
> >              <t:graphicImage style="border:0px" url="#{t.nodeExpanded ?
> > '/images/tree/nav-plus.gif' : '/images/tree/nav-minus.gif' }" />
> >            <h:outputText value="#{node.uri}"/>
> >          </h:panelGroup>
> >        </f:facet>
> >      </t:tree2>
> >
> >
> > BTW, I will post my code to a blog soon..  I will send the link to this
> > mail list once I have time to finish it..
> >
> > Bill
> >
> >              Roger Keays
> >              <[EMAIL PROTECTED]
> >              havenue.com.au>
> To
> >              Sent by: news             [email protected]
> >              <[EMAIL PROTECTED]
> cc
> >              rg>
> >
> Subject
> >                                        Re: ajax4jsf + tree2?
> >              09/21/2006 07:46
> >              PM
> >
> >
> >              Please respond to
> >                  "MyFaces
> >                 Discussion"
> >              <[EMAIL PROTECTED]
> >                  ache.org>
> >
> >
> >
> >
> >
> >
> > Roger Keays wrote:
> > > Hi Bill,
> > >
> > >> I had no problem with it, what kind of tree behavior are you looking
> > for?
> > >> lazy loading? ajax expend-collapse? clickable treenode that does ajax
> > >> request? etc
> > >
> > > I'm looking for AJAX expand-collapse when the +/- icon is clicked. It
> > > would be okay if the entire tree was refreshed, just not the entire
> page!
> >
> > Okay, so the trick is to use showNav="false" and make your own
> > navigation togglers with an a4j:commandLink. It works, but it is
> > difficult to make the new links look just like the originals. I gave it
> > a shot (see below), but it still looks pretty ugly.
> >
> > Perhaps a better solution would be a new tree2 attribute called
> > 'a4jToggle', which when set to true puts in the magic a4j javascript
> > (not sure exactly what that looks like) instead of the standard js.
> >
> >
> >      <t:tree2 value="#{dao.treeModel}" id="tree" var="node"
> >               showNav="false" clientSideToggle="false"
> >               varNodeToggler="t">
> >
> >        <f:facet name="content">
> >          <h:panelGroup>
> >            <a4j:commandLink action="#{t.toggleExpanded}" reRender="tree"
> >                             rendered="#{!node.leaf}">
> >              <h:graphicImage
> >
> 
value="/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11588409/tree2.HtmlTreeRenderer/images/nav-#{t.nodeExpanded
>
> >
> > ? 'minus' : 'plus'}-line-middle.gif"
> >                              style="border: 0px;"/>
> >            </a4j:commandLink>
> >            <h:graphicImage
> >
> 
value="/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11588409/tree2.HtmlTreeRenderer/images/line-middle.gif"
>
> >
> >                            rendered="#{node.leaf}" style="border: 0px;"/>
> >            <h:outputText value="#{node.uri}"/>
> >          </h:panelGroup>
> >        </f:facet>
> >      </t:tree2>
> >
> >
> > >
> > > One other thing though.. I see lots of references to AJAX lazy loading.
> > > What is that supposed to mean? AFAICT tree2 supports lazy loading out
> of
> > > the box, and it has nothing to do with AJAX. Just set
> > > clientSideToggle="false".
> > >
> > > Cheers,
> > >
> > > Roger
> > >
> > >>
> > >> Hi there,
> > >>
> > >> Does anybody have experience integrating ajax4jsf with MyFaces' tree2
> > >> component? I can't see anything in ajax4jsf that will work out of the
> > >> box (a4j:support, a4j:region and a4j:form don't do the trick).
> > >>
> > >> Cheers,
> > >>
> > >> Roger
> > >
> > >
> >
> >
> > --
> > ----------------------------------------
> > Ninth Avenue Software
> > p: +61 7 3137 1351 (UTC +10)
> > f: +61 7 3102 9141
> > w: http://www.ninthavenue.com.au
> > e: [EMAIL PROTECTED]
> > ----------------------------------------
> >
> >
> > Disclaimer: This electronic mail and any attachments are confidential and
> may be privileged. If you are not the intended recipient, please notify the
> sender immediately by replying to this email, and destroy all copies of
> this email and any attachments. Thank you.
> >
> >
>
> Disclaimer: This electronic mail and any attachments are confidential and may 
be privileged. If you are not the intended recipient, please notify the sender 
immediately by replying to this email, and destroy all copies of this email and 
any attachments. Thank you.
>
>

Reply via email to