You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Cosma Colanicchia <co...@gmail.com> on 2006/05/19 10:58:01 UTC

Popup windows without breaking JSF

I was thinking about a solution for the popup window problem in JSF..
someone has suggested to use a simple javascript, but any user action
on the caller page that hasn't be submitted isn't notified to the
backing beans, and validations are not executed.. in my case, the
current row of a dataTable isn't update with the clicked one. So I got
an idea, I'm sharing it to know if it is praticable.

The solution should be a new UICommand component, let's name it
<s:commandPopupWindow>. When activated, the enclosing form is
submitted as usual to itself (with validation executed if immediate is
false, and all standard behaviours triggered with a normal commandLink
or commandButton). But in the resulting page a javascript function is
attached and automatically called in the onLoad body event handler,
that opens the popupWindow.

The tag should supports child <f:param> components to define
parameters to be passed to the child window.. this could be done
rendering an additional form on the resulting page with an hidden
field for each <f:param> nested element, and having the javascript
function submit that hidden form in the child window's target.

What do you think about a solution of this type? I don't have any
experience in writing JSF components, do you see any problem with
implementing this behaviour?

Cosma

Re: Popup windows without breaking JSF

Posted by Chrisi <ne...@googlemail.com>.
Hi Cosma,

check out the 'How do I...' section of core JSF.
There is a section about popups and JSF.

You find it at amazon as reading example Chapter 12:
(see chapter 'How do I generate a popup window?' page 28 inside the pdf).
Amzon-Link:
httpa://www.amazon.com/gp/product/0131463055/102-0590514-9574546?n=283155

Hope this helps ..
Greetings
Chrisi

On 5/19/06, Cosma Colanicchia <co...@gmail.com> wrote:
> Mhh.. I'm still a bit confused about the server and client side
> saving.. what is the "state" we are talking about? Is the tree of the
> components used in the jsp page?
>
>
>
> 2006/5/19, Andrew Robinson <an...@gmail.com>:
> > FYI - if you go with multiple windows, make sure you use client side
> > state. I don't think MyFaces yet supports server side state with
> > multiple client windows for one Servlet session.
> >
> > -Andrew
> >
> > On 5/19/06, Cosma Colanicchia <co...@gmail.com> wrote:
> > > I know, and alredy considered jenia4faces, but my requirement is to
> > > open a new browser window.. so I was trying a way to minimize problems
> > > in JSF.
> > >
> > > Thanks anyway for your interest
> > > Cosma
> > >
> > >
> > > 2006/5/19, Werner Punz <we...@gmx.at>:
> > > > Cosma Colanicchia schrieb:
> > > > > Maybe I just didn't understand it very well, but I need to open a new
> > > > > *browser* window, while this component seems to open an "in-page"
> > > > > popup, like the t:popUp one..
> > > > >
> > > > >
> > > > Yes, the popup is in browser, it is way less problematic that way.
> > > > If you really have to open a new browser window, then the notifier is
> > > > not the preferred choice.
> > > >
> > > > (another alternative to having an in browser popup is the way more
> > > > advanced jenia4faces popup)
> > > >
> > > > have in mind that you open a huge can of worms with a popup window.
> > > >
> > > >
> > >
> >
>

Re: Popup windows without breaking JSF

Posted by Cosma Colanicchia <co...@gmail.com>.
Mhh.. I'm still a bit confused about the server and client side
saving.. what is the "state" we are talking about? Is the tree of the
components used in the jsp page?



2006/5/19, Andrew Robinson <an...@gmail.com>:
> FYI - if you go with multiple windows, make sure you use client side
> state. I don't think MyFaces yet supports server side state with
> multiple client windows for one Servlet session.
>
> -Andrew
>
> On 5/19/06, Cosma Colanicchia <co...@gmail.com> wrote:
> > I know, and alredy considered jenia4faces, but my requirement is to
> > open a new browser window.. so I was trying a way to minimize problems
> > in JSF.
> >
> > Thanks anyway for your interest
> > Cosma
> >
> >
> > 2006/5/19, Werner Punz <we...@gmx.at>:
> > > Cosma Colanicchia schrieb:
> > > > Maybe I just didn't understand it very well, but I need to open a new
> > > > *browser* window, while this component seems to open an "in-page"
> > > > popup, like the t:popUp one..
> > > >
> > > >
> > > Yes, the popup is in browser, it is way less problematic that way.
> > > If you really have to open a new browser window, then the notifier is
> > > not the preferred choice.
> > >
> > > (another alternative to having an in browser popup is the way more
> > > advanced jenia4faces popup)
> > >
> > > have in mind that you open a huge can of worms with a popup window.
> > >
> > >
> >
>

Re: Popup windows without breaking JSF

Posted by Andrew Robinson <an...@gmail.com>.
FYI - if you go with multiple windows, make sure you use client side
state. I don't think MyFaces yet supports server side state with
multiple client windows for one Servlet session.

-Andrew

On 5/19/06, Cosma Colanicchia <co...@gmail.com> wrote:
> I know, and alredy considered jenia4faces, but my requirement is to
> open a new browser window.. so I was trying a way to minimize problems
> in JSF.
>
> Thanks anyway for your interest
> Cosma
>
>
> 2006/5/19, Werner Punz <we...@gmx.at>:
> > Cosma Colanicchia schrieb:
> > > Maybe I just didn't understand it very well, but I need to open a new
> > > *browser* window, while this component seems to open an "in-page"
> > > popup, like the t:popUp one..
> > >
> > >
> > Yes, the popup is in browser, it is way less problematic that way.
> > If you really have to open a new browser window, then the notifier is
> > not the preferred choice.
> >
> > (another alternative to having an in browser popup is the way more
> > advanced jenia4faces popup)
> >
> > have in mind that you open a huge can of worms with a popup window.
> >
> >
>

Re: Popup windows without breaking JSF

Posted by Cosma Colanicchia <co...@gmail.com>.
I know, and alredy considered jenia4faces, but my requirement is to
open a new browser window.. so I was trying a way to minimize problems
in JSF.

Thanks anyway for your interest
Cosma


2006/5/19, Werner Punz <we...@gmx.at>:
> Cosma Colanicchia schrieb:
> > Maybe I just didn't understand it very well, but I need to open a new
> > *browser* window, while this component seems to open an "in-page"
> > popup, like the t:popUp one..
> >
> >
> Yes, the popup is in browser, it is way less problematic that way.
> If you really have to open a new browser window, then the notifier is
> not the preferred choice.
>
> (another alternative to having an in browser popup is the way more
> advanced jenia4faces popup)
>
> have in mind that you open a huge can of worms with a popup window.
>
>

Re: Popup windows without breaking JSF

Posted by Werner Punz <we...@gmx.at>.
Cosma Colanicchia schrieb:
> Maybe I just didn't understand it very well, but I need to open a new
> *browser* window, while this component seems to open an "in-page"
> popup, like the t:popUp one..
> 
> 
Yes, the popup is in browser, it is way less problematic that way.
If you really have to open a new browser window, then the notifier is
not the preferred choice.

(another alternative to having an in browser popup is the way more
advanced jenia4faces popup)

have in mind that you open a huge can of worms with a popup window.


Re: Popup windows without breaking JSF

Posted by Cosma Colanicchia <co...@gmail.com>.
Maybe I just didn't understand it very well, but I need to open a new
*browser* window, while this component seems to open an "in-page"
popup, like the t:popUp one..


2006/5/19, Werner Punz <we...@gmx.at>:
> Cosma Colanicchia schrieb:
> > Is there any documentation available? I can't find any reference of it
> > in the myfaces web site...
> >
> Not yet, since this is an alpha stage quality component, the best thing
> is to check the example which is there already...
> (a demo can be found in the sandbox examples under timedNotifier.jsf)
>
>
> it is rather simple you have a notifier tag with a start and endtime
> attribute, a zero at the start should the notifier immediately an
> endtime of zero should keep it open afair (take it with a grain of salt,
> if it does not work out set it to a really high milisecond value.
>
> if you want to fill it with content other than a normal text, you have a
> facet subtag für the content, there you can set buttons, input fields
> etc..., you have to apply some javascript for closing or hiding the
> dialog system if you want to avoid page refreshes, if you can live with
> a page refresh then simply apply standard jsf mechanisms like a command
> link.
>
> For the javascript handler, I will dig it up and post the info later
> today. (You have to use some dojo code there, but I have to dig up the
> code which I cannot do now)
>
>
> As for the references, you can find the thing in the myfaces sandbox,
> and the demo is in the sandbox examples. I will commit an example with a
> javascript hook and a facet this weekend, this is a common usecase which
> I have not covered yet in the examples.
>
>

Re: Popup windows without breaking JSF

Posted by Werner Punz <we...@gmx.at>.
Ok you can hide the dialog again on the javascript side if you set a
javascript with the exact id of the dialog container being something
like dialogId

and

dialogId.hideDialog();

the variable itself already should be set at that time due to the reason
that the dialog system itself sets a variable with the id name and
references the dialog that way.


Sorry for the missing docs, but expect an improvement in this area on
the dojo based components soon, the reason for the half finished stage
was, that I was bound by other projects 110% of the time, so some things
in the dojo area are still missing.

The important thing is, if you want to use it, get the sandbox, check
out the examples and toy with it.


Re: Popup windows without breaking JSF

Posted by Werner Punz <we...@gmx.at>.
Cosma Colanicchia schrieb:
> Is there any documentation available? I can't find any reference of it
> in the myfaces web site...
> 
Not yet, since this is an alpha stage quality component, the best thing
is to check the example which is there already...
(a demo can be found in the sandbox examples under timedNotifier.jsf)


it is rather simple you have a notifier tag with a start and endtime
attribute, a zero at the start should the notifier immediately an
endtime of zero should keep it open afair (take it with a grain of salt,
if it does not work out set it to a really high milisecond value.

if you want to fill it with content other than a normal text, you have a
facet subtag für the content, there you can set buttons, input fields
etc..., you have to apply some javascript for closing or hiding the
dialog system if you want to avoid page refreshes, if you can live with
a page refresh then simply apply standard jsf mechanisms like a command
link.

For the javascript handler, I will dig it up and post the info later
today. (You have to use some dojo code there, but I have to dig up the
code which I cannot do now)


As for the references, you can find the thing in the myfaces sandbox,
and the demo is in the sandbox examples. I will commit an example with a
javascript hook and a facet this weekend, this is a common usecase which
I have not covered yet in the examples.


Re: Popup windows without breaking JSF

Posted by Cosma Colanicchia <co...@gmail.com>.
Is there any documentation available? I can't find any reference of it
in the myfaces web site...

Tnx
Cosma



2006/5/19, Werner Punz <we...@gmx.at>:
> Cosma Colanicchia schrieb:
> > I was thinking about a solution for the popup window problem in JSF..
> > someone has suggested to use a simple javascript, but any user action
> > on the caller page that hasn't be submitted isn't notified to the
> > backing beans, and validations are not executed.. in my case, the
> > current row of a dataTable isn't update with the clicked one. So I got
> > an idea, I'm sharing it to know if it is praticable.
> >
> > The solution should be a new UICommand component, let's name it
> > <s:commandPopupWindow>. When activated, the enclosing form is
> > submitted as usual to itself (with validation executed if immediate is
> > false, and all standard behaviours triggered with a normal commandLink
> > or commandButton). But in the resulting page a javascript function is
> > attached and automatically called in the onLoad body event handler,
> > that opens the popupWindow.
> >
> > The tag should supports child <f:param> components to define
> > parameters to be passed to the child window.. this could be done
> > rendering an additional form on the resulting page with an hidden
> > field for each <f:param> nested element, and having the javascript
> > function submit that hidden form in the child window's target.
> >
> > What do you think about a solution of this type? I don't have any
> > experience in writing JSF components, do you see any problem with
> > implementing this behaviour?
> >
> You can use also the timed notifier sandbox component...
> together with the rendered attribute ;-)
>
>

Re: Popup windows without breaking JSF

Posted by Cosma Colanicchia <co...@gmail.com>.
Thank you Chrisi and Matthias.

I looked at the ADF solution and it seems pretty clean, I'll check if
I can use it in a myfaces project



2006/5/21, Matthias Wessendorf <ma...@apache.org>:
> Cosma-
>
> you can also have a look at ADF Faces dialog system.
> Go ahead to the ADF Faces user list here at Apache.
>
> -Matthias
>
> On 5/19/06, Werner Punz <we...@gmx.at> wrote:
> > Cosma Colanicchia schrieb:
> > > I was thinking about a solution for the popup window problem in JSF..
> > > someone has suggested to use a simple javascript, but any user action
> > > on the caller page that hasn't be submitted isn't notified to the
> > > backing beans, and validations are not executed.. in my case, the
> > > current row of a dataTable isn't update with the clicked one. So I got
> > > an idea, I'm sharing it to know if it is praticable.
> > >
> > > The solution should be a new UICommand component, let's name it
> > > <s:commandPopupWindow>. When activated, the enclosing form is
> > > submitted as usual to itself (with validation executed if immediate is
> > > false, and all standard behaviours triggered with a normal commandLink
> > > or commandButton). But in the resulting page a javascript function is
> > > attached and automatically called in the onLoad body event handler,
> > > that opens the popupWindow.
> > >
> > > The tag should supports child <f:param> components to define
> > > parameters to be passed to the child window.. this could be done
> > > rendering an additional form on the resulting page with an hidden
> > > field for each <f:param> nested element, and having the javascript
> > > function submit that hidden form in the child window's target.
> > >
> > > What do you think about a solution of this type? I don't have any
> > > experience in writing JSF components, do you see any problem with
> > > implementing this behaviour?
> > >
> > You can use also the timed notifier sandbox component...
> > together with the rendered attribute ;-)
> >
> >
>
>
> --
> Matthias Wessendorf
> Aechterhoek 18
> 48282 Emsdetten
> http://jroller.com/page/mwessendorf
> mwessendorf-at-gmail-dot-com
>

Re: Popup windows without breaking JSF

Posted by Matthias Wessendorf <ma...@apache.org>.
Cosma-

you can also have a look at ADF Faces dialog system.
Go ahead to the ADF Faces user list here at Apache.

-Matthias

On 5/19/06, Werner Punz <we...@gmx.at> wrote:
> Cosma Colanicchia schrieb:
> > I was thinking about a solution for the popup window problem in JSF..
> > someone has suggested to use a simple javascript, but any user action
> > on the caller page that hasn't be submitted isn't notified to the
> > backing beans, and validations are not executed.. in my case, the
> > current row of a dataTable isn't update with the clicked one. So I got
> > an idea, I'm sharing it to know if it is praticable.
> >
> > The solution should be a new UICommand component, let's name it
> > <s:commandPopupWindow>. When activated, the enclosing form is
> > submitted as usual to itself (with validation executed if immediate is
> > false, and all standard behaviours triggered with a normal commandLink
> > or commandButton). But in the resulting page a javascript function is
> > attached and automatically called in the onLoad body event handler,
> > that opens the popupWindow.
> >
> > The tag should supports child <f:param> components to define
> > parameters to be passed to the child window.. this could be done
> > rendering an additional form on the resulting page with an hidden
> > field for each <f:param> nested element, and having the javascript
> > function submit that hidden form in the child window's target.
> >
> > What do you think about a solution of this type? I don't have any
> > experience in writing JSF components, do you see any problem with
> > implementing this behaviour?
> >
> You can use also the timed notifier sandbox component...
> together with the rendered attribute ;-)
>
>


-- 
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
http://jroller.com/page/mwessendorf
mwessendorf-at-gmail-dot-com

Re: Popup windows without breaking JSF

Posted by Werner Punz <we...@gmx.at>.
Cosma Colanicchia schrieb:
> I was thinking about a solution for the popup window problem in JSF..
> someone has suggested to use a simple javascript, but any user action
> on the caller page that hasn't be submitted isn't notified to the
> backing beans, and validations are not executed.. in my case, the
> current row of a dataTable isn't update with the clicked one. So I got
> an idea, I'm sharing it to know if it is praticable.
> 
> The solution should be a new UICommand component, let's name it
> <s:commandPopupWindow>. When activated, the enclosing form is
> submitted as usual to itself (with validation executed if immediate is
> false, and all standard behaviours triggered with a normal commandLink
> or commandButton). But in the resulting page a javascript function is
> attached and automatically called in the onLoad body event handler,
> that opens the popupWindow.
> 
> The tag should supports child <f:param> components to define
> parameters to be passed to the child window.. this could be done
> rendering an additional form on the resulting page with an hidden
> field for each <f:param> nested element, and having the javascript
> function submit that hidden form in the child window's target.
> 
> What do you think about a solution of this type? I don't have any
> experience in writing JSF components, do you see any problem with
> implementing this behaviour?
> 
You can use also the timed notifier sandbox component...
together with the rendered attribute ;-)