You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by netfork <ia...@gmail.com> on 2007/06/02 16:45:14 UTC

When page is onload, can Ajax Modal window be loaded?

I have a question.
When my page is onload, can Ajax Modal window be loaded?
It's auto loaded. Not click button to load modal window.
Please help me.Thanks a lot!
-- 
View this message in context: http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tf3857232.html#a10927996
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: When page is onload, can Ajax Modal window be loaded?

Posted by Sapounov Alexey <sa...@gmail.com>.
Sorry for my english...

For me, I found the solution:

This works for me because I haven't any links on my page

1. Create na AjaxLink for show modal window.
2. Set the CSS attribute visibility to hidden (we don't need a click by
mouse to that link :) )

3. Use JavaScript for "click" this link:
3.1 - search the links on page :
     var linksOnpage = document.getElementsByTagName("A");
     var showModalLink = document.getElementById(linksOnPage[0].id);

3.2 - "click" the link
    showModalLink.onClick();

that's all :)

4. Don't forget to add "onLoad" to <body> tag


--------------------
<body onLoad="showModal">

<script>

function showModal(){
     var linksOnpage = document.getElementsByTagName("A");
     var showModalLink = document.getElementById(linksOnPage[0].id);
     showModalLink.onClick();
}

</script>



    

or shorter:


function showModal(){
     var showModalLink =
document.getElementById(document.getElementsByTagName("A")[0].id);
     showModalLink.onClick();
}

-- 
View this message in context: http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tp10927996p20836349.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: When page is onload, can Ajax Modal window be loaded?

Posted by kenixwong <ke...@yahoo.com>.
Hi, 

i had change the idea to do it ...my page will be left menu bar (few report
links)  and content page. Once click on the report link, it will load the
report and Pop up a modal window at the same time. The modal   window has
some message and a cancel button. 

What i want is the report is running at the background until finish. But
when user click on cancel button  then it will stop the process. The main
reason i need to have this feature is because the report page will be load a
huge data. The modal window just facilities the user whether want to stop
the backend process or not if user don't wish to wait the report page load
until finish.

the way i tried is 

1) normal link for the left menu bar ( once link is clicked , setResponse to
the report page )
2) Once the report page is first loading, pop up a modal window at the same
time with cancel button
    So, in this report page , i had create a modal window component 

    final ModalWindow cancelReportModal = new
ModalWindow("cancelReportModal");
		
		add(cancelReportModal);
				
		cancelReportModal.setPageMapName("cancelReportModal");
		cancelReportModal.setCookieName("cancelReportModal");
		cancelReportModal.setResizable(false);		
		cancelReportModal.setInitialWidth(30);
		cancelReportModal.setInitialHeight(12);
		cancelReportModal.setWidthUnit("em");
		cancelReportModal.setHeightUnit("em");
		
		cancelReportModal.setPageCreator(new ModalWindow.PageCreator()  
		{
			public Page createPage()
			{
				return new CancelReportModalPage(reportPage.this);
			}
		});
		cancelReportModal.setOutputMarkupId(true);

   From the wicket example,  it use ajaxLink to call up the modal widow once
the user click on the link ( mean onClick function is performed )

       final  AjaxLink ajaxLink ;
		ajaxLink = new AjaxLink("cancelReportModalLink"){
			@Override
			public void onClick(AjaxRequestTarget target) {
				cancelReportModal.show(target);			
			}			
		}; 

 
 But in here , i don't any idea how to auto display the modal window on
screen. i had tried for the solution given from this forum
(http://www.nabble.com/modal-window-question---opening-a-modal-window-on-page-load-to12586008.html)
which talk about 

getBodyContainer().addOnLoadModifier(
           new ClickOnceOnLoadModel( modalWindowOpeningLink ), null );  


put inside the page constructor. but i cant get it also... 

i had tried also to auto load the onClick functinby this way. but failed to
do that too...
                 AjaxLink link ;
		AjaxRequestTarget target2 = new AjaxRequestTarget();
		add(link = new AjaxLink("cancelReportModalLink")
				{
					public void onClick(AjaxRequestTarget target)
					{
						System.out.println(" target = " + target);
						
						triggerTarget = target;
						System.out.println(" triggerTarget = " + triggerTarget);
						cancelReportModal.show(target);
					}
				}); 
		link.onClick(triggerTarget);

the target value all the while also retun NULL value

can somebody give some reference to me .. is that possible the to load the
modal window automatically without the click the button?

Thanks in advance






kenixwong wrote:
> 
> yes...i have the same question here.... can wicket do that. For my case,
> When my page is onload, Ajax Modal window is auto loaded ( Not click
> button to load modal window). This modal window will display the message
> and 2 button ( stop and continue ). Once the user click the stop button,
> mean backend process is stop. If continue button is click, it will send
> response to load a report page at the current page. 
> 
> i had searched the forum  as below link , but i still cant get the
> solution yet. 
> http://www.nabble.com/modal-window-question---opening-a-modal-window-on-page-load-to12586008.html#a12598786
> 
> Can anybody help or give more explanation on it ?
> 
> 
> thanks in advance
> 
> 
> 
> Matej Knopp-2 wrote:
>> 
>> It can. But you have to call the javascript on your own. It's not a
>> trivial thing to do.
>> 
>> -Matej
>> 
>> On 6/2/07, netfork <ia...@gmail.com> wrote:
>>>
>>> I have a question.
>>> When my page is onload, can Ajax Modal window be loaded?
>>> It's auto loaded. Not click button to load modal window.
>>> Please help me.Thanks a lot!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tf3857232.html#a10927996
>>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tp10927996p15154810.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: When page is onload, can Ajax Modal window be loaded?

Posted by kenixwong <ke...@yahoo.com>.
yes...i have the same question here.... can wicket do that. For my case, When
my page is onload, Ajax Modal window is auto loaded ( Not click button to
load modal window). This modal window will display the message and 2 button
( stop and continue ). Once the user click the stop button, mean backend
process is stop. If continue button is click, it will send response to load
a report page at the current page. 

i had go thru the forum  as below link , but i still cant get the solution
yet.
http://www.nabble.com/modal-window-question---opening-a-modal-window-on-page-load-to12586008.html#a12598786


Can anybody help or give more explanation on it ?


thanks in advance



Matej Knopp-2 wrote:
> 
> It can. But you have to call the javascript on your own. It's not a
> trivial thing to do.
> 
> -Matej
> 
> On 6/2/07, netfork <ia...@gmail.com> wrote:
>>
>> I have a question.
>> When my page is onload, can Ajax Modal window be loaded?
>> It's auto loaded. Not click button to load modal window.
>> Please help me.Thanks a lot!
>> --
>> View this message in context:
>> http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tf3857232.html#a10927996
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tp10927996p15151070.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: When page is onload, can Ajax Modal window be loaded?

Posted by Matej Knopp <ma...@gmail.com>.
It can. But you have to call the javascript on your own. It's not a
trivial thing to do.

-Matej

On 6/2/07, netfork <ia...@gmail.com> wrote:
>
> I have a question.
> When my page is onload, can Ajax Modal window be loaded?
> It's auto loaded. Not click button to load modal window.
> Please help me.Thanks a lot!
> --
> View this message in context: http://www.nabble.com/When-page-is-onload%2C-can-Ajax-Modal-window-be-loaded--tf3857232.html#a10927996
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>