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 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 function 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 return NULL value

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

Thanks in advance




kenixwong wrote:
> 
> Hi, Ed
> 
> i just read from the forum you sent.... if you don't mind, can you give
> more example ? because i based on the in instruction , i still cant get
> it. An no idea for this part
> 
>         getBodyContainer().addOnLoadModifier(
>                   new ClickOnceOnLoadModel( modalWindowOpeningLink ), null
> );
> 
> As my code structure this like this way
> 
> 
> public class LastThirtyDaysLineChart extends CommonPage{
> 
> 
>     // main contructor. Initial the page to show what
>     public LastThirtyDaysLineChart () {
>         // 1. display the feedback panel
>         add(new FeedbackPanel("feedback"));
>        
>         // 2. display the component defined in form
>         add(new
> LastThirtyDaysLineChartForm("LastThirtyDaysLineChartForm"));
>     }
> 
>    
>     // the form declare the component in order display in the web browser
>     private class LastThirtyDaysLineChartFormextends Form{
>    
>         // 3. so, is the main source to get the data from Database  in
> order to generate the chart
>         generate Time series chart...
>     }
> }
> 
> 
> 
> So, in which part i need to generate the ModalWindow with no onClick event
> ...Mean  once this page is load, the modal window will auto prompt on
> screen...
> 
> 
> Can you give some instruction to me ? thanks in advance
> 
> 
> 
> 
> Ed_ wrote:
>> 
>> 
>> Thanks Ryan,
>> 
>> First pass this has worked well for me. Appreciate your detailed
>> instructions. Maybe these can be added to the open issue history itself
>> for other folks till the issue gets closed.
>> 
>> I assume you have to be developer to make changes to the change history.
>> 
>> -ed
>> 
>>> From: [EMAIL PROTECTED]
>>> Subject: Re: modal window question - opening a modal window on page load
>>> Date: Sun, 9 Sep 2007 22:24:03 -0700
>>> To: users@wicket.apache.org
>>> 
>>> There is an open issue about this: http://issues.apache.org/jira/ 
>>> browse/WICKET-12
>>> Read the discussion for some background and possible solutions.
>>> 
>>> I needed to do the same thing on a couple of pages. First, I tried  
>>> using getWindowOpenJavascript() on the modal window (called via  
>>> reflection as it's a private method) to get the needed JS, but I  
>>> think I ran into a few issues which I've now forgotten (private  
>>> 'shown' variable wasn't set?).
>>> 
>>> What I ended up doing was to use JavaScript to call the onclick()  
>>> method of a link that opens the modal window from my page's onload  
>>> function. Since the modal window is a JavaScript construct anyway I  
>>> don't think using JS for the "auto-open" behavior is weird.
>>> 
>>> 
>>> The following model ensures that a component is "clicked" only one  
>>> time, when the page is initially loaded (probably a common use case).  
>>> If you want to open the modal window on every page load, just check  
>>> out the JavaScript and the basic concept. This is written for Wicket  
>>> 1.2 but a similar approach should work for 1.3.
>>> 
>>> public class ClickOnceOnLoadModel extends AbstractReadOnlyModel {
>>>    private final Component component;
>>>    private boolean clicked = false;
>>> 
>>>     public ClickOnceOnLoadModel(Component component) {
>>>      this.component = component;
>>>    }
>>> 
>>>    @Override
>>>    public Object getObject(Component cmp) {
>>>      if ( !this.clicked ) {
>>>        this.clicked = true;
>>>        return getClickJs();
>>>      }
>>>      return null;
>>>    }
>>> 
>>>    private String getClickJs() {
>>>      StringBuilder sb = new StringBuilder( 64 );
>>>      sb.append( "var e=document.getElementById('" );
>>>      sb.append( this.component.getMarkupId() );
>>>      sb.append( "');e.onclick();" );
>>>      return sb.toString();
>>>    }
>>> }
>>> 
>>> 
>>> You would use it like this:
>>> 
>>> // Page constructor
>>> public MyPage() {
>>>     getBodyContainer().addOnLoadModifier(
>>>            new ClickOnceOnLoadModel( modalWindowOpeningLink ), null );
>>> }
>>> 
>>> 
>>> This of course requires a link on your page that opens the same modal  
>>> window you want to open automatically. If you really don't want such  
>>> a link, you could always hide it with CSS.
>>> 
>>> If there are more elegant solutions (and I'm sure there are), you'll  
>>> probably hear about them soon...
>>> 
>>> -Ryan
>>> 
>>> On Sep 9, 2007, at 8:04 PM, Ed _ wrote:
>>> 
>>> >
>>> > I want to bring up a modal window when I load a page, ie without  
>>> > clicking a link. I want to use it to prompt the user to enter some  
>>> > data on the home page before he can proceed. So somehow I have to  
>>> > enable the show function, how do I do that.
>>> >
>>> > I tried to do something as follows -
>>> >
>>> >             FormPanel form =  new FormPanel(modal.getContentId(),  
>>> > StoreBasePath, strId, title);
>>> >             form.setOutputMarkupId(true);
>>> >             modal.setContent(form);
>>> >             modal.setTitle("This is modal window with panel  
>>> > content.");
>>> >             modal.setCookieName("modalform");
>>> >             AjaxRequestTarget target = new AjaxRequestTarget();
>>> >             modal.show(target);
>>> >
>>> > java.lang.IllegalStateException: No Page found for component  
>>> > [MarkupContainer [Component id = ModalWindow, page = <No Page>,  
>>> > path = FormPanel:ModalWindow.ModalWindow]]
>>> >      at wicket.Component.getPage(Component.java:1037)
>>> >      at wicket.RequestCycle.urlFor(RequestCycle.java:655)
>>> >      at wicket.Component.urlFor(Component.java:2307)
>>> >      at wicket.behavior.AbstractAjaxBehavior.getCallbackUrl 
>>> > (AbstractAjaxBehavior.java:143)
>>> >      at wicket.ajax.AbstractDefaultAjaxBehavior.getCallbackScript 
>>> > (AbstractDefaultAjaxBehavior.java:131)
>>> >
>>> >
>>> > is there a way to do this.
>>> >
>>> > thanks
>>> >
>>> > _________________________________________________________________
>>> > Gear up for Halo® 3 with free downloads and an exclusive offer.  
>>> > It’s our way of saying thanks for using Windows Live™.
>>> > http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>> 
>> 
>> _________________________________________________________________
>> Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our
>> way of saying thanks for using Windows Live™.
>> http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/modal-window-question---opening-a-modal-window-on-page-load-tp12586008p15154850.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to