You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-dev@incubator.apache.org by Anthony Yulo <An...@headstrong.com> on 2006/10/26 08:10:33 UTC

RE: JavaScript and Dialog Framework

Hi I have successfully launched a dialog from a javascript.  I can get the
correct FacesContext objects.  Problem now is how do I setup a
returnListener for the Dialog.  The Dialog is launched during an onblur
event of an InputText.  So I'm planning to extend the CoreInputText
component and implement it as a DialogSource. Do you have any suggestion on
where can I start doing this? What are the steps needed?



-----Original Message-----
From: Anthony Yulo 
Sent: Thursday, October 05, 2006 11:08 PM
To: 'adffaces-dev@incubator.apache.org'
Subject: RE: DWR and ADF Faces

Yes, I know, if only the component was an ActionSource, then things would be
a little bit easy. 

-----Original Message-----
From: Simon Lessard [mailto:simon.lessard.3@gmail.com] 
Sent: Thursday, October 05, 2006 11:03 PM
To: adffaces-dev@incubator.apache.org
Subject: Re: DWR and ADF Faces

Actually that will work only if your component launching the dialog isan
ActionSource, as I mentioned in my first replies.

On 10/5/06, Simon Lessard <si...@gmail.com> wrote:
>
> On a side note, I didn't check at all if it's doable, but you could check
> how a commandButton opening a dialog looks like (the javascript enerated
> mainly) and add that code to your onmouseover event. That way you would
use
> the PPR framework instead of DWR, and if it works, all technical
> difficulties I was mentioning in the previous post would not apply.
>
> Regards,
>
> ~ Simon
>
> On 10/5/06, Simon Lessard <si...@gmail.com> wrote:
> >
> > If it works, the result will be consistent in any environment.
> >
> > What I'm unsure about is the feasibility in a short time in an easy way.
> > Let me enumerate the technical difficulties I see, maybe they willappear
> > trivial to you:
> >
> > 1. Get a FacesContext instance. Fix: Change DWRServlet code a bit to
> > instanciate the FacesContext. Main difficulty: I don't know if
> > FacesContextFactory will like the XMLRequest format of AJAX, it's
possible
> > that it don't whine at all though. If that's the case, this point is not
a
> > real issue.
> > 2. Get a RequestContext instance. Fix: Add AdfFilter to DWRServlet. Main
> > difficulty: None connected directly to this point.
> > 3. Use the dialog feature of RequestContext. Difficulty: None
> > 4. Open the dialog, e.g. how do you manage the callback method?
> > Difficulty: Dialog is based on some internal Trinidad JS and PPR code
that
> > will call a window.open instead refreshing the page. With DWR you'll
> > most likely need to do that yourself, but I'm not perfectly sure on that
> > point. I know the dialog framework, but I'm not a guru.
> > 5. Managing return event. Fix: I have no clue, it might works like
> > magic, but I never used dialog framework that way.
> >
> > If you try it an it works, I would be glad to hear it though.
> >
> >
> > Regards,
> >
> > ~ Simon
> >
> > On 10/5/06, Anthony Yulo < Anthony.Yulo@headstrong.com> wrote:
> > >
> > > Im planning to do this on a production environment.  Nightmarish? So
> > > you're
> > > saying that this is not adviseable to implement this on a production
> > > environment? What do you mean nightmarish? The results will not be
> > > consistent?
> > >
> > > -----Original Message-----
> > > From: Simon Lessard [mailto: simon.lessard.3@gmail.com]
> > > Sent: Thursday, October 05, 2006 10:29 PM
> > > To: adffaces-dev@incubator.apache.org
> > > Subject: Re: DWR and ADF Faces
> > >
> > > Using DWR to do that will be nightmarish I think... You'll need a
> > > TrinidadContext instance as well to push the dialog...
> > >
> > > Hmmm I think this could be a nice improvement for Trinidad though, an
> > > attribute to send an action from any JavaScript event. Maybe a keyword
> > >
> > > placed in the event attributes, or new attributes altogether. All
> > > components
> > > implementing that would have to also implement
> > > ActionSource/ActionSource 2
> > > though. This is not a small change, but it would open a whole new
> > > level of
> > > functionality.
> > >
> > >
> > > Regards,
> > >
> > > ~ Simon
> > >
> > >
> > > On 10/5/06, Anthony Yulo <Anthony.Yulo@headstrong.com > wrote:
> > > >
> > > > Well I know the launchDialog function gets called so I know that the
> > > DWR
> > > > is
> > > > working and that I can all java code from the javascript.  However,
> > > the
> > > > popup window is not showing and that the browser is issuing an
> > > alertbox
> > > > with
> > > > message: "null".  And, Simon said that as long as you don't use the
> > > > FacesContext's instance, it will be fine.  But here I am using the
> > > > FacesContext.
> > > >
> > > >
> > > > Here is the actual code:
> > > >
> > > > public void launchDialog() {
> > > >
> > > >         System.out.println ("Launch Dialog called.");
> > > >           FacesContext context = FacesContext.getCurrentInstance();
> > > >
> > > >         ViewHandler viewHandler = context.getApplication
> > > > ().getViewHandler();
> > > >
> > > >         UIViewRoot dialog = viewHandler.createView(context,
> > > > "/pages/iv/dialogPage.jsp");
> > > >
> > > >
> > > >         HashMap properties = new HashMap();
> > > >             properties.put("width", new Integer(250));
> > > >             properties.put("height", new Integer(150));
> > > >
> > > >
> > > >
> > > > AdfFacesContext.getCurrentInstance
> > > > ().launchDialog(dialog,properties,null,tru
> > > > e,properties);
> > > >         System.out.println("after launch" + componentId);
> > > >
> > > >
> > > > }
> > > >
> > > > -----Original Message-----
> > > > From: mwessendorf@gmail.com [mailto: mwessendorf@gmail.com] On
> > > Behalf Of
> > > > Matthias Wessendorf
> > > > Sent: Thursday, October 05, 2006 10:08 PM
> > > > To: adffaces-dev@incubator.apache.org
> > > > Subject: Re: DWR and ADF Faces
> > > >
> > > > what was the result of that?
> > > >
> > > > or haven't you tried?
> > > >
> > > >
> > > >
> > > > On 10/5/06, Anthony Yulo < Anthony.Yulo@headstrong.com> wrote:
> > > > > Actually what I want is to launch a dialog when the onfocus()
> > > event
> > > > fires.
> > > > >
> > > > > I am getting the FacesContext Instance on the method that is
> > > called by
> > > > the
> > > > > javascript so that will pose a problem?
> > > > >
> > > > >
> > > > > <af:inputText ...  onfocus=FocusFunction() />
> > > > > ...
> > > > > ...
> > > > > ...
> > > > >
> > > > > //
> > > > > function FocusFunction() {
> > > > >
> > > > >    BackingBean.launchDialog();
> > > > > }
> > > > >
> > > > > ...
> > > > > ...
> > > > > ...
> > > > > public void launchDialog() {
> > > > >    FacesContext context = FacesContext.getCurrentInstance();
> > > > >     ...
> > > > >     ...
> > > > >     ...
> > > > >
> > > > > }
> > > > >
> > > > > -----Original Message-----
> > > > > From: Simon Lessard [mailto:simon.lessard.3@gmail.com]
> > > > > Sent: Thursday, October 05, 2006 9:41 PM
> > > > > To: adffaces-dev@incubator.apache.org
> > > > > Subject: Re: DWR and ADF Faces
> > > > >
> > > > > I did not try it, but I don't see any reason why it would not work
> > > > though,
> > > > > as long as you don't need a FacesContext instance in your DWR
> > > method. If
> > > > you
> > > > > do, it might get hellish.
> > > > >
> > > > >
> > > > > Regards,
> > > > >
> > > > > ~ Simon
> > > > >
> > > > > On 10/5/06, Anthony Yulo < Anthony.Yulo@headstrong.com> wrote:
> > > > > >
> > > > > > Has anyone tried to integrate DWR with ADF Faces?
> > > > > >
> > > > > > *************The information transmitted is intended only for
> > > the
> > > > person
> > > > > > or
> > > > > > entity to which it is addressed and may contain confidential
> > > and/or
> > > > > > privileged material. Any review,retransmission,dissemination or
> > > other
> > > > use
> > > > > > of, or taking of any action in reliance upon, this information
> > > by
> > > > persons
> > > > > > or
> > > > > > entities other than the intended recipient is prohibited. If you
> > > > received
> > > > > > this in error, please contact the sender and delete the material
> > > from
> > > > any
> > > > > > computer.*********************
> > > > > >
> > > > > >
> > > > > *************The information transmitted is intended only for the
> > > person
> > > > or
> > > > > entity to which it is addressed and may contain confidential
> > > and/or
> > > > > privileged material. Any review,retransmission,dissemination or
> > > other
> > > > use
> > > > > of, or taking of any action in reliance upon, this information by
> > > > persons
> > > > or
> > > > > entities other than the intended recipient is prohibited. If you
> > > > received
> > > > > this in error, please contact the sender and delete the material
> > > from
> > > > any
> > > > > computer.*********************
> > > > >
> > > >
> > > >
> > > > --
> > > > Matthias Wessendorf
> > > > http://tinyurl.com/fmywh
> > > >
> > > > further stuff:
> > > > blog: http://jroller.com/page/mwessendorf
> > > > mail: mwessendorf-at-gmail-dot-com
> > > > *************The information transmitted is intended only for the
> > > person
> > > > or
> > > > entity to which it is addressed and may contain confidential and/or
> > > > privileged material. Any review,retransmission,dissemination or
> > > other use
> > > > of, or taking of any action in reliance upon, this information by
> > > persons
> > > > or
> > > > entities other than the intended recipient is prohibited. If you
> > > received
> > > > this in error, please contact the sender and delete the material
> > > from any
> > > > computer.*********************
> > > >
> > > *************The information transmitted is intended only for the
> > > person or
> > > entity to which it is addressed and may contain confidential and/or
> > > privileged material. Any review,retransmission,dissemination or other
> > > use
> > > of, or taking of any action in reliance upon, this information by
> > > persons or
> > > entities other than the intended recipient is prohibited. If you
> > > received
> > > this in error, please contact the sender and delete the material from
> > > any
> > > computer.*********************
> > >
> >
> >
>
*************The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review,retransmission,dissemination or other use
of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.*********************
*************The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review,retransmission,dissemination or other use
of, or taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from any
computer.*********************

Re: JavaScript and Dialog Framework

Posted by Adam Winer <aw...@gmail.com>.
All you need to do is:

- Override decode(), and add:

     RequestContext rc =  RequestContext.getCurrentInstance();
     ReturnEvent event = rc.getDialogService().getReturnEvent(this);
     if (event != null)
        ... handle the return event

-- Adam


On 10/26/06, Anthony Yulo <An...@headstrong.com> wrote:
>
> Hi I have successfully launched a dialog from a javascript.  I can get the
> correct FacesContext objects.  Problem now is how do I setup a
> returnListener for the Dialog.  The Dialog is launched during an onblur
> event of an InputText.  So I'm planning to extend the CoreInputText
> component and implement it as a DialogSource. Do you have any suggestion
> on
> where can I start doing this? What are the steps needed?
>
>
>
> -----Original Message-----
> From: Anthony Yulo
> Sent: Thursday, October 05, 2006 11:08 PM
> To: 'adffaces-dev@incubator.apache.org'
> Subject: RE: DWR and ADF Faces
>
> Yes, I know, if only the component was an ActionSource, then things would
> be
> a little bit easy.
>
> -----Original Message-----
> From: Simon Lessard [mailto:simon.lessard.3@gmail.com]
> Sent: Thursday, October 05, 2006 11:03 PM
> To: adffaces-dev@incubator.apache.org
> Subject: Re: DWR and ADF Faces
>
> Actually that will work only if your component launching the dialog isan
> ActionSource, as I mentioned in my first replies.
>
> On 10/5/06, Simon Lessard <si...@gmail.com> wrote:
> >
> > On a side note, I didn't check at all if it's doable, but you could
> check
> > how a commandButton opening a dialog looks like (the javascript enerated
> > mainly) and add that code to your onmouseover event. That way you would
> use
> > the PPR framework instead of DWR, and if it works, all technical
> > difficulties I was mentioning in the previous post would not apply.
> >
> > Regards,
> >
> > ~ Simon
> >
> > On 10/5/06, Simon Lessard <si...@gmail.com> wrote:
> > >
> > > If it works, the result will be consistent in any environment.
> > >
> > > What I'm unsure about is the feasibility in a short time in an easy
> way.
> > > Let me enumerate the technical difficulties I see, maybe they
> willappear
> > > trivial to you:
> > >
> > > 1. Get a FacesContext instance. Fix: Change DWRServlet code a bit to
> > > instanciate the FacesContext. Main difficulty: I don't know if
> > > FacesContextFactory will like the XMLRequest format of AJAX, it's
> possible
> > > that it don't whine at all though. If that's the case, this point is
> not
> a
> > > real issue.
> > > 2. Get a RequestContext instance. Fix: Add AdfFilter to DWRServlet.
> Main
> > > difficulty: None connected directly to this point.
> > > 3. Use the dialog feature of RequestContext. Difficulty: None
> > > 4. Open the dialog, e.g. how do you manage the callback method?
> > > Difficulty: Dialog is based on some internal Trinidad JS and PPR code
> that
> > > will call a window.open instead refreshing the page. With DWR you'll
> > > most likely need to do that yourself, but I'm not perfectly sure on
> that
> > > point. I know the dialog framework, but I'm not a guru.
> > > 5. Managing return event. Fix: I have no clue, it might works like
> > > magic, but I never used dialog framework that way.
> > >
> > > If you try it an it works, I would be glad to hear it though.
> > >
> > >
> > > Regards,
> > >
> > > ~ Simon
> > >
> > > On 10/5/06, Anthony Yulo < Anthony.Yulo@headstrong.com> wrote:
> > > >
> > > > Im planning to do this on a production environment.  Nightmarish? So
> > > > you're
> > > > saying that this is not adviseable to implement this on a production
> > > > environment? What do you mean nightmarish? The results will not be
> > > > consistent?
> > > >
> > > > -----Original Message-----
> > > > From: Simon Lessard [mailto: simon.lessard.3@gmail.com]
> > > > Sent: Thursday, October 05, 2006 10:29 PM
> > > > To: adffaces-dev@incubator.apache.org
> > > > Subject: Re: DWR and ADF Faces
> > > >
> > > > Using DWR to do that will be nightmarish I think... You'll need a
> > > > TrinidadContext instance as well to push the dialog...
> > > >
> > > > Hmmm I think this could be a nice improvement for Trinidad though,
> an
> > > > attribute to send an action from any JavaScript event. Maybe a
> keyword
> > > >
> > > > placed in the event attributes, or new attributes altogether. All
> > > > components
> > > > implementing that would have to also implement
> > > > ActionSource/ActionSource 2
> > > > though. This is not a small change, but it would open a whole new
> > > > level of
> > > > functionality.
> > > >
> > > >
> > > > Regards,
> > > >
> > > > ~ Simon
> > > >
> > > >
> > > > On 10/5/06, Anthony Yulo <Anthony.Yulo@headstrong.com > wrote:
> > > > >
> > > > > Well I know the launchDialog function gets called so I know that
> the
> > > > DWR
> > > > > is
> > > > > working and that I can all java code from the
> javascript.  However,
> > > > the
> > > > > popup window is not showing and that the browser is issuing an
> > > > alertbox
> > > > > with
> > > > > message: "null".  And, Simon said that as long as you don't use
> the
> > > > > FacesContext's instance, it will be fine.  But here I am using the
> > > > > FacesContext.
> > > > >
> > > > >
> > > > > Here is the actual code:
> > > > >
> > > > > public void launchDialog() {
> > > > >
> > > > >         System.out.println ("Launch Dialog called.");
> > > > >           FacesContext context = FacesContext.getCurrentInstance
> ();
> > > > >
> > > > >         ViewHandler viewHandler = context.getApplication
> > > > > ().getViewHandler();
> > > > >
> > > > >         UIViewRoot dialog = viewHandler.createView(context,
> > > > > "/pages/iv/dialogPage.jsp");
> > > > >
> > > > >
> > > > >         HashMap properties = new HashMap();
> > > > >             properties.put("width", new Integer(250));
> > > > >             properties.put("height", new Integer(150));
> > > > >
> > > > >
> > > > >
> > > > > AdfFacesContext.getCurrentInstance
> > > > > ().launchDialog(dialog,properties,null,tru
> > > > > e,properties);
> > > > >         System.out.println("after launch" + componentId);
> > > > >
> > > > >
> > > > > }
> > > > >
> > > > > -----Original Message-----
> > > > > From: mwessendorf@gmail.com [mailto: mwessendorf@gmail.com] On
> > > > Behalf Of
> > > > > Matthias Wessendorf
> > > > > Sent: Thursday, October 05, 2006 10:08 PM
> > > > > To: adffaces-dev@incubator.apache.org
> > > > > Subject: Re: DWR and ADF Faces
> > > > >
> > > > > what was the result of that?
> > > > >
> > > > > or haven't you tried?
> > > > >
> > > > >
> > > > >
> > > > > On 10/5/06, Anthony Yulo < Anthony.Yulo@headstrong.com> wrote:
> > > > > > Actually what I want is to launch a dialog when the onfocus()
> > > > event
> > > > > fires.
> > > > > >
> > > > > > I am getting the FacesContext Instance on the method that is
> > > > called by
> > > > > the
> > > > > > javascript so that will pose a problem?
> > > > > >
> > > > > >
> > > > > > <af:inputText ...  onfocus=FocusFunction() />
> > > > > > ...
> > > > > > ...
> > > > > > ...
> > > > > >
> > > > > > //
> > > > > > function FocusFunction() {
> > > > > >
> > > > > >    BackingBean.launchDialog();
> > > > > > }
> > > > > >
> > > > > > ...
> > > > > > ...
> > > > > > ...
> > > > > > public void launchDialog() {
> > > > > >    FacesContext context = FacesContext.getCurrentInstance();
> > > > > >     ...
> > > > > >     ...
> > > > > >     ...
> > > > > >
> > > > > > }
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: Simon Lessard [mailto:simon.lessard.3@gmail.com]
> > > > > > Sent: Thursday, October 05, 2006 9:41 PM
> > > > > > To: adffaces-dev@incubator.apache.org
> > > > > > Subject: Re: DWR and ADF Faces
> > > > > >
> > > > > > I did not try it, but I don't see any reason why it would not
> work
> > > > > though,
> > > > > > as long as you don't need a FacesContext instance in your DWR
> > > > method. If
> > > > > you
> > > > > > do, it might get hellish.
> > > > > >
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > ~ Simon
> > > > > >
> > > > > > On 10/5/06, Anthony Yulo < Anthony.Yulo@headstrong.com> wrote:
> > > > > > >
> > > > > > > Has anyone tried to integrate DWR with ADF Faces?
> > > > > > >
> > > > > > > *************The information transmitted is intended only for
> > > > the
> > > > > person
> > > > > > > or
> > > > > > > entity to which it is addressed and may contain confidential
> > > > and/or
> > > > > > > privileged material. Any review,retransmission,dissemination
> or
> > > > other
> > > > > use
> > > > > > > of, or taking of any action in reliance upon, this information
> > > > by
> > > > > persons
> > > > > > > or
> > > > > > > entities other than the intended recipient is prohibited. If
> you
> > > > > received
> > > > > > > this in error, please contact the sender and delete the
> material
> > > > from
> > > > > any
> > > > > > > computer.*********************
> > > > > > >
> > > > > > >
> > > > > > *************The information transmitted is intended only for
> the
> > > > person
> > > > > or
> > > > > > entity to which it is addressed and may contain confidential
> > > > and/or
> > > > > > privileged material. Any review,retransmission,dissemination or
> > > > other
> > > > > use
> > > > > > of, or taking of any action in reliance upon, this information
> by
> > > > > persons
> > > > > or
> > > > > > entities other than the intended recipient is prohibited. If you
> > > > > received
> > > > > > this in error, please contact the sender and delete the material
> > > > from
> > > > > any
> > > > > > computer.*********************
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Matthias Wessendorf
> > > > > http://tinyurl.com/fmywh
> > > > >
> > > > > further stuff:
> > > > > blog: http://jroller.com/page/mwessendorf
> > > > > mail: mwessendorf-at-gmail-dot-com
> > > > > *************The information transmitted is intended only for the
> > > > person
> > > > > or
> > > > > entity to which it is addressed and may contain confidential
> and/or
> > > > > privileged material. Any review,retransmission,dissemination or
> > > > other use
> > > > > of, or taking of any action in reliance upon, this information by
> > > > persons
> > > > > or
> > > > > entities other than the intended recipient is prohibited. If you
> > > > received
> > > > > this in error, please contact the sender and delete the material
> > > > from any
> > > > > computer.*********************
> > > > >
> > > > *************The information transmitted is intended only for the
> > > > person or
> > > > entity to which it is addressed and may contain confidential and/or
> > > > privileged material. Any review,retransmission,dissemination or
> other
> > > > use
> > > > of, or taking of any action in reliance upon, this information by
> > > > persons or
> > > > entities other than the intended recipient is prohibited. If you
> > > > received
> > > > this in error, please contact the sender and delete the material
> from
> > > > any
> > > > computer.*********************
> > > >
> > >
> > >
> >
> *************The information transmitted is intended only for the person
> or
> entity to which it is addressed and may contain confidential and/or
> privileged material. Any review,retransmission,dissemination or other use
> of, or taking of any action in reliance upon, this information by persons
> or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from any
> computer.*********************
> *************The information transmitted is intended only for the person
> or
> entity to which it is addressed and may contain confidential and/or
> privileged material. Any review,retransmission,dissemination or other use
> of, or taking of any action in reliance upon, this information by persons
> or
> entities other than the intended recipient is prohibited. If you received
> this in error, please contact the sender and delete the material from any
> computer.*********************
>