From: Mark Probert Date: 2004-09-11T04:45:01+09:00 Subject: IOWA binding magic (long) Hi, Kirk and everyone. This one is a little tough to explain so please bear with me. Like DemoApp, I have a header and leftnav, with Header importing LeftNav. Header.iwa looks like: import 'LeftNav' class Header < Iowa::Component attr_binding :user, :ulevel # stuff gone end LeftNav.iwa like: class LeftNav < Iowa::Component attr_binding :user, :ulevel def foo_page newPage = page_named("Run::Foo") newPage.user = @user newPage.ulevel = @ulevel yield newPage end end LeftNav.html looks like:
The main page (Index.html) has a login form from which I extract user and ulevel (user access level). So, when I login I go to page Bar which is generated from the Login button on the main form (Index.iwa) like: def goLogin check_login_details # form validation .. errors into @errlist if @errlist.empty? # Now go into the application itself newPage = page_named('Run::Main') @ulevel = $hcSecurity.userGroup(@username) newPage.user = CGI::escapeHTML(@username) newPage.ulevel = @ulevel yield newPage end end Which works fine. Run::Main has the correct username and ulevel. [As an aside, I noted that CGI::escapeHTML(@username) wiped @username. Is this expected behanviour?] However, if I click on the LeftNav foo link, the username and ulevel are both blank (empty strings). Obviously, I am not getting the bindings right somewhere. Main.iwa is very simple and looks like: import 'Header' import 'Footer' class Main < Iowa::Component attr_accessor :header, :user, :ulevel def run_single new_page = page_named("Run::SingleCmd") yield new_page end end This make any sense? Also, I notice that there is an 'attr_binding' attribute. Can you explain that one to me? Regards, -- -mark. (probertm @ acm dot org)