New topic: WebToolbar dynamic caption issue
<http://forums.realsoftware.com/viewtopic.php?t=47769> Page 1 of 1 [ 5 posts ] Previous topic | Next topic Author Message louisd Post subject: WebToolbar dynamic caption issuePosted: Thu May 02, 2013 5:16 pm Joined: Fri Jul 27, 2012 9:52 am Posts: 8 Hello all; I am writing a web app that needs to be multi-lingual. TYhe strings are in a database, and upon loginm, I load the language-specific strings in an array setup as a session property. Then, each page gets assigned the appropriate strings in the Open event. I am experiencing a problem with the WebToolbar. It resists my best efforts to set the menu item captions at runtime. My code is like this, in the M.Open event section: (The page is called Mainmenu and the toolbar is currently called M, and each item is called M01, M02 etc.) Dim item1 As WebToolbarContainer item1 = WebToolbarContainer(Me.ItemWithName("M01")) If item1 <> Nil Then item1.Caption = session.apptext(3) 'Application menu End If This code compiles OK, but I always get an Unhandled IllegalCastException error. If I use for example "M00", which is not already set at design time, then the code runs just fine. Can someone please point me in the direction of a solution? (or at least shed some light on my error) Thanks in advance. LD Top taylor-design Post subject: Re: WebToolbar dynamic caption issuePosted: Thu May 02, 2013 6:07 pm Joined: Wed Mar 22, 2006 11:15 am Posts: 665 Location: Southern California Stab in the dark: does the code work in the Shown event? In WE the page and controls are not fully setup in Open. _________________ Daniel L. Taylor Custom Controls for Real Studio WE! Visit: http://www.webcustomcontrols.com/ Top louisd Post subject: Re: WebToolbar dynamic caption issuePosted: Thu May 02, 2013 7:05 pm Joined: Fri Jul 27, 2012 9:52 am Posts: 8 I also tried in the shown event. Same issue. I should also perhaps have indicated that I am using 2012 R2. thanks. LD Top taylor-design Post subject: Re: WebToolbar dynamic caption issuePosted: Thu May 02, 2013 7:58 pm Joined: Wed Mar 22, 2006 11:15 am Posts: 665 Location: Southern California Looking over the code...is M01 actually a WebToolbarContainer? The code works for me. But if I remove the container and add a button with the name M01, then it fails with an IllegalCastException. If you have different types in your toolbar you will need to use IsA to check type and correctly cast each item. Example: Dim item1 As WebToolbarItem item1 = Me.ItemWithName("M01") If item1 IsA WebToolbarContainer Then WebToolbarContainer(item1).Caption = "Test" ElseIf item1 Isa WebToolbarButton Then WebToolbarButton(item1).Caption = "Test" End If _________________ Daniel L. Taylor Custom Controls for Real Studio WE! Visit: http://www.webcustomcontrols.com/ Top louisd Post subject: Re: WebToolbar dynamic caption issuePosted: Thu May 02, 2013 8:09 pm Joined: Fri Jul 27, 2012 9:52 am Posts: 8 Doh! I guess I overlooked the obvious. Thank you so much for your help! LD Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 5 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
