You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Travis Reeder <tr...@gmail.com> on 2006/04/07 02:04:56 UTC

Just committed an Ajax Listener component

Basicallys lets a component listen for events on another component, all via
ajax.

Sample usage on inputAjax.jsp.

     <s:outputText value="#{inputAjaxBean.waitingText2}">
        <s:listener on="formText2"/>
    </s:outputText>

Only works with the sandbox OutputText right now, but after I get some
feedback and discussion on it, I figure it would be nice to have across the
board.  It's a bit more functional than the ADF partial triggers because it
*will* be able to support different event types (onChange currently) and
different actions (update currently, but will could support other actions
including calling an arbitrary javascript).

Any feedback appreciated.  And thoughts about applying this to all MyFaces
components?

Travis

Re: Just committed an Ajax Listener component

Posted by Travis Reeder <tr...@gmail.com>.
Sorry, I should have been more descriptive here, it's not based on onchange
events on the component, it's based on what's returned in an ajax response.


So for example, if formText2 gets submitted either automagically using the
InputTextAjax or with a form using the CommandButtonAjax, the xml response
contains which elements were updated on the server side.  So it will include
formText2 as an updated element.  The client side response handling
mechanism checks for listeners and sends an update request for those
components which returns the current value for the components.  For
instance, if i put a listener on formText2 onto my outputText, <s:listener
on="formText2"/>, then the outputText will request an update from the server
when formText2 has a successful update response from the server.

Travis

On 4/6/06, Adam Winer <aw...@gmail.com> wrote:
>
> The ADF Faces partial trigger code is basically server-side event
> triggered:
> "in response to any server-side event on component 'foo', please
> re-render me too".
>
> This isn't especially fine-grained, but in practice it rarely needs to be,
> and in the event of such needs, there are programmatic APIs.
>
> This seems (though I haven't seen any more than what Travis has said here)
> client-side: in response to an "onchange" JS event from a particular,
> repaint me.
> Rather different...   The way we'd do that in ADF Faces is make formText2
> "autoSubmit" - so you get a partial request any time formText2 changes -
> and
> then have partialTriggers on the output component point at
> formText2.  This
> way, it's processed in strictly JSF terms, w/o lots of DOM assumptions or
> JS handling.  (E.g., how do you know that all input components are
> actually
> going to have one DOM element that delivers an onchange event?  Whereas
> you do know that all EditableValueHolders will deliver ValueChangeEvents.)
>
> -- Adam
>
>
> On 4/6/06, Martin Marinschek <ma...@gmail.com> wrote:
> > What I remember, the ADF-Faces partials allow an m:n relationship
> > between triggers and updated components/regions.
> >
> > Is that the same here?
> >
> > regards,
> >
> > Martin
> >
> > On 4/7/06, Travis Reeder <tr...@gmail.com> wrote:
> > > Basicallys lets a component listen for events on another component,
> all via
> > > ajax.
> > >
> > > Sample usage on inputAjax.jsp.
> > >
> > >      <s:outputText value="#{inputAjaxBean.waitingText2}">
> > >         <s:listener on="formText2"/>
> > >     </s:outputText>
> > >
> > > Only works with the sandbox OutputText right now, but after I get some
> > > feedback and discussion on it, I figure it would be nice to have
> across the
> > > board.  It's a bit more functional than the ADF partial triggers
> because it
> > > *will* be able to support different event types (onChange currently)
> and
> > > different actions (update currently, but will could support other
> actions
> > > including calling an arbitrary javascript).
> > >
> > > Any feedback appreciated.  And thoughts about applying this to all
> MyFaces
> > > components?
> > >
> > > Travis
> > >
> > >
> >
> >
> > --
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
>

Re: Just committed an Ajax Listener component

Posted by Adam Winer <aw...@gmail.com>.
The ADF Faces partial trigger code is basically server-side event triggered:
"in response to any server-side event on component 'foo', please
re-render me too".

This isn't especially fine-grained, but in practice it rarely needs to be,
and in the event of such needs, there are programmatic APIs.

This seems (though I haven't seen any more than what Travis has said here)
client-side: in response to an "onchange" JS event from a particular,
repaint me.
Rather different...   The way we'd do that in ADF Faces is make formText2
"autoSubmit" - so you get a partial request any time formText2 changes - and
then have partialTriggers on the output component point at formText2.  This
way, it's processed in strictly JSF terms, w/o lots of DOM assumptions or
JS handling.  (E.g., how do you know that all input components are actually
going to have one DOM element that delivers an onchange event?  Whereas
you do know that all EditableValueHolders will deliver ValueChangeEvents.)

-- Adam


On 4/6/06, Martin Marinschek <ma...@gmail.com> wrote:
> What I remember, the ADF-Faces partials allow an m:n relationship
> between triggers and updated components/regions.
>
> Is that the same here?
>
> regards,
>
> Martin
>
> On 4/7/06, Travis Reeder <tr...@gmail.com> wrote:
> > Basicallys lets a component listen for events on another component, all via
> > ajax.
> >
> > Sample usage on inputAjax.jsp.
> >
> >      <s:outputText value="#{inputAjaxBean.waitingText2}">
> >         <s:listener on="formText2"/>
> >     </s:outputText>
> >
> > Only works with the sandbox OutputText right now, but after I get some
> > feedback and discussion on it, I figure it would be nice to have across the
> > board.  It's a bit more functional than the ADF partial triggers because it
> > *will* be able to support different event types (onChange currently) and
> > different actions (update currently, but will could support other actions
> > including calling an arbitrary javascript).
> >
> > Any feedback appreciated.  And thoughts about applying this to all MyFaces
> > components?
> >
> > Travis
> >
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>

Re: Just committed an Ajax Listener component

Posted by Martin Marinschek <ma...@gmail.com>.
What I remember, the ADF-Faces partials allow an m:n relationship
between triggers and updated components/regions.

Is that the same here?

regards,

Martin

On 4/7/06, Travis Reeder <tr...@gmail.com> wrote:
> Basicallys lets a component listen for events on another component, all via
> ajax.
>
> Sample usage on inputAjax.jsp.
>
>      <s:outputText value="#{inputAjaxBean.waitingText2}">
>         <s:listener on="formText2"/>
>     </s:outputText>
>
> Only works with the sandbox OutputText right now, but after I get some
> feedback and discussion on it, I figure it would be nice to have across the
> board.  It's a bit more functional than the ADF partial triggers because it
> *will* be able to support different event types (onChange currently) and
> different actions (update currently, but will could support other actions
> including calling an arbitrary javascript).
>
> Any feedback appreciated.  And thoughts about applying this to all MyFaces
> components?
>
> Travis
>
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces