Project

General

Profile

Actions

Bug #1847

closed

doJavaScript on WWidget in wt.3.3.0

Added by Anonymous almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
High
Assignee:
Target version:
Start date:
04/17/2013
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I have this object structure:

CBase : WTemplate
{
public:
    CBase()
    {
       addFunction("tr", &Wt::WTemplate::Functions::tr);
       ...
       bindWidget("b1", b1_);
       bindWidget("b2", b2_);
    }
protected:
   virtual void refresh()
   {
     WTemplate::refresh();

     doJavaScript('custom_java_script_function');
   }
...

private:
    //internal widgets
    Wt::WPushButton* b1_;
    Wt::WPushButton* b2_;

}

CDerived : public CBase
{
public:
    CDerived()
    {
       setTemplateText(tr("MyTemplate"));

       ...
       bindWidget("medit", edit_);
    }
private:
    Wt::WLineEdit* edit_;
}

The problem arises when calling WApplication::setLocale on my web application, for changing the locale. I've noticed that setLocale calls WApplication::refresh() which calls refresh on every widget in the application, so CBase::doJavaScript is called on changing the locale.

When the 'custom_java_script_function' is executed, it checks the presence of the DOM object associated with the Wt::WLineEdit* edit_ in CDerived, but the object is not present in the DOM tree yet (I think this is true for all widgets that are bound in the template, from base class too). As you can see above, in CBase, the called doJavaScript is the WWidget::doJavaScript so I would expect that the DOM object associated with the edit_ to be in the DOM tree when the 'custom_java_script_function' is called since it is a member of CDerived template widget.

I tried to override the refresh() method in CDerived too and have it call WTemplate::refresh() and CBase::refresh(), but with the same effect.

This problem didn't manifest with wt.3.2.1. I have checked, and with wt.3.2.1 all widgets (CBase and CDerived with their members)exist in the DOM tree at the moment when 'custom_java_script_function' executes.

Also it doesn't occur when refreshing the page using F5 in browser.

Is this a bug in wt.3.3.0 or maybe I should use another approach ?


Files

WT1847.7z (2.51 MB) WT1847.7z W X, 04/22/2013 11:50 AM
#1

Updated by Koen Deforche almost 12 years ago

  • Status changed from New to InProgress
  • Assignee set to Koen Deforche
  • Target version set to 3.3.1
#2

Updated by W X almost 12 years ago

#5

Updated by Wim Dumon almost 12 years ago

  • Status changed from InProgress to Resolved
  • Assignee changed from Koen Deforche to Wim Dumon
#8

Updated by Koen Deforche over 11 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF