You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ernesto Reinaldo Barreiro <re...@gmail.com> on 2010/11/23 16:16:45 UTC

opening ModalWindow on page load

Hi,

In one of the application we working at right now we have the
requirement that the user should fill in some extra information before
he/she is allowed to work with some pages. We wanted to do this with a
modal window blocking the page till this information is provided. So,
the requirement is:

-Modal window should be opened immediately after a page is load.

After a bit of messing around/googling we came up with this class, who
seems to be doing the job:-)

public class OpenOnLoadModalWindow extends ModalWindow implements
IHeaderContributor {

	private static final long serialVersionUID = 1L;

	/**
	 * @param id
	 */
	public OpenOnLoadModalWindow(String id) {
		super(id);
	}

	/**
	 * @param id
	 * @param model
	 */
	public OpenOnLoadModalWindow(String id, IModel<?> model) {
		super(id, model);
	}
	
	/**
	 * Adds the JavaScript to initially open modal window.
	 */
	public void renderHead(IHeaderResponse response)
	{
		response.renderOnDomReadyJavascript(getWindowOpenJavascript());
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#makeContentVisible()
	 */
	@Override
	protected boolean makeContentVisible()
	{
		return true;
	}
}

Would this class, or one derived form this one, or a better solution
if one is known:), be included on the framework. Or this is just a
topic for wiki page?

Regards,

Ernesto

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: opening ModalWindow on page load

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Done. Added the class to:

https://cwiki.apache.org/confluence/display/WICKET/Modal+Windows


Regards,

Ernesto

On Tue, Nov 23, 2010 at 4:24 PM, Martin Grigorov <mg...@apache.org> wrote:
> Wiki page is OK for now.
> 1) it is easy to create if needed
> 2) I don't remember such request in the mailing lists for the last 2 years,
> so it is not something everyone needs
>
> My 2c.
>
> On Tue, Nov 23, 2010 at 4:16 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
>> Hi,
>>
>> In one of the application we working at right now we have the
>> requirement that the user should fill in some extra information before
>> he/she is allowed to work with some pages. We wanted to do this with a
>> modal window blocking the page till this information is provided. So,
>> the requirement is:
>>
>> -Modal window should be opened immediately after a page is load.
>>
>> After a bit of messing around/googling we came up with this class, who
>> seems to be doing the job:-)
>>
>> public class OpenOnLoadModalWindow extends ModalWindow implements
>> IHeaderContributor {
>>
>>        private static final long serialVersionUID = 1L;
>>
>>        /**
>>         * @param id
>>         */
>>        public OpenOnLoadModalWindow(String id) {
>>                super(id);
>>        }
>>
>>        /**
>>         * @param id
>>         * @param model
>>         */
>>        public OpenOnLoadModalWindow(String id, IModel<?> model) {
>>                super(id, model);
>>        }
>>
>>        /**
>>         * Adds the JavaScript to initially open modal window.
>>         */
>>        public void renderHead(IHeaderResponse response)
>>        {
>>
>>  response.renderOnDomReadyJavascript(getWindowOpenJavascript());
>>        }
>>
>>        /*
>>         * (non-Javadoc)
>>         * @see
>> org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#makeContentVisible()
>>         */
>>        @Override
>>        protected boolean makeContentVisible()
>>        {
>>                return true;
>>        }
>> }
>>
>> Would this class, or one derived form this one, or a better solution
>> if one is known:), be included on the framework. Or this is just a
>> topic for wiki page?
>>
>> Regards,
>>
>> Ernesto
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: opening ModalWindow on page load

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Martin,

Yes you are right the requests/e-mails I have seen are older that two
years. But I'm not sure this is not a feature  everyone needs: maybe
when people have such a need they look at ModalWindow and then realize
it can't do the job and then turn to use other solution (e.g. jquery
Dialog which have an autoOpen property). In my case jquery Dialog was
not a good solution, so, I went into trying to fix modal window to do
the Job:-)

I will add a wiki page then.

Regards,

Ernesto


On Tue, Nov 23, 2010 at 4:24 PM, Martin Grigorov <mg...@apache.org> wrote:
> Wiki page is OK for now.
> 1) it is easy to create if needed
> 2) I don't remember such request in the mailing lists for the last 2 years,
> so it is not something everyone needs
>
> My 2c.
>
> On Tue, Nov 23, 2010 at 4:16 PM, Ernesto Reinaldo Barreiro <
> reiern70@gmail.com> wrote:
>
>> Hi,
>>
>> In one of the application we working at right now we have the
>> requirement that the user should fill in some extra information before
>> he/she is allowed to work with some pages. We wanted to do this with a
>> modal window blocking the page till this information is provided. So,
>> the requirement is:
>>
>> -Modal window should be opened immediately after a page is load.
>>
>> After a bit of messing around/googling we came up with this class, who
>> seems to be doing the job:-)
>>
>> public class OpenOnLoadModalWindow extends ModalWindow implements
>> IHeaderContributor {
>>
>>        private static final long serialVersionUID = 1L;
>>
>>        /**
>>         * @param id
>>         */
>>        public OpenOnLoadModalWindow(String id) {
>>                super(id);
>>        }
>>
>>        /**
>>         * @param id
>>         * @param model
>>         */
>>        public OpenOnLoadModalWindow(String id, IModel<?> model) {
>>                super(id, model);
>>        }
>>
>>        /**
>>         * Adds the JavaScript to initially open modal window.
>>         */
>>        public void renderHead(IHeaderResponse response)
>>        {
>>
>>  response.renderOnDomReadyJavascript(getWindowOpenJavascript());
>>        }
>>
>>        /*
>>         * (non-Javadoc)
>>         * @see
>> org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#makeContentVisible()
>>         */
>>        @Override
>>        protected boolean makeContentVisible()
>>        {
>>                return true;
>>        }
>> }
>>
>> Would this class, or one derived form this one, or a better solution
>> if one is known:), be included on the framework. Or this is just a
>> topic for wiki page?
>>
>> Regards,
>>
>> Ernesto
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: opening ModalWindow on page load

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Peter,

> p.s.: Ernesto, thanks for sharing your code!

Glad to be of some help:-)

Regards,

Ernesto

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: opening ModalWindow on page load

Posted by Major Péter <ma...@sch.bme.hu>.
Hi,

A colleague of mine wanted to do the same just last week. He ended up 
dropping modal window, and the problem was solved in a different way, so 
there are use-cases for this functionality.
(ours was: popping a modal window for user to accept/decline a 
pre-defined profile image on first visit/until choice made.)

p.s.: Ernesto, thanks for sharing your code!

Regards,
Peter

2010-11-23 16:24 keltezéssel, Martin Grigorov írta:
> Wiki page is OK for now.
> 1) it is easy to create if needed
> 2) I don't remember such request in the mailing lists for the last 2 years,
> so it is not something everyone needs
>
> My 2c.
>
> On Tue, Nov 23, 2010 at 4:16 PM, Ernesto Reinaldo Barreiro<
> reiern70@gmail.com>  wrote:
>
>> Hi,
>>
>> In one of the application we working at right now we have the
>> requirement that the user should fill in some extra information before
>> he/she is allowed to work with some pages. We wanted to do this with a
>> modal window blocking the page till this information is provided. So,
>> the requirement is:
>>
>> -Modal window should be opened immediately after a page is load.
>>
>> After a bit of messing around/googling we came up with this class, who
>> seems to be doing the job:-)
>>
>> public class OpenOnLoadModalWindow extends ModalWindow implements
>> IHeaderContributor {
>>
>>         private static final long serialVersionUID = 1L;
>>
>>         /**
>>          * @param id
>>          */
>>         public OpenOnLoadModalWindow(String id) {
>>                 super(id);
>>         }
>>
>>         /**
>>          * @param id
>>          * @param model
>>          */
>>         public OpenOnLoadModalWindow(String id, IModel<?>  model) {
>>                 super(id, model);
>>         }
>>
>>         /**
>>          * Adds the JavaScript to initially open modal window.
>>          */
>>         public void renderHead(IHeaderResponse response)
>>         {
>>
>>   response.renderOnDomReadyJavascript(getWindowOpenJavascript());
>>         }
>>
>>         /*
>>          * (non-Javadoc)
>>          * @see
>> org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#makeContentVisible()
>>          */
>>         @Override
>>         protected boolean makeContentVisible()
>>         {
>>                 return true;
>>         }
>> }
>>
>> Would this class, or one derived form this one, or a better solution
>> if one is known:), be included on the framework. Or this is just a
>> topic for wiki page?
>>
>> Regards,
>>
>> Ernesto

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: opening ModalWindow on page load

Posted by Martin Grigorov <mg...@apache.org>.
Wiki page is OK for now.
1) it is easy to create if needed
2) I don't remember such request in the mailing lists for the last 2 years,
so it is not something everyone needs

My 2c.

On Tue, Nov 23, 2010 at 4:16 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Hi,
>
> In one of the application we working at right now we have the
> requirement that the user should fill in some extra information before
> he/she is allowed to work with some pages. We wanted to do this with a
> modal window blocking the page till this information is provided. So,
> the requirement is:
>
> -Modal window should be opened immediately after a page is load.
>
> After a bit of messing around/googling we came up with this class, who
> seems to be doing the job:-)
>
> public class OpenOnLoadModalWindow extends ModalWindow implements
> IHeaderContributor {
>
>        private static final long serialVersionUID = 1L;
>
>        /**
>         * @param id
>         */
>        public OpenOnLoadModalWindow(String id) {
>                super(id);
>        }
>
>        /**
>         * @param id
>         * @param model
>         */
>        public OpenOnLoadModalWindow(String id, IModel<?> model) {
>                super(id, model);
>        }
>
>        /**
>         * Adds the JavaScript to initially open modal window.
>         */
>        public void renderHead(IHeaderResponse response)
>        {
>
>  response.renderOnDomReadyJavascript(getWindowOpenJavascript());
>        }
>
>        /*
>         * (non-Javadoc)
>         * @see
> org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#makeContentVisible()
>         */
>        @Override
>        protected boolean makeContentVisible()
>        {
>                return true;
>        }
> }
>
> Would this class, or one derived form this one, or a better solution
> if one is known:), be included on the framework. Or this is just a
> topic for wiki page?
>
> Regards,
>
> Ernesto
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>