I did. I made a simplified widget Menu. I realized that WMenu not
suitable for my purposes. Wt perfectly well that extends and allows
you to create widgets based on available, this helps a great hierarchy
of classes. Thanks you very mach! :)

Regards,
Aleksey

2010/3/6 OvermindDL1 <[email protected]>:
> On Thu, Mar 4, 2010 at 7:26 AM, Koen Deforche <[email protected]> wrote:
>> Hey Aleksey,
>>
>> 2010/3/4 Aleksey Chirkin <[email protected]>:
>>> I noticed that LazyLoading in WMenu does not work.
>>> Content always loading as though PreLoading activated, but i make
>>> WMenuItems with LazyLoading option.
>>>
>>> Here is example:
>>
>> (...)
>>
>>> class Page2 : public WContainerWidget
>>> {
>>> public:
>>>        Page2()
>>>        {
>>>                addWidget(new WText("this is page2"));
>>>                std::cout << "Page2 is loaded" << std::endl;
>>>        }
>>> };
>>>
>>
>> (...)
>>
>>>                menu->addItem("page2", new Page2(), WMenuItem::LazyLoading);
>>
>> Although page2 will not be inserted into the DOM, and therefore not
>> propagated to the browser, you are already creating the widget and
>> thus you will see "Page2 is loaded" printed.
>>
>> If you want to see how it is being loaded just-in-time, you should
>> reimplement the Page2::load() method and print there (and call the
>> base implementation).
>>
>> If you want to defer creation of the widget, you could use a utility
>> method similar to the following, which accepts a function that returns
>> a widget:
>>
>> template <typename Function>
>> class DeferredWidget : public WContainerWidget
>> {
>> public:
>>  DeferredWidget(Function f)
>>    : f_(f) { }
>>
>> private:
>>  void load() {
>>    WContainerWidget::load();
>>    addWidget(f_());
>>  }
>>
>>  Function f_;
>> };
>>
>> template <typename Function>
>> DeferredWidget<Function> *deferCreate(Function f)
>> {
>>  return new DeferredWidget<Function>(f);
>> }
>>
>>
>>
>> You do it even simpler if creating the widget using the default
>> constructor is acceptible:
>>
>> template <typename Widget>
>> class DeferredWidget : public WContainerWidget
>> {
>> public:
>>  DeferredWidget() { }
>>
>> private:
>>  void load() {
>>    WContainerWidget::load();
>>    addWidget(new Widget());
>>  }
>> };
>>
>>  menu->addItem("page2", new DeferredWidget<Page2>(), WMenuItem::LazyLoading);
>
> What about adding both of those patterns to Wt itself?  Seems like a
> common use-case, I do it myself often actually.
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to